Search documentation
Search pages, components, blocks, styles and colours.
Displays a callout for user attention.
Installation
Usage
import {
Alert,
AlertAction,
AlertDescription,
AlertTitle,
} from "@/components/ui/alert"<Alert>
<InfoIcon />
<AlertTitle>Heads up!</AlertTitle>
<AlertDescription>
You can add components and dependencies to your app using the cli.
</AlertDescription>
<AlertAction>
<Button variant="outline">Enable</Button>
</AlertAction>
</Alert>Composition
Use the following composition to build an Alert:
Alert
├── Icon
├── AlertTitle
├── AlertDescription
└── AlertActionBasic
A basic alert with an icon, title and description.
Status
Use variant="info", "success", "warning" or "error" for a status alert. With the default contrast="low", the alert keeps the neutral panel and only the icon takes the status colour. Use contrast="high" to wash the whole alert in the status surface. Every status colour is checked for WCAG AA contrast in light and dark; see Surfaces.
low contrast
high contrast
Destructive
Use variant="destructive" to create a destructive alert.
Action
Use AlertAction to add a button or other action element to the alert.
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.
API Reference
Alert
The Alert component displays a callout for user attention.
AlertTitle
The AlertTitle component displays the title of the alert.
AlertDescription
The AlertDescription component displays the description or content of the alert.
AlertAction
The AlertAction component displays an action element (like a button) positioned absolutely in the top-right corner of the alert.