Components
Alert
Displays a callout for user attention. Use it for inline, persistent messages — not for transient toasts or blocking dialogs.
Preview
Success! Your changes have been saved.
Rendered with live Cognition tokens — surface, border, and every variant color remap on theme change, no dark: classes.
Variants
Heads up
<Alert>
<CircleAlert />
<AlertTitle>Changes saved</AlertTitle>
<AlertDescription>Your edits are live.</AlertDescription>
</Alert>Something went wrong!
<Alert variant="destructive">
<CircleAlert />
<AlertTitle>Something went wrong</AlertTitle>
<AlertDescription>Your session has expired.</AlertDescription>
</Alert>Your subscription will expire in 3 days.
<Alert variant="warning">
<TriangleAlert />
<AlertTitle>Subscription expiring</AlertTitle>
<AlertDescription>Renew within 3 days.</AlertDescription>
</Alert>destructive recolors the title, description, and icon to the danger token; warning tints the surface amber — both via tokens, so dark mode is automatic.
Composition
Title only
AlertTitle and AlertDescription are both optional — drop the icon, the title, or both. With no icon the text fills the full width.
API
Don't and Do
Don't color the destructive alert with border-destructive dark:border-destructive — the legacy alert.tsx does exactly this. Hardcoded dark: classes drift the moment the brand changes.
// One variant prop, token-driven, theme-agnostic
<Alert variant="destructive">…</Alert>import { Alert, AlertTitle, AlertDescription } from "@/components/ui/alert";
import { CircleAlert } from "lucide-react";
export function SavedAlert() {
return (
<Alert>
<CircleAlert />
<AlertTitle>Changes saved</AlertTitle>
<AlertDescription>Your edits are live.</AlertDescription>
</Alert>
);
}Drop the icon in as the first child — the [&>svg] rules position it and pad the text. Cognition tokens are baked in.