shadcn.io is not affiliated with official shadcn/ui
Alert examples · Info
Info with Title and Action Alert for React
An info alert with a title and Learn More and Dismiss buttons.
Information with a next step beats a passive notice. This React alert puts Learn More and Dismiss buttons in AlertAction, at the end of an Alert with variant="info" and a single AlertTitle. Use it for feature announcements or changelog highlights, where the reader can read more or acknowledge it and move on.
Preview
Installation
FAQ
What sits next to the title?
Learn More and Dismiss, in one AlertAction. The alert is variant="info" with a single AlertTitle and no description.
Why is Learn More a default button rather than blue?
Button has no info variant, so Learn More uses the default variant and Dismiss uses outline: the filled button is the one to press. The alert's blue tint already marks the message as information. In the info variant, ghost buttons in AlertAction take the blue hover color if you want a lighter pair.
Does Learn More go anywhere in this demo?
No. It is a Button with size="xs" and no href or click handler. Dismiss is the same size with variant="outline". Wire those yourself if the buttons should navigate or hide the alert.
Where are the buttons positioned?
AlertAction is absolutely positioned at the top right. The alert adds right padding so the title keeps its room. className="flex gap-2" puts the two xs buttons in a row.
Related
- Info with Title AlertAn info alert with only a title, for a
- Info with Title, Description and Action AlertAn info alert with a title, a
- Info with Title and Description AlertAn info alert with a title and a
- Error with Title and Action AlertA destructive alert with a title and
- Warning with Title and Action AlertA warning alert with a title and Proceed
- Info with Everything AlertAn info alert with an info icon, a title