shadcn.io is not affiliated with official shadcn/ui
Alert examples · Success
Success with Title and Action Alert for React
A success alert with a title and View Details and Dismiss buttons.
Success with a next step beats a passive confirmation. This React alert puts View Details and Dismiss buttons in AlertAction, at the end of an Alert with variant="success" and a single AlertTitle. Use it for confirmations the reader may want to follow up on, such as a finished upload or a completed task.
Preview
Installation
FAQ
What sits next to the Success title?
View Details and Dismiss, in one AlertAction. The alert is variant="success" with a single AlertTitle and no description.
Why is View Details a default button rather than green?
Button has no success variant, so View Details uses the default variant and Dismiss uses outline. The alert's green tint already says it's good news; the filled button only marks the main action.
What button variants work best for success alerts?
A default button for the main action and outline for Dismiss, as here, both size="xs". In the success variant, ghost buttons inside AlertAction take a green hover color, which suits a quieter pair.
Where are the buttons positioned?
AlertAction is absolutely positioned at the top right, and the alert adds right padding so the title keeps its room. className="flex gap-2" puts the two buttons in one row.
Related
- Success with Title AlertA success alert with only a title, for a
- Success with Title and Description AlertA success alert with a title and a
- Error with Title and Action AlertA destructive alert with a title and
- Info with Title and Action AlertAn info alert with a title and Learn More
- Warning with Title and Action AlertA warning alert with a title and Proceed
- Success with Everything AlertA success alert with a check icon, a