Alert
A message that stays on the page until the situation changes.
When to use it
Use Alert for information about the current page that people need to see: a failed sync, a trial ending, a form-wide error.
For a quick confirmation that can disappear, use Toast. For a decision that must be made first, use Alert Dialog.
AlertThis page
Stays on the page.
Warnings and errors about this page.
Empty
Nothing here yet.
Tip: pressโNfrom anywhere to start a document.
First runs and empty searches.
How it behaves
Default and success variants use role=status; destructive uses role=alert for urgent feedback.
Insert live feedback after an action. Keep messages specific and explain how to fix errors.
Success and destructive variants use soft status backgrounds, tinted borders, and colored icons and titles. Supporting text stays neutral; the default uses a muted surface.
Compose AlertTitle, AlertDescription, and optional AlertAction. Add a decorative icon explicitly; native div props are forwarded. AlertDescription also works without a title and stays aligned beside an icon.
Build it
Add it with the shadcn CLI:
1pnpm dlx shadcn@latest add https://jzbui.com/r/alert.jsonA complete example. Change the values to fit your product:
12345678import { CircleCheck } from "lucide-react"import { Alert, AlertTitle, AlertDescription } from "@/components/ui/alert"
<Alert variant="success"> <CircleCheck aria-hidden="true" /> <AlertTitle>Changes saved</AlertTitle> <AlertDescription>Your project is ready to share.</AlertDescription></Alert>The full source is yours to edit once installed: