Asks people to confirm an action or acknowledge important information with SwiftUI's native alert.
Usage
The system draws alerts, with their own material, layout, and accessibility, so use .alert directly and open it from FLX components:
Inside an alert, use Button, not FLXButton. The system draws the buttons from their titles and roles and ignores button styles.
Buttons
A .destructive role paints the button red. A .cancel role marks the button that dismisses without acting, and the system places it for you. Every button dismisses the alert after its action runs.
Use .keyboardShortcut(.defaultAction) to mark the button people most likely want. The alert fills it with the app's AccentColor from the asset catalog, not with the theme, and Return chooses it. Set AccentColor to your theme's tint, as in Installation.
Examples
Text field
Add a TextField before the buttons to ask for a short value, such as a name.
Error
Pass a LocalizedError and the alert uses its errorDescription as the title.
Confirmation dialog
Use .confirmationDialog to offer a few choices about an action someone started. On macOS, a confirmation dialog appears as an alert attached to the window.
Alert, dialog, or sheet
- Use an alert for important information that needs a response, such as confirming a destructive action or reporting an error.
- Use a confirmation dialog when an action has a few possible outcomes.
- Use a Sheet when you need more than a short message and a text field.
For more information about alerts and confirmation dialogs, see the Apple documentation.







