Alert
A short message about the state of the page or an action. Renders a plain
div — no role, no live region — unless live asks for one.
import { Alert } from "antlitz";
API
| Prop | Type | Default |
|---|---|---|
| asChild | boolean | false |
| live | "off" | "polite" | "assertive" | off |
| radius | "none" | "sm" | "md" | "lg" | "full" | none |
| size | "sm" | "md" | "lg" | md |
| tone | "base" | "muted" | "subtle" | base |
| variant | "solid" | "soft" | "outline" | "danger" | "success" | "warning" | "info" | "plain" | soft |
live defaults to off. polite gives the alert role="status" and
assertive gives it role="alert". Each role implies its own aria-live, so
nothing else needs setting, and an explicit role takes precedence over
live.
Use polite for a message that appears after load — a save confirmation — so
a screen reader announces it without interrupting. Reserve assertive for
content the user must act on.
An alert present on first render needs no live region: it is read as part of the page.
Variants
export function Variants() {
return VARIANTS.map((variant) => (
<Alert key={variant} variant={variant}>
{variant}
</Alert>
));
}Sizes
export function Sizes() {
return (
<>
<Alert size="sm">Small</Alert>
<Alert size="md">Medium</Alert>
<Alert size="lg">Large</Alert>
</>
);
}Radius
export function Radius() {
return RADII.map((radius) => (
<Alert key={radius} variant="outline" radius={radius}>
{radius}
</Alert>
));
}Tones
export function Tones() {
return (
<>
<Alert variant="outline" tone="base">
Base
</Alert>
<Alert variant="outline" tone="muted">
Muted
</Alert>
<Alert variant="outline" tone="subtle">
Subtle
</Alert>
</>
);
}Composition
export function Composition() {
return (
<Alert variant="warning" className="w-full max-w-md gap-3">
<Icon size={16}>
<circle cx="12" cy="12" r="9" />
<path d="M12 8v4M12 16h.01" />
</Icon>
<div className="flex flex-col gap-1">
<Text as="span" weight="medium">
Payment method expiring
</Text>
<Text as="span" size="sm">
Update your card before the next billing cycle.
</Text>
</div>
</Alert>
);
}Alert is a flex row aligned to the top, and any direct svg child is set to
one line height — so an icon lines up with the first line of text rather than
centring against the whole block.