shadcn.io is not affiliated with official shadcn/ui
Alert examples · Warning
Warning with Title Alert for React
A warning alert with only a title, for a message that needs no explanation.
Sometimes a warning needs no paragraph, just a heads-up. This React alert sets variant="warning" on Alert and holds a single AlertTitle, so it reads as a caution with an amber tint. Use it for rate limits, quotas or reminders where the context is obvious and the reader only needs to know something deserves attention.
Preview
Installation
FAQ
When should I use title-only warning alerts?
When the title says what to watch out for and what to do is obvious: Storage almost full, Unsaved changes. If the reader would ask what happens if they ignore it, add an AlertDescription.
When should I use warning instead of error alerts?
A warning is about something that may go wrong; an error is about something that already did. An expiring plan or a nearly full disk is a warning; a failed payment is an error and uses variant="destructive".
Where does the amber styling come from?
From variant="warning": a faint tint of the theme's --warning color on the background, a stronger border, and the same color on any icon. The title keeps the regular text color, since amber text is hard to read on a light background.
Where should warning alerts appear on the page?
Before the thing it warns about: above a form whose submission is risky, at the top of a usage page for a quota. A warning after the action is too late to help.
Related
- Warning with Title and Description AlertA warning 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
- Success with Title AlertA success alert with only a title, for a
- Warning with Everything AlertA warning alert with a warning icon, a
- Warning with Title and Action AlertA warning alert with a title and Proceed