shadcn.io is not affiliated with official shadcn/ui
Alert examples · Success
Success with Title Alert for React
A success alert with only a title, for a message that needs no explanation.
Sometimes success needs no celebration, just confirmation. This React alert sets variant="success" on Alert and holds a single AlertTitle, so it reads as good news with a green tint and nothing else. Use it for saves, submissions or simple completions where the reader only needs to know it worked.
Preview
Installation
FAQ
When should I use title-only success alerts?
When the title is the whole story and the reader has nothing else to do: Changes saved, Invitation sent. If they might want to know what happens next, add an AlertDescription.
Where does the green styling come from?
From variant="success": a faint tint of the theme's --success color on the background, a stronger border, and the same color on any icon. The title keeps the regular text color, so it stays readable in light and dark mode.
Where should success alerts appear on the page?
Where the reader's attention already is: above the form they just saved, or at the top of the section that changed. A success message far from the action is easy to miss.
Should success alerts be dismissible or auto-hide?
An Alert stays until your code removes it, which suits a confirmation the reader may come back to. For one that should disappear on its own, use a toast such as Sonner. To let the reader close the alert, add a Dismiss button in AlertAction and hide it from your own state.
Related
- Success with Title and Description AlertA success alert with a title and a
- Error with Title AlertA destructive alert with only a title
- Info with Title AlertAn info alert with only a title, for a
- Warning with Title AlertA warning alert with only a title, for a
- Success with Everything AlertA success alert with a check icon, a
- Success with Title and Action AlertA success alert with a title and View