shadcn.io is not affiliated with official shadcn/ui
Alert examples · Warning
Warning with Title and Action Alert for React
A warning alert with a title and Proceed and Cancel buttons.
Warnings with choices respect the reader. This React alert puts Proceed and Cancel buttons in AlertAction, at the end of an Alert with variant="warning" and a single AlertTitle. Use it for risky actions or limits where the reader decides whether to continue or back out.
Preview
Installation
FAQ
What sits next to the Warning title?
Proceed and Cancel, in one AlertAction. The alert is variant="warning" with a single AlertTitle and no description.
Why is Proceed a default button rather than amber?
Button has no warning variant, so Proceed uses the default variant and Cancel uses outline, both size="xs". The alert's amber tint carries the caution. In the warning variant, ghost buttons inside AlertAction take an amber hover color.
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 Proceed first and Cancel after it.
Do Proceed and Cancel do anything in this file?
No. Neither button has a click handler. Stopping or continuing is something you add. Alert itself does not close.
Related
- Warning with Title AlertA warning alert with only a title, for a
- Warning with Title and Description AlertA warning 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
- Success with Title and Action AlertA success alert with a title and View
- Warning with Everything AlertA warning alert with a warning icon, a