Alert
A status banner component built on a variant by tone matrix (soft or outline, across six semantic tones) with an optional leading icon, AlertTitle, and AlertDescription. It renders a div with role="alert" to announce messages to assistive technology.


Installed with shadcn add · 2 workarounds · theme from registry.json
- applied the registry's theme (tokens, fonts and CSS from the registry preview settings)
- installed base item https://ai2.design/r/tokens.json (registry preview settings)
Installation
Requires @ai2 in the registries of your components.json (shadcn adds official directory namespaces automatically).
Usage
import { Alert, AlertTitle, AlertDescription } from "@/components/ui/alert"export function Example() { return ( <Alert tone="info"> <AlertTitle>Heads up</AlertTitle> <AlertDescription>Your changes are saved locally.</AlertDescription> </Alert> )}- Showing inline feedback such as success, warning, error, or informational messages inside a page or form.
- Surfacing a status that should be announced immediately to screen readers, since the root has role="alert".
- Pairing a semantic tone with an icon and a short title plus description for scannable notices.
- Choosing the soft variant for a filled notice or the outline variant for a lighter, bordered notice.
Examples
Soft success alert with icon
A soft brand-free success notice with a leading lucide icon. The icon is tinted by the success tone and the grid indents the title automatically.
import { CircleCheck } from "lucide-react"import { Alert, AlertTitle, AlertDescription } from "@/components/ui/alert"export function SavedAlert() { return ( <Alert tone="success"> <CircleCheck /> <AlertTitle>Saved</AlertTitle> <AlertDescription>Your profile has been updated.</AlertDescription> </Alert> )}Outline danger alert
An outline variant with a danger tone for a form error. The border is danger/30 and the icon is tinted danger.
import { CircleAlert } from "lucide-react"import { Alert, AlertTitle, AlertDescription } from "@/components/ui/alert"export function ErrorAlert() { return ( <Alert variant="outline" tone="danger"> <CircleAlert /> <AlertTitle>Payment failed</AlertTitle> <AlertDescription>Check your card details and try again.</AlertDescription> </Alert> )}Neutral alert without icon
A default soft neutral alert with only a title and description. Without an icon, the grid column is collapsed.
import { Alert, AlertTitle, AlertDescription } from "@/components/ui/alert"export function NoteAlert() { return ( <Alert> <AlertTitle>Maintenance window</AlertTitle> <AlertDescription>Service may be briefly unavailable on Sunday.</AlertDescription> </Alert> )}API reference
Accessibility
- The root has role="alert", so screen readers announce its content when it is inserted or changed. Use it for important, time-sensitive messages only, and avoid placing many alerts on one page.
- AlertTitle and AlertDescription are plain divs, so the title is not a heading element. Add a heading role or a semantic element via the as-style pattern if document outline matters.
- Tone is conveyed by color and icon, so include descriptive text in the title or description and do not rely on color alone.
- Decorative icons should be marked aria-hidden="true" when the title already conveys the same meaning.
- If the alert is dismissible or appears dynamically, ensure focus management and keyboard access for any action buttons placed inside it.
Docs written by anthropic:claude-haiku-5-5 from the registry source.
Use with Coding Agent
Paste this into Claude Code, Codex or Cursor. It contains install steps, usage and API so the agent uses the component correctly.
Use the "Alert" component (ai2/alert) from its shadcn registry.1. Install it with: npx shadcn@latest add @ai2/alert2. Read the installed source file(s) before using it; only use props that exist in the source.3. Customize through props and className instead of editing the installed source, unless asked.4. Available props: variant, tone, className, ...props.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { Alert, AlertTitle, AlertDescription } from "@/components/ui/alert"export function Example() { return ( <Alert tone="info"> <AlertTitle>Heads up</AlertTitle> <AlertDescription>Your changes are saved locally.</AlertDescription> </Alert> )}```Files & dependencies
- registry/ai2/ui/alert.tsx