Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Alert examples · Success

Success with Title Alert for React

A success alert with only a title, for a message that needs no explanation.

Framework
UI library

Sometimes success needs no celebration, just confirmation. This React alert sets variant="success" on Alert and holds a single AlertTitle, so it reads as good news with a green tint and nothing else. Use it for saves, submissions or simple completions where the reader only needs to know it worked.

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 success alerts?

When the title is the whole story and the reader has nothing else to do: Changes saved, Invitation sent. If they might want to know what happens next, add an AlertDescription.

Where does the green styling come from?

From variant="success": a faint tint of the theme's --success color on the background, a stronger border, and the same color on any icon. The title keeps the regular text color, so it stays readable in light and dark mode.

Where should success alerts appear on the page?

Where the reader's attention already is: above the form they just saved, or at the top of the section that changed. A success message far from the action is easy to miss.

Should success alerts be dismissible or auto-hide?

An Alert stays until your code removes it, which suits a confirmation the reader may come back to. For one that should disappear on its own, use a toast such as Sonner. To let the reader close the alert, add a Dismiss button in AlertAction and hide it from your own state.

What should success alert titles say?

What succeeded, specifically: Profile updated, Payment received. The demo's Success is a placeholder; a specific title confirms the right thing happened.

Are success alerts accessible to screen readers?

Alert renders with role="alert", so the title is announced as soon as it appears. For a confirmation, a polite announcement is usually better: pass role="status" so it waits for the reader to finish what they're doing.