Alert
An inline notice in five tones, with one action and an optional close.
- Category
- Data & feedback
- Access
- Free with an account
- Source
- 200 lines · one file
- States
- 8 drawn
- Added
- 13 Oct 2026
When to use it
Use Alert for a message that sits in the page: neutral, info, success, warning or destructive, with a title, an action and an optional dismiss. For a passing result, use toast.
Installation
How you get it
Paste this into Claude Code, Cursor, Codex or any coding agent. It installs the file and uses it as it is, instead of writing a new one.
Use Liro's Alert for this.
Install it: npx shadcn@latest add @liro/alert
(the @liro registry is set up in components.json, with LIRO_KEY in .env.local)
Import it from @/components/ui/alert.
Do not rewrite or restyle it. Pass my data through its props
and keep its built-in states.For the full brief with every prop and the mistakes assistants usually make, use Copy prompt above. Free components install through the @liro registry with your CLI token: see the Namespaced tab.
Usage
import { Button } from "@/components/ui/button";
import { Alert } from "@/components/ui/alert";
export function BillingAlert({ update }: { update: () => void }) {
return (
<Alert
tone="warning"
title="Your card expires this month"
action={<Button size="sm" variant="outline" onClick={update}>Update card</Button>}
>
Update it before 14 Nov to keep the Team plan.
</Alert>
);
}API reference
“Copy prompt” above puts a full brief on your clipboard, install command, dependencies, props, and the mistakes an assistant usually makes with this component.
Props
Read from the component’s own TypeScript interface when the site is built, so this table cannot drift from the file you install.
| Type | Notes | ||
|---|---|---|---|
tone | AlertTone | No | What kind of notice it is. Default `info`. |
title | React.ReactNode | No | The headline, one short line. |
icon | React.ReactNode | false | No | Replace the tone's icon, or pass `false` for none. |
action | React.ReactNode | No | One action: a button or a link, shown under the text on small screens and beside it on wide ones. |
onDismiss | () => void | No | Adds a close button. Called after it is pressed. |
dismissLabel | string | No | Label for the close button. Default "Dismiss". |
open | boolean | No | Controls whether it shows. Leave it out and a dismissed alert hides itself. |
size | "sm" | "md" | No | `sm` for tight spots: inside a card, under a field. Default `md`. |
Dependencies
npm packages
clsxframer-motionlucide-reacttailwind-mergeLiro foundations, installed alongside it
liro-themeStates
All of them are drawn by the component. None is left for you to design.
- Info
- Success
- Neutral
- Warning
- Destructive
- With action
- Dismissible
- Compact
Accessibility
- Keyboard reachable throughout, in visual order
- Focus trapped in overlays, Escape closes them
- Focus returns to whatever opened it
- Live regions announce what changed, not that something did
- Honours prefers-reduced-motion
Responsive behavior
- Sizes to its container, not the viewport
- Usable from 320px up
- Pointer-based interaction, so trackpad and touch both work
- No hover-only affordances