Alert
An inline message about the page or a section of it, in one of five tones.
Preview
Installation
pnpm add @syntara/react @syntara/tokensimport { Alert } from '@syntara/react';Usage
import { Alert } from '@syntara/react';
export function CardNotice() {
return (
<Alert tone="warning" title="Card expiring">
Your card ending 4821 expires next month. Order a replacement.
</Alert>
);
}Examples
Tones
Neutral, info, success, warning and danger. Each tone has its own filled shape, so colour is never the only signal.
Actions, dismiss and live
Action weight by severity (contrast on a danger alert, outline on a success one), a dismissible alert, and a live alert with no icon and a link action.
Accessibility
| Keys | Action |
|---|---|
| Tab | Moves to the action and the close button, in reading order. |
| EnterorSpace | Activates the focused close button or action. |
- No live role by default, so alerts rendered with the page are not re-announced. Set `live` for alerts that appear after a user action (e.g. a failed submit).
- With `live`, the alert is named by its title (aria-labelledby).
- The close button is a 24×24px target (WCAG 2.5.8) and has an accessible name.
- Each tone has its own filled shape and a text title, so colour is never the only signal. The shape is feedback.<tone>.fg: ≥ 6.09:1 against the surface, including the sheen's brightest pixel (WCAG 1.4.11 needs 3:1). The knocked-out glyph is feedback.<tone>.bg: ≥ 5.43:1 against the shape. Both hold for every tenant and the 1,000 fuzz brands in both schemes, and test/alert.test.tsx re-proves them.
- Surface recipe: an opaque surface.raised face, --syntara-sheen in dark, a neutral hairline and the raised shadow. Only text.default and text.subtle sit on it.
Guidelines
Do
- Lead with what happened, then what to do next.
- Use danger for problems that block the task; warning for things that will become problems.
- Keep the action to one short verb phrase.
- Give danger and warning alerts a `contrast` action and the others an `outline` one, so the strongest button on the page is the one that fixes something.
Don’t
- Don't use an alert for transient confirmations — use a toast.
- Don't set `live` on alerts that are present when the page loads.
- Don't stack several alerts of the same tone; combine them.
API reference
Alert
toneneutraldefaultinfosuccesswarningdanger
Sets the filled status shape and its colour. The surface is the same for every tone.
titleReactNodeShort summary shown in semibold above the body.
childrenReactNodeThe message body, in text.subtle. Links inside are underlined.
iconReactNode | falseReplaces the filled status shape; it takes the tone colour (feedback.<tone>.fg). `false` shows no icon.
actionReactNodeOne small Button or a link. It sits at the inline end and wraps under the text when the alert is narrow. Match its weight to the tone: `<Button size="sm" variant="contrast">` for danger and warning, `variant="outline"` otherwise.
onDismiss() => voidShows a close button that calls this. You remove the alert.
dismissLabelstringAccessible name of the close button.
Default
'Dismiss'liveboolean | 'assertive' | 'polite'Announce the alert when it appears: `true`/'assertive' → role="alert", 'polite' → role="status". Leave unset for alerts present on page load.
Tokens
The semantic tokens this component reads, grouped by what they control. Swatches show this site’s theme; change a tenant’s brand and the component follows with no code change.
- Colour7
feedback.*.bgfeedback.*.fgfocus.ringsurface.raisedtext.defaulttext.subtleborder.subtle- Type9
font.bodyfont.size.mdfont.size.smfont.weight.semiboldline-height.normalline-height.snugfont.tracking.mdfont.tracking.smfont.weight.medium- Space and size7
space.3space.4space.6space.16card-insetspace.1space.2- Shape3
radius.containerradius.buttonradius.badge- Depth2
shadow.raisedhairline- Motion4
motion.duration.fastmotion.duration.springmotion.easingmotion.spring- Other2
sheenrim