Skip to content
shadcn.io

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.

Framework
UI library

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

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

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.

Should warning alerts be dismissible or persistent?

Persistent while the condition holds: a warning about a full disk should stay until there's space. The Alert never hides itself, so it stays until your code stops rendering it. Let readers dismiss only warnings they can safely ignore.

Are warning alerts accessible to screen readers?

Yes: Alert renders with role="alert", so the warning is announced as soon as it appears. The title states the problem in text, so the amber color isn't the only signal.