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

# cancel(_:action:)

Creates an alert button that indicates cancellation, with a custom label.

## Declaration

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

## Parameters

- `label`: The text to display on the button.
- `action`: A closure to execute when the user taps or presses the button.

## Return Value

Return Value An alert button that indicates cancellation.

## See Also

### Getting a button

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