Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Alert examples · Warning

Warning with Everything Alert for React

A warning alert with a warning icon, a title, a description, and Proceed and Cancel buttons.

Framework
UI library

This is the full warning alert: a TriangleAlertIcon from Lucide, a title, a description of the risk, and Proceed and Cancel buttons in an Alert with variant="warning". The icon goes first and the alert gives it its own column in the warning color. Use it for consequential actions, such as an operation that can't be undone, where the reader needs to notice, understand and decide.

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

What is in this warning alert?

TriangleAlertIcon first, then AlertTitle, AlertDescription, and Proceed plus Cancel in AlertAction. The root is variant="warning" with className="max-w-lg".

What color is the TriangleAlert icon?

The theme's --warning color, set by variant="warning" on the alert. You don't add color or size classes to the icon; the alert handles both, and the text keeps its regular colors.

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, and aligns it with the title's first line.

Why is the icon aria-hidden?

The title already says Warning, so the icon is decorative. The demo sets aria-hidden="true" on TriangleAlertIcon.

Which button variants does the demo use?

Proceed is the default Button and Cancel is variant="outline". Both are size="xs" in one AlertAction with className="flex gap-2". Neither has a click handler.

What does the description say?

"This action may have unintended consequences and cannot be undone." It is an AlertDescription in the muted color. The warning tint is on the background, the border, and the icon.