Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Alert examples · Warning

Warning with Title and Description Alert for React

A warning alert with a title and a one-sentence description.

Framework
UI library

Warnings get clearer with context. This React alert pairs an AlertTitle with an AlertDescription in an Alert with variant="warning", so the title names the risk and the sentence says what could happen. Use it for risky actions, quotas or permissions where the reader needs to understand why to be careful.

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 does this warning alert contain?

AlertTitle with the text Warning, and AlertDescription with "This action may have unintended consequences. Please proceed with caution." The root is variant="warning" and className="max-w-lg".

Is there an icon or a button?

No. Put TriangleAlertIcon first if you want the icon column, or Proceed and Cancel in AlertAction if the reader should choose.

Why isn't the description amber?

The warning variant tints the alert's background and border and colors the icon, but keeps the text in the theme's foreground and muted colors. Amber text would be hard to read, and the tint already marks the alert as a warning.

How do the title and description line up?

Alert is a grid with a small gap. AlertTitle is font-medium and AlertDescription follows it, wrapping inside max-w-lg.

Should warnings with descriptions auto-hide?

No. A warning should stay while the risk does, and an Alert never hides itself; it stays until your code removes it, for example once the quota is back under its limit.

How is this warning announced?

Alert defaults to role="alert", so the title and description are announced when the alert appears. The warning color is not the only signal, because the text names the risk.