Alert
Shows an inline message about a status or event.
Preview mode
Changes stay in this workspace until you publish.
alert-basic-demo.tsx
Installation
The CLI adds the files, packages, theme variables, and Tailwind plugin that this component uses. Before you run it, set up your project.
npm
yarn
pnpm
bun
Composition
AlertAlertIconAlertTitleAlertDescriptionAlertActionOptionalAlertDismissOptional
Variants
Preview mode
Changes stay in this workspace until you publish.
Ready to publish
Your changes are saved and can go live.
Check your billing details
Update the card on file before the next renewal.
Could not save changes
Check your connection and try again.
Scheduled maintenance
The workspace will be read-only on Sunday morning.
alert-demo.tsx
Action
The action moves below the text in a narrow alert. Also install Button link.
Set up your project
Complete the one-time setup before you add a component.
alert-action-demo.tsx
Dismiss
Move focus to a nearby control before the alert leaves, so focus is not lost. Also install Presence.
Invite sent
Maya gets an email with a link to join.
alert-dismiss-demo.tsx
API reference
- title: string
- Shows the variant icon and a heading, with children as the description. Leave it out to build the alert from its parts.
- variant: "info" | "success" | "warning" | "error" | "neutral" = "info"
- Sets the colors and the icon.
- action: ReactNode
- Controls after the text, such as a button. Works with title.
- onDismiss: () => void
- Shows a close button. Remove the alert in this function.
- dismissLabel: string = "Dismiss"
- Accessible name of the close button.
- children: ReactNode
- The alert content. When title is set, children become the description.
- role: "status" | "alert"
- Screen readers do not announce an alert by default. For a message that appears after an action, set "status". For an urgent error, set "alert".