Alert
Inline messages for info, success, warning and errors.
Built on Icons.
Installation
npx shadcn@latest add https://neonkit.heyaadi.com/r/alert.jsonUsage
import { Alert, AlertTitle, AlertDescription } from "@/components/ui/alert"
<Alert status="success">
<AlertTitle>Deployment ready</AlertTitle>
<AlertDescription>acme-web is live on acme.dev.</AlertDescription>
</Alert>Examples
Action and dismiss
The action inherits the alert's color, so a Button in it matches without props.
Variants
Custom color and icon
color overrides the status color. icon={false} hides the icon.
API reference
Alert
Also accepts every native div attribute.
| Prop | Type | Default |
|---|---|---|
status | "info"Sets the default color and icon, and how urgently a live alert is announced. | "info" |
live | "assertive"assertive renders role="alert", polite role="status", off no live region. Auto keeps alerts that were on the page at load quiet, and announces ones added later: assertive for warning and error, polite for the rest. | auto |
variant | "soft"Visual style. | "soft" |
color | NeonColorPalette name or hex. Overrides the status color. | from status |
icon | ReactNodeReplaces the icon, or hides it with false. | status icon |
action | ReactNodeRight-aligned slot, usually a small Button. | None |
onDismiss | () => voidShows a dismiss button that calls this. Removing the alert is up to you. | None |
AlertTitle
A div with the title style. Accepts every native div attribute.
| Prop | Type | Default |
|---|
AlertDescription
A div with the muted body style. Accepts every native div attribute.
| Prop | Type | Default |
|---|
Accessibility
- An alert rendered with the page is a callout, not news, so it gets no live role and nothing is read out on load.
- An alert added after load (a failed save, a lost connection) is announced: warning and error interrupt with role="alert", the others wait with role="status".
- Set live yourself when the default guesses wrong, for example live="off" on a client-rendered page's permanent banner.
- The dismiss button is a native button labelled "Dismiss", reachable with Tab.