Alert
alertAn inline message in four states, with a matching icon, an optional title and room for an action. The dismiss control collapses the message out of the flow so what follows closes the gap, and only the destructive state interrupts a screen reader.
"use client";
import { useState } from "react";
import { Button } from "@/components/forme/button/button";
import { Alert } from "@/components/forme/alert/alert";
export function AlertDemo() {
const [banner, setBanner] = useState(true);
const [upgraded, setUpgraded] = useState(false);
return (
<div className="flex w-full max-w-xl flex-col gap-3">
<Alert title="A new version of the registry is available">
Run the install command again to pull the latest source into your project.
</Alert>
<Alert variant="success" title="Domain verified">
forme.dev is live. Certificates renew automatically.
</Alert>
<Alert
variant="warning"
title="You are at 92% of your seat limit"
action={
<Button size="small" variant="secondary">
Add seats
</Button>
}
>
New invitations will queue once the workspace is full.
</Alert>
<Alert variant="destructive" title="Payment failed">
The card ending 4242 was declined. Update it to keep your plan.
</Alert>
{/* A message the reader can put away. The gap closes as it leaves. */}
{banner ? null : (
<Button size="small" variant="secondary" onClick={() => setBanner(true)}>
Show the banner again
</Button>
)}
<Alert
variant="info"
dismissible
open={banner}
onOpenChange={setBanner}
title="Two-factor authentication is now available"
action={
<Button size="small" onClick={() => setUpgraded(true)}>
{upgraded ? "Enabled" : "Turn on"}
</Button>
}
>
Protect your account with a code from your phone.
</Alert>
</div>
);
}Install
Adds the component, its registry dependencies, and the token stylesheet you import once.
Usage
import { Alert } from "@/components/forme/alert/alert";
<Alert variant="warning" title="You are at 92% of your seat limit">
New invitations will queue once the workspace is full.
</Alert>When to use
Reach for it
- A message about the page or a section of it: a failed load, a limit approaching, a confirmation the reader should see next to the thing it concerns.
dismissiblewhen the reader can act on the message and it should then stay gone; the close button is the acknowledgement.actionfor the one thing to do about it — add seats, retry, update the card.
Use something else
- Something the page will show again on reload; a dismiss that does not persist trains people to ignore it. Leave
dismissibleoff. - A message that interrupts the whole task; that is a
Dialog. - A one-off confirmation of an action just taken; that is a
Toast, which does not occupy the page.
API reference
Read from the source, so it is the API of the file you install. A prop marked * is required.
Alert
An inline message about the page or a part of it.
| Prop | Type | Default | Description |
|---|---|---|---|
variant | 'info' | 'success' | 'warning' | 'destructive' | "info" | |
title | ReactNode | — | |
icon | ReactNode | — | An icon element. Defaults to a glyph that matches the variant. |
action | ReactNode | — | Buttons or links, placed on the right on wide screens and below on narrow ones. |
dismissible | boolean | false | Renders a dismiss control. The alert animates out, then unmounts. |
open | boolean | — | Controlled visibility. Pair with onOpenChange. |
defaultOpen | boolean | true | Whether it starts visible when uncontrolled. |
onOpenChange | (open: boolean) => void | — | Called when the dismiss control is pressed, or when open is controlled and asked to change. |
returnFocusRef | React.RefObject<HTMLElement | null> | — | Focus this when dismissing hides the focused control; defaults to nothing moving. |
Also takes every prop of <div> attributes.
Accessibility
- Only
destructiveusesrole="alert", which interrupts a screen reader; the rest arerole="status"and wait their turn. - The close button has an accessible name and, on dismissing, moves focus to
returnFocusRefwhen it would otherwise land on the body. - The icon is decorative and hidden, so the message is not announced twice.
Motion
- The entrance and exit are skipped on first render, so an alert present at page load does not animate in.
- Dismissing collapses height and fades together, so the content below slides up rather than jumping.
- Reduced motion drops the height change and keeps a short fade.
Responsive behaviour
- The action sits beside the message on wide screens and below it on narrow ones, aligned with the text rather than the icon.
Related


Empty State
What a list, table or page shows before it has anything in it: a stacked icon, a title, one sentence and the next action. So an empty screen reads as a start rather than an error.
feedback

Loader
Eight loading indicators — ring, dots, bars, a dot-grid wave and orbit, a terminal braille spinner, a figure-eight comet and sparkles. Pure CSS in a server component, sized in em and coloured by currentColor, with a still frame under reduced motion.
feedback

Progress
A determinate progress bar with its label and value, both announced to a screen reader by the Base UI parts rather than by hand-written aria attributes. A null value renders as indeterminate and dims the track so it reads as waiting.
feedback