Alert
An inline status banner for page-level messages, validation summaries, and contextual feedback. Five semantic variants, optional icon, actions, and a dismiss button.
Deployment successful
Your application has been deployed to production.
Installation#
Usage#
import {
Alert,
AlertIcon,
AlertContent,
AlertTitle,
AlertDescription,
AlertActions,
} from "@/components/ui/alert"
export function Example() {
return (
<Alert variant="info">
<AlertIcon />
<AlertContent>
<AlertTitle>Heads up</AlertTitle>
<AlertDescription>This action cannot be undone.</AlertDescription>
</AlertContent>
</Alert>
)
}Variants#
Five semantic variants. Each keeps a neutral surface (border-border on bg-background) and only recolors the leading icon from a single semantic token (--success, --warning, etc.), so the status reads at a glance and re-themes across all four Koala themes automatically.
Default
A neutral, non-semantic message.
Info
Informational context for the user.
Success
The operation completed successfully.
Warning
Review before proceeding.
Error
Something went wrong. Please try again.
Sizes#
Small alert
Compact size for dense UIs.
Medium alert
Default size for most contexts.
With icon#
AlertIcon auto-selects the matching Koala icon for the current variant when no children are given. Pass children to use a custom icon instead.
Auto icon from variant
No icon
Omit AlertIcon entirely to go icon-free.
With actions#
Use AlertActions inside AlertContent to add a row of action buttons below the description.
Unsaved changes
You have unsaved changes that will be lost if you leave.
Dismissible#
Pass onDismiss to render a close button. The component is uncontrolled - the consumer manages visibility. Use dismissLabel to provide a screen-reader accessible label (defaults to "Dismiss").
Deployment successful
Your application is live on production.
New update available
Version 2.4.0 introduces improved performance.
Storage almost full
You have used 90% of your allocated storage.
Payment failed
Your card was declined. Please update your details.
API reference#
Alert
The root, a <div role="alert"> that sets the tone for every part. Forwards all native <div> props. Every part accepts className, merged last.
| Prop | Type | Default | Description |
|---|---|---|---|
| variant | "default" | "info" | "success" | "warning" | "destructive" | "default" | The semantic tone: the icon color and the icon AlertIcon picks on its own. |
| size | "sm" | "md" | "md" | Padding, gap, type and icon size. |
| onDismiss | () => void | - | Renders a close button that calls it. You own the visibility state. |
| dismissLabel | string | "Dismiss" | The accessible label of the close button. |
| CSS variable | Description |
|---|---|
| --surface | Read as the fill, falling back to --background, so the alert takes the ground it sits on. |
AlertIcon
The leading icon column, a sibling of AlertContent. Left empty, it draws the icon of the variant; pass children for a custom one. Forwards all native <div> props.
AlertContent
The text column holding the title, description and actions. Forwards all native <div> props.
AlertTitle
The heading line, a <p>. Forwards all native <p> props.
AlertDescription
The body text, a <p>. Forwards all native <p> props.
AlertActions
A button row, last inside AlertContent. Sizes every control inside it through the control-size context. Forwards all native <div> props.
| Prop | Type | Default | Description |
|---|---|---|---|
| size | "sm" | "md" | "lg" | "sm" | The size the nested buttons take. |
| Data attribute | Description |
|---|---|
| data-control-size | The size the row hands its controls. |
Anatomy#
import {
Alert,
AlertIcon,
AlertContent,
AlertTitle,
AlertDescription,
AlertActions,
} from "@/components/ui/alert"
<Alert>
<AlertIcon />
<AlertContent>
<AlertTitle />
<AlertDescription />
<AlertActions />
</AlertContent>
</Alert>