Alert
ProA message that stays until it's resolved: a form's error, a page's warning, a system notice. Error, info, success, warning and neutral, tonal or outlined. Not an M3 component (@windmorph/react-pro).
import { Alert } from '@windmorph/react-pro';Part of Windmorph Pro, paid components on the free core, not on sale yet. See the Pro guide for what it includes and to register interest.
Keyboard
| Key | Action |
|---|---|
| Tab | Moves through the actions and the close button, in order. The alert itself is not a Tab stop. |
| Enter or Space | Presses the focused action, or the close button. |
Escape does not close it: an alert stays until it is resolved or closed.
Screen reader
- Role
alertfor theerrorseverity, read at once;statusfor the others (info, the default,success,warning,neutral), read politely.- Accessible name
- None of its own: its title and message are read as its content.
- States announced
- None.
- The severity icon is decorative and hidden from assistive tech, so the words must say what kind of message it is.
- The close button is an
IconButtonnamed bylabels.close("Close"). - The live region goes into the page a moment (100ms) before its content, so screen readers announce an alert that mounts with its message. One in the server's HTML shows at once.
Focus
- The actions and the close button sit in the Tab order after the message.
- With
autoFocus, focus moves to the alert itself once, when it first appears (tabIndex={-1}), and it scrolls into view no further than needed, so the next Tab continues from there. From the keyboard it shows the M3 focus indicator while it holds focus. - Closing it never drops focus to the page: before
onCloseruns, focus goes back to where it was beforeautoFocus, or on to the next control.
Touch target
The close button is a small (40px) IconButton with an invisible 48 × 48px touch target, kept at density 0 so it never shrinks. Actions keep their own Button targets.
Motion
- It fades in on the default effects spring as it appears, under reduced motion too: a fade is not movement.
- Leaving (
open={false}), it fades out on the fast effects spring as its height folds; under reduced motion only the fade runs, and its height stays until it has gone.
What you need to do
- Write the message so it says what happened and what to do; the severity's colour and icon are not read.
- Use
autoFocusfor an error that blocks a form after a failed submit, and nowhere else. - Hide it with
open={false}rather than unmounting it, so it leaves with its motion and hands focus on first; if focus should go somewhere specific (the field to fix), move it inonClose. - Pass
labels.closein your language, andheadingLevelwhen the alert heads a section. - In forced-colours mode every alert keeps a border; keep
classNamesoverrides from removing it.