Base · Feedback
Alert
An inline message that calls attention to something on the page.
HTML / JSDraftReactStableReact NativeDraftSwift (SwiftUI)PlannedGodotPlannedVueDraftSvelteDraftSolidDraft
Reviewed
Customs documents missing
Upload the commercial invoice before Friday to avoid a delay at the border.
Props
tsx
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"
<Alert>
<AlertTitle>Customs documents missing</AlertTitle>
<AlertDescription>Upload the commercial invoice before Friday to avoid a delay at the border.</AlertDescription>
</Alert>Overview
Alerts sit in the page flow next to the content they are about. They stay until the situation changes, unlike toasts, and do not interrupt, unlike dialogs.
When to use
- To tell people about a condition affecting the page or section: an error, a warning, a notice.
- At the top of a form to summarise what went wrong.
When not to use
- For feedback on an action that just happened: use Toast.
- When a response is required before continuing: use Alert Dialog.
- For a status on one item: use Badge.
Anatomy
Container
A bordered surface spanning the content width.
Icon (optional)
Reinforces the intent so color is not the only signal.
Title
A short statement of what happened.
Description (optional)
What it means and what to do next.
Props
The contract every language implements. Names follow each language’s conventions (camelCase in React, snake_case in Rust).
| Prop | Type | Default | Description |
|---|---|---|---|
| variant | "default" | "destructive" | default | Neutral notice or error. |
| title | string | Customs documents missing | Example content: the alert title. |
| description | string | Upload the commercial invoice before Friday to avoid a delay at the border. | Example content: the supporting text. |
States
- Static
- Alerts have no interactive states; actions inside them do.
Accessibility
Role: alert
- An alert that appears after page load is announced immediately by screen readers; do not use it for content that is always present.
- Say what to do next, not only what went wrong.
Design tokens
Change any of these in Foundations and this component follows, in every language.
Platform notes
- HTML / JS
- Draft
- A <div role="alert">, so screen readers announce it when it appears.
- React
- Stable
- Matches the contract with no platform differences.
- React Native
- Draft
- Matches the contract with no platform differences.
- Swift (SwiftUI)
- Planned
- Not built in Swift yet.
- Godot
- Planned
- Not built in Godot yet.
- Vue
- Draft
- Usage snippet only; same props and behavior as the React component.
- Svelte
- Draft
- Usage snippet only; same props and behavior as the React component.
- Solid
- Draft
- Usage snippet only; same props and behavior as the React component.