Alert

Inline message for status, warnings, or callouts. Two visual variants and slots for an icon, title, and description.

Demo

Alerts with an icon, title and description.

Dark previewReplay previewOpen in new tab

Usage

Import the parts you need from the component's folder.

ts
import {
  Alert,
  AlertTitle,
  AlertDescription,
  AlertAction,
} from "@/components/ui/alert";

Basic

A basic alert with an icon, title and description.

Dark previewReplay previewOpen in new tab

Destructive

Use variant="destructive" to create a destructive alert.

Dark previewReplay previewOpen in new tab

Action

Use AlertAction to add a button or other action element to the alert.

Dark previewReplay previewOpen in new tab

Custom Colors

You can customize the alert colors by adding custom classes such as bg-amber-50 dark:bg-amber-950 to the Alert component.

Dark previewReplay previewOpen in new tab

RTL

Alert follows the document direction; text, icon, and action flip together.

Dark previewReplay previewOpen in new tab

API Reference

Alert

PropTypeDefaultDescription
variant"default" | "destructive""default"Visual tone.
classstring—Extra classes, merged with cn().

AlertTitle / AlertDescription

PropTypeDefaultDescription
classstring—Override typography or spacing.

AlertAction

PropTypeDefaultDescription
classstring—Extra classes. Pins its content to the alert's top-right; the alert reserves trailing space automatically.