Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Alert examples · Standard

Standard with Everything Alert for React

A neutral alert with a check icon, a title, a description, and View Details and Dismiss buttons.

Framework
UI library

This is the full neutral alert: a CircleCheckIcon from Lucide, a title, a description, and View Details and Dismiss buttons, in the default Alert with no color tint. The icon goes first and the alert gives it its own column in the text color, so the title and description line up beside it. Use it for prominent general announcements that should stand out without a semantic color.

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

Which icon does this alert use, and why isn't it green?

CircleCheckIcon, with aria-hidden="true", next to a title that says Success. There is no variant, so the icon takes the alert's text color. variant="success" is what tints the border and paints the icon with --success.

Should standard alert icons use color or stay neutral?

Neutral fits the default variant: the icon takes the alert's text color, so nothing suggests an error or a success. If the icon needs a color, switch to the variant that matches it instead of coloring the icon alone.

How does the icon line up with the title?

Put it first, before AlertTitle: the alert places a direct svg child in its own column, spanning the title and description, aligns it with the title's first line, and sizes it unless you pass a size class.

How are View Details and Dismiss set up?

Both are size="xs" inside one AlertAction with className="flex gap-2". View Details is the default button. Dismiss is variant="outline". Neither has a click handler.

When should I use standard vs semantic colored variants?

Use a semantic variant (success, info, warning, destructive) when the reader should know the kind of message at a glance. Use the default when it's general, or when several colored alerts would compete.

What does the description say?

"Your changes have been saved successfully and are now live." It is an AlertDescription, in the muted color, under the title. The alert is capped with className="max-w-lg".