Search every page in the navigation.
Displays a callout for user attention.
import { IconCircleCheck, IconInfoCircle } from "@tabler/icons-react"
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"
export default function AlertDemo() {
return (
<div className="grid w-full max-w-md items-start gap-4">
<Alert>
<IconCircleCheck />
<AlertTitle>Payment successful</AlertTitle>
<AlertDescription>
Your payment of $29.99 has been processed. A receipt has been sent to
your email address.
</AlertDescription>
</Alert>
<Alert>
<IconInfoCircle />
<AlertTitle>New feature available</AlertTitle>
<AlertDescription>
We've added dark mode support. You can enable it in your account
settings.
</AlertDescription>
</Alert>
</div>
)
}npx shadcn@latest add @ziiz/alertimport {
Alert,
AlertAction,
AlertDescription,
AlertTitle,
} from "@/components/ui/alert"<Alert>
<IconInfoCircle />
<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>Use the following composition to build an Alert:
Alert
โโโ Icon
โโโ AlertTitle
โโโ AlertDescription
โโโ AlertActionA basic alert with an icon, title and description.
import { IconCircleCheck } from "@tabler/icons-react"
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"
export default function AlertBasic() {
return (
<Alert className="max-w-md">
<IconCircleCheck />
<AlertTitle>Account updated successfully</AlertTitle>
<AlertDescription>
Your profile information has been saved. Changes will be reflected
immediately.
</AlertDescription>
</Alert>
)
}Use variant="destructive" to create a destructive alert.
import { IconAlertCircle } from "@tabler/icons-react"
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"
export default function AlertDestructive() {
return (
<Alert variant="destructive" className="max-w-md">
<IconAlertCircle />
<AlertTitle>Payment failed</AlertTitle>
<AlertDescription>
Your payment could not be processed. Please check your payment method
and try again.
</AlertDescription>
</Alert>
)
}Use AlertAction to add a button or other action element to the alert.
import {
Alert,
AlertAction,
AlertDescription,
AlertTitle,
} from "@/components/ui/alert"
import { Button } from "@/components/ui/button"
export default function AlertActionExample() {
return (
<Alert className="max-w-md">
<AlertTitle>Dark mode is now available</AlertTitle>
<AlertDescription>
Enable it under your profile settings to get started.
</AlertDescription>
<AlertAction>
<Button size="xs" variant="default">
Enable
</Button>
</AlertAction>
</Alert>
)
}You can customize the alert colors by adding custom classes such as bg-amber-50 dark:bg-amber-950 to the Alert component.
import { IconAlertTriangle } from "@tabler/icons-react"
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"
export default function AlertColors() {
return (
<Alert className="max-w-md border-amber-400 bg-amber-100 text-amber-900">
<IconAlertTriangle />
<AlertTitle>Your subscription will expire in 3 days.</AlertTitle>
<AlertDescription>
Renew now to avoid service interruption or upgrade to a paid plan to
continue using the service.
</AlertDescription>
</Alert>
)
}The Alert component displays a callout for user attention.
| Prop | Type | Default |
|---|---|---|
variant | "default" | "destructive" | "default" |
The AlertTitle component displays the title of the alert.
| Prop | Type | Default |
|---|---|---|
className | string | - |
The AlertDescription component displays the description or content of the alert.
| Prop | Type | Default |
|---|---|---|
className | string | - |
The AlertAction component displays an action element (like a button) positioned absolutely in the top-right corner of the alert.
| Prop | Type | Default |
|---|---|---|
className | string | - |