Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Alert examples · Error

Error with Everything Alert for React

A destructive alert with an error icon, a title, a description, and Retry and Dismiss buttons.

Framework
UI library

This is the full error alert: a CircleXIcon from Lucide, a title, a description, and Retry and Dismiss buttons, all in a destructive Alert. The icon goes first, and the alert gives it its own column so the title and description line up beside it. Use it for failures that need to stand out, such as a declined payment or a sync that stopped, where the reader needs the reason and a way to recover.

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 error alerts include icons?

When the alert has to stand out among other content, such as at the top of a page or in a dashboard. An icon helps readers sort alerts at a glance: a circled X for errors, a triangle for warnings, an i for information. Inline next to a field that's already marked invalid, it adds little.

What color is the icon?

The variant's: with variant="destructive" the icon takes the destructive color along with the text. You don't set its color or size; the alert sizes an unsized icon and colors it for every variant.

How does the icon line up with the title?

The alert places a direct svg child in a first column that spans the title and description rows, and aligns it with the title's first line. Put the icon first, before AlertTitle, and the layout does the rest.

Does the icon need aria-hidden?

Here, yes: the title already says Error, so the icon is decorative and the demo sets aria-hidden="true" on it. If the icon were the only sign of severity, give the title that word instead of exposing the icon.

Should error icons be left or right of content?

At the start of the reading direction, where the eye lands first: left in English, right in Arabic or Hebrew. The alert's icon column follows the page's direction, so you don't change anything for right-to-left. Controls such as the buttons go at the end.

Do I need a flex row for the icon and content?

No. Alert is already a grid that adds the icon column when a direct svg child is present, and AlertAction takes the buttons. Write the parts in order (icon, title, description, action) without wrapper elements.