Alert
The canonical inline status banner. <Alert /> is the DS's first opinionated feedback
surface — it covers info / success / warning / danger / neutral messages with
auto-icon, optional title + description + action area, and a Motion-driven dismiss.
Overview — info, success, warning, and closable danger
Why this exists
Three jobs land in this component that other status surfaces (Toast, Banner, Inline-error) will reuse:
- Icon-by-color. The leading icon is selected automatically from the active color via
the shared
_shared/iconForColorhelper. One mapping, every consumer. - Constrained color set. Alerts speak about what happened — they don't carry brand.
The 5-of-7 palette (no
primary/secondary) is the convention. - Motion-driven exit.
<AnimatePresence>makesclosableAlerts dismiss with a single height + opacity tween. Surrounding layout reflows for free.
Anatomy
┌──────────────────────────────────────────────────────────┐
│ [icon] <Title> [× close button] │
│ <Description> │
│ <Action> [button] [button] │
└──────────────────────────────────────────────────────────┘┌──────────────────────────────────────────────────────────┐
│ [icon] <Title> [× close button] │
│ <Description> │
│ <Action> [button] [button] │
└──────────────────────────────────────────────────────────┘<Alert.Title> / <Alert.Description> / <Alert.Action> are subparts — use only the
ones you need. A bare <Alert>Saved.</Alert> is just as valid.
Variants
| Variant | Background | Border | When to reach for it |
|---|---|---|---|
solid | full color | none | Critical announcements, system-level alerts. |
outline | paper | colored border | Brand-light contexts, paired with Card. |
soft | subtle tint | low-contrast colored border | Default. Toast/banner-style notifications. |
inline | transparent | logical-start 4px colored bar | Inline form validation, minimal chrome. |
Colors
info (default) · success · warning · danger · neutral
Brand colors (primary, secondary) are intentionally excluded — they don't carry status
meaning. Add them via a theme override if your product needs them.
Examples
Default — info color, soft variant
All four variants
Three sizes (sm / md / lg)
Every variant × every color
With title + description
With action button row
Closable + Motion exit
Custom leading icon
Hide icon (chrome-less)
Controlled — parent owns open state
Inline variant under a form field
Stacked / dismissable list
Props
| Prop | Type | Default | Notes |
|---|---|---|---|
variant | 'solid' | 'outline' | 'soft' | 'inline' | 'soft' | Responsive via the { base, md } shape. |
color | 'info' | 'success' | 'warning' | 'danger' | 'neutral' | 'info' | Drives the auto-icon and the auto-role. |
size | 'sm' | 'md' | 'lg' | 'md' | Padding + icon size + font scale. |
icon | ReactNode | — | Overrides the auto-selected leading icon. |
hideIcon | boolean | false | Hides the leading icon slot entirely. |
closable | boolean | false | Renders a × button on the trailing edge. |
onClose | () => void | — | Fired when the alert dismisses (close button or controlled open flip). |
open | boolean | — | Controlled visibility. Pair with onClose. |
defaultOpen | boolean | true | Initial visibility for the uncontrolled flow. |
role | 'status' | 'alert' | auto | Auto-selects per color. Override only when intentional. |
className | string | — | Merged via tailwind-merge. Last-wins. |
sx | Sx | — | Theme-aware inline style. |
Accessibility
- Auto live-region role.
info/success/neutral→role="status"(polite live region).warning/danger→role="alert"(assertive). Override only when you know. - Decorative icon. The leading icon is wrapped in an
aria-hidden="true"span — the body text + role carry the meaning for screen readers. - Close button has a name. Always reads as "Dismiss" via
aria-label. - Heading level is left to you.
Alert.Titleis a plain<div>. Wrap in<h3>/<h4>when the page outline demands a real heading.
Theming
defineTheme({
components: {
Alert: {
defaultProps: { variant: 'outline', size: 'sm' },
styleOverrides: {
root: 'rounded-xl',
title: 'tracking-tight',
description: 'leading-snug',
action: 'mt-3',
},
},
},
});defineTheme({
components: {
Alert: {
defaultProps: { variant: 'outline', size: 'sm' },
styleOverrides: {
root: 'rounded-xl',
title: 'tracking-tight',
description: 'leading-snug',
action: 'mt-3',
},
},
},
});Alert is consumed by the renderer's Theme Studio for live preview.