---
title: "cancel(_:)"
framework: swiftui
role: symbol
role_heading: Type Method
path: "swiftui/alert/button/cancel(_:)"
---

# cancel(_:)

Creates an alert button that indicates cancellation, with a system-provided label.

## Declaration

```swift
static func cancel(_ action: (() -> Void)? = {}) -> Alert.Button
```

## Parameters

- `action`: A closure to execute when the user taps or presses the button.

## Return Value

Return Value An alert button that indicates cancellation.

## Discussion

Discussion The system automatically chooses locale-appropriate text for the button’s label.

## See Also

### Getting a button

- [default(_:action:)](swiftui/alert/button/default(_:action:).md)
- [cancel(_:action:)](swiftui/alert/button/cancel(_:action:).md)
- [destructive(_:action:)](swiftui/alert/button/destructive(_:action:).md)
