Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Alert examples · Error

Error with Title, Description and Action Alert for React

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

Framework
UI library

When an error needs both context and a way out, combine them. This React alert stacks an AlertTitle and an AlertDescription in a destructive Alert and adds Retry and Dismiss in AlertAction, so the reader learns what failed, why, and what to do in one place. Use it for failed requests or payments where the reader can try again.

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 fully-featured error alerts?

When the reader needs an explanation and can recover from the alert itself, such as a request that failed but can be retried. For a failure with nothing to click, drop the buttons; for one that needs no explanation, drop the description.

How are the title, description and buttons laid out?

Alert is a grid: AlertTitle and AlertDescription stack in it with a small gap, and AlertAction is positioned at the end of the first row while the alert pads its end side to leave room. You don't need wrapper elements or flex classes; the parts do the layout.

Why are the two buttons wrapped in one AlertAction?

AlertAction is the alert's single action slot, so both buttons go inside it, with flex gap-2 to space them. Two separate AlertAction parts would sit on top of each other.

Should long error descriptions truncate or wrap?

Wrap. A truncated error message can hide the one part the reader needs. AlertDescription wraps onto as many lines as it needs; keep it to a sentence or two so the alert stays short.

How should this layout adapt on mobile?

It needs no breakpoints: the buttons stay at the end of the title row and the description wraps under them. Keep the title short so it fits beside the two buttons on a narrow screen.

Can I show multiple error alerts at once?

You can stack them with a gap, but several at once is hard to act on. Prefer one alert that summarizes the failures, and mark individual form fields with their own error messages, as in Field.