Alert
Displays a callout for user attention.
Kobalte
The Alert component is built on top of Kobalte Alert, which provides accessible callout semantics.
Payment successful
Your payment of $29.99 has been processed. A receipt has been sent to your email address.
New feature available
We've added dark mode support. You can enable it in your account settings.
import { CheckCircle2Icon, InfoIcon } from "lucide-solid";import { Alert, AlertDescription, AlertTitle } from "~/components/ui/alert";
export default function AlertDemo() { return ( <div class="grid w-full max-w-md items-start gap-4"> <Alert> <CheckCircle2Icon /> <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> <InfoIcon /> <AlertTitle>New feature available</AlertTitle> <AlertDescription> We've added dark mode support. You can enable it in your account settings. </AlertDescription> </Alert> </div> );}Installation
Usage
import { Alert, AlertAction, AlertDescription, AlertTitle,} from "~/components/ui/alert";import { Button } from "~/components/ui/button";import InfoIcon from "lucide-solid/icons/info";<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.
Account updated successfully
Your profile information has been saved. Changes will be reflected immediately.
import { CheckCircle2Icon } from "lucide-solid";import { Alert, AlertDescription, AlertTitle } from "~/components/ui/alert";
export default function AlertBasic() { return ( <Alert class="max-w-md"> <CheckCircle2Icon /> <AlertTitle>Account updated successfully</AlertTitle> <AlertDescription> Your profile information has been saved. Changes will be reflected immediately. </AlertDescription> </Alert> );}Destructive
Use variant="destructive" to create a destructive alert.
Payment failed
Your payment could not be processed. Please check your payment method and try again.
import { AlertCircleIcon } from "lucide-solid";import { Alert, AlertDescription, AlertTitle } from "~/components/ui/alert";
export default function AlertDestructive() { return ( <Alert variant="destructive" class="max-w-md"> <AlertCircleIcon /> <AlertTitle>Payment failed</AlertTitle> <AlertDescription> Your payment could not be processed. Please check your payment method and try again. </AlertDescription> </Alert> );}Action
Use AlertAction to add a button or other action element to an alert.
Dark mode is now available
Enable it under your profile settings to get started.
import { Alert, AlertAction, AlertDescription, AlertTitle } from "~/components/ui/alert";import { Button } from "~/components/ui/button";
export default function AlertActionExample() { return ( <Alert class="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">Enable</Button> </AlertAction> </Alert> );}Custom Colors
Customize alert colors with utility classes such as bg-amber-50 dark:bg-amber-950.
Your subscription will expire in 3 days.
Renew now to avoid service interruption or upgrade to a paid plan to continue using the service.
import { AlertTriangleIcon } from "lucide-solid";import { Alert, AlertDescription, AlertTitle } from "~/components/ui/alert";
export default function AlertColors() { return ( <Alert class="max-w-md border-amber-200 bg-amber-50 text-amber-900 dark:border-amber-900 dark:bg-amber-950 dark:text-amber-50"> <AlertTriangleIcon /> <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> );}API Reference
Alert
Displays a callout for user attention.
AlertTitle
Displays the title of an alert.
AlertDescription
Displays an alert's description or content.
AlertAction
Displays an action element positioned at the alert's top right.
For all primitive props and keyboard interactions, see the Kobalte Alert API reference.