Skip to content
shadcn.io

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.

Framework
UI library

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

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.

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.

Why are both buttons in one AlertAction?

That part is a single absolutely positioned slot. A second AlertAction would sit on top of the first. The title is one word, which leaves room for the two xs buttons.

How is this warning announced?

Alert defaults to role="alert", so the title is announced when the alert appears. The amber border is not the only signal, because the title says Warning.