What it is.Alert is an inline banner with six type values (neutral, info, success, warning, danger and loading) and five variant surfaces (inset, default, soft, glass, solid). It takes a title, a message, an optional action slot and a dismissible close button. AlertAction is the matching pill button.
How it is built. The type picks an animated icon (from ui-animated-icons) and a colour, and the variant picks the surface. danger and warning render with role="alert", the other types with role="status", and loading adds aria-busy with a spinning icon. Dismissing fades the alert out over 200 ms and then calls onDismiss.
When to use it. Use Alert for persistent in-page banners, form summaries and system notices that stay in the layout. For notifications that disappear on their own, use Toast or Sonner.
For AI agents
Hand your agent this brief or the Markdown page, not a screenshot.
When to use
Persistent inline callouts, validation summaries, and status banners inside page layouts or forms
Visual variants (inset, default, soft, glass, solid) matched to light, dark, or image/gradient backdrops
When not to use
Temporary floating notifications: use Sonner or Toast
Named exports Alert and AlertAction from @/components/custom/blocks/Alerts; there is no default export.
type is "neutral" | "info" | "success" | "warning" | "danger" | "loading". There is no error or destructive type: use danger.
variant="glass" applies backdrop blur and white text, so it needs an image or gradient behind it.
Dismissal is internal: the alert hides itself after the fade, and onDismiss is only a notification, not a controlled open prop.
Put AlertAction in the action slot or inside children; it takes its colour from the alert's type and variant.
For AI agents4 variants. Ask the user which one.▾
Ask before you pick. This page has 4 variants. If the user has not named one and has not asked you to choose for them, ask which they want before you install anything or write code, and show every option with its live link. If they ask you to choose, pick from each variant's best-for and avoid-if lines against their brief, and say why. If the user named a variant, use it and do not ask.
When to use it. An inline alert for messages that stay in the layout, with six types (neutral, info, success, warning, danger, loading), an action button slot and optional dismiss, in four styles: default, soft, glass and solid.
When to use something else
Toast: the message is short-lived and should float over the page instead of sitting in the layout.
Gotchas
All four are looks of the one `alert` item: install it once and set `variant` from the index.
The type picks the icon and the colour on every style; it says what the alert is about, so choose it by meaning, not by taste.
Glass uses white text and needs an image or gradient behind it; on a plain background use another style.
What the alert is about. Sets the icon and the colour.
variant
"inset" | "default" | "soft" | "glass" | "solid"
"default"
The visual style.
title
ReactNode
undefined
The bold heading.
message
ReactNode
undefined
The text under the title.
icon
ReactNode | null
The icon for the type
Replaces the icon. Pass null to hide it.
action
ReactNode
undefined
Slot on the right, usually an AlertAction.
dismissible
boolean
false
Adds a close button that fades the alert out.
onDismiss
() => void
null
Called after the fade, so you can drop the alert from your state.
children
ReactNode
undefined
Extra content under the message, such as a list.
className
string
undefined
Classes for the alert root.
titleClassName
string
undefined
Classes for the title.
messageClassName
string
undefined
Classes for the message.
iconClassName
string
undefined
Classes for the icon wrapper.
Works with other components
Pair Alert above Form or Input groups for server-side validation summaries.
Use Toast or Sonner when feedback should appear temporarily and auto-dismiss.
Embed inside Dialog to highlight destructive action warnings.
How do I show an error alert with the Alert component?
Use type="danger". Alert has no error or destructive type, so danger is the red one. It uses the theme's destructive colour on the default and soft variants, renders with role="alert" so screen readers announce it, and pairs with AlertAction for a retry button in the action slot.
When should I use variant="glass" vs variant="soft"?
Use variant="soft" on plain light or dark backgrounds: it bleeds the type colour into a pale card from the left corners. Use variant="glass" over a photo, gradient or mesh background, where its backdrop-blur-xl frosting and white text show through. On a flat background glass loses its effect.
How do I make an Alert dismissible and react to it closing?
Set dismissible to show a close button labelled "Dismiss alert". Clicking it fades the alert out over 200 ms and hides it. onDismiss then runs, so use it to drop the alert from your own state. Alert does not take an open prop to control visibility.
How do I add a button to an Alert?
Pass <AlertAction> to the action prop for a button on the right, or place it inside children for one under the message. AlertAction reads the alert's type and variant for its colours, and appearance="outline" gives a quieter second button beside a filled one.
Does Alert announce itself to screen readers?
Yes, with a role chosen from type. danger and warning use role="alert", which interrupts, while neutral, info, success and loading use role="status", which is polite. The loading type also sets aria-busy, and its spinner and entrance animation respect reduced motion.
What is the difference between Alert and Toast / Sonner?
Alert stays inline in the document flow until the person or your state removes it. Toast and Sonner render floating notifications in a viewport corner that disappear after a duration (Toast defaults to 5000 ms), so use Alert for anything that must stay readable.