Pro

Alert

Inline banner for info, success, warning and error. It reserves its space up front or opens on a press, so a late status never pushes the page.

Invitations go out from hosts@example.com

Replies land in the same inbox. Change the sender

Two guests haven’t replied

Priya and Tom were invited on October 12. Seating closes Thursday.

Menu shared with 8 guests

They can leave allergy notes until Friday.

Arrives later, space held

Saturday supper, 8 guests. The menu is due Thursday.

Answers a press, opens its height

Next: the harvest dinner on November 21.

Installation

With UI Polish connected, ask your agent:

Add the UI Polish alert to this project.

Or with the shadcn CLI:

npx shadcn@latest add https://uipolish.com/r/alert.json
Brings inField, Icons

An inline banner with a status: info, success, warning or error. A title, a sentence of detail, optional actions and an optional dismiss button.

TSX
<Alert tone="warning" title="Two guests haven’t replied" actions={<Button variant="secondary">Send a reminder</Button>}>  Seating closes Thursday.</Alert>

The rule for alerts that arrive later

An alert in the page from the first paint is part of the layout. One that arrives later (a save failing, a connection dropping) must not push the page while someone is reading it. Pass open and pick how it makes room:

arriveUse it whenWhat happens
reserve (default)The status can arrive without the user doing anythingIts space is held from the first paint by an invisible copy, and it fades in there. Nothing moves, ever
expandIt answers the user's own click or key pressIt opens its height on --ui-ease-expand. The browser doesn't count movement within 500ms of input as layout shift

If neither fits (there's no room to reserve and nothing the user did), use a toast: it overlays instead of taking space. Dismissing always collapses the alert: that answers a press, so it's allowed to move things.

When not to

  • Field errors: the field's own message line.
  • Confirmation of something the user can already see changed.

Props

PropWhat it does
toneinfo (default), success, warning, error
title, children, actionsOne line, a sentence or two, buttons or links
open, arriveSee the rule above. Leave open out for a static alert
onDismiss, dismissLabelShows the dismiss button; called after it has closed

Look and motion

The status color tints the surface 6% with a hairline edge of it, and colors the mark (--ui-success, --ui-warning, --ui-danger; info uses the text color); title and text stay in the text colors so contrast holds in every tone. Info is neutral. The mark sits centered in a square the height of the title's line; the dismiss button is centered on that line too, inset the same from top and end, with the alert's radius less the inset. Both marks end up the same distance from every edge they're near. Nested in a rounded container, set --alert-radius to the container's radius less its inset and --alert-pad to match its padding, so the corners stay concentric and the text lines up.

Arriving: fade and a 2px drop, --ui-dur-fast on --ui-ease-enter. Leaving: a step faster on the color curve. Under prefers-reduced-motion it appears and collapses at once.

Accessibility

An alert that can arrive later lives in a live region that's always in the DOM: role="alert" for errors and warnings, role="status" otherwise, so it's announced when it opens, and again each time it reopens. A static alert isn't announced. Each opening remounts the content, so a repeated failure is announced again.