A callout for a message the user should notice: a saved form, a failed payment, a planned outage. Default and destructive variants; the icon is a slot, an <svg> as the first child or any node in icon. Server component, no JavaScript.
Preview
Installation
Usage
import { CircleCheck } from "lucide-react"
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"
export default function Example() {
return (
<Alert>
<CircleCheck />
<AlertTitle>Changes saved</AlertTitle>
<AlertDescription>Your profile is up to date.</AlertDescription>
</Alert>
)
}Examples
Destructive
For errors and actions that failed.
<Alert variant="destructive">
<TriangleAlert />
<AlertTitle>Payment failed</AlertTitle>
<AlertDescription>Your card was declined.</AlertDescription>
</Alert>Without an icon
Without an icon the text takes the full width.
<Alert role="note">
<AlertTitle>Planned maintenance</AlertTitle>
<AlertDescription>…</AlertDescription>
</Alert>Icon prop and role
icon puts any node in the icon column. Alert has role="alert", which screen readers announce at once; for calm, static messages pass role="status" or role="note".
<Alert role="note" icon={<Info className="text-primary" />}>
<AlertTitle>Tip</AlertTitle>
<AlertDescription>…</AlertDescription>
</Alert>Props
| Prop | Type | Default | Description |
|---|---|---|---|
| variant | "default" | "destructive" | "default" | Visual style |
| icon | React.ReactNode | - | Icon in the first column. An <svg> child works the same way |
| role | string | "alert" | role="alert" by default; "status" or "note" for messages that should not interrupt |
| className | string | - | Additional CSS classes |