Alert

A tinted line that stays in the page, beside the thing it is about, for as long as it is true.

Try it

Information:
Use the Markdown syntax for styling your email messages.
Error:
The calendar could not be reached. Nothing was saved.
Success:
The invite was sent to leonor@example.com.
Warning:
Room conflict
This room is booked until 15:00. The appointment will overlap.

The three drawn shapes — a close, nothing, one action — and a fourth that is not drawn: a title over the message, with both buttons.

Choosing an alert

An alert is about a place. It sits at the top of the form, the card or the page it concerns, and it stays while what it says is true: the trial ends in three days, the calendar is disconnected, these settings are managed by someone else. What has just happened and needs no place is a toast. What is wrong with one field is the Field’s own error. What must be decided before anything else is a dialog.

It does not dismiss itself and it has no clock. onClose shows the close and tells the caller, who removes it; without it the alert stays until its cause is gone.

Information:
This one is removed by the page when it is closed.

Anatomy

Alert geometry, in pixels
PartValue
Least height56
Padding12 block, 16 before, 12 after
Gap8
Radius12
Text, Medium14 / 22
Icon20
Action32 tall, 16 inline, a capsule
Close32 square, icon 20

It is as wide as what holds it. A long message wraps and the alert grows downward, with the icon and the buttons kept to the first line. It asks its own container how wide it is, not the screen: under 400, the action drops below the message and the close keeps the corner.

Warning:
This room is booked until 15:00. The appointment will overlap.

Where it leaves the drawing

The drawing edges two of its states in the theme’s strong status borders and two in a pale stop with no token, so two alerts have an outline and two almost none. Every edge is now soft, and four tokens were added for them, named after the surfaces they edge. In dark they are a stop stronger, as every border in the theme is.

The four edges, as aliases
TokenLightDark
border/info-subtleglacier/200glacier/700
border/success-subtlemoss/200moss/700
border/warning-subtleamber/300amber/700
border/danger-subtleember/200ember/700

The drawn action is filled with the state’s colour. The theme has a fill for success and for danger and none for the other two, and white on the drawn info fill is about 3.4:1. So the action is an outline in the text’s own colour, which already reads on the tint, with the theme’s wash for hover. The fill returns when all four tones have one.

The close is 32 with a 20 icon, the Toast’s, where the drawn one is 24: one close button across the system. In dark the alert keeps its tint, a surface step above a card, where the Badge changes to an outline: that was chosen for a label 24 tall, and an alert is a panel whose tint is how it is found.

Accessibility

The tone is a colour and a shape, so it is also said: a screen reader hears “Warning:” before the message. An alert is not a live region unless asked. One that is in the page when it loads would otherwise be read out over the page; one that is inserted in answer to something takes announce, and then danger and warning interrupt as alert and the others wait as status. The action comes before the close in the tab order. The focus ring is the system’s, and is 3:1 or more on all four tints in both modes.

Props

Alert props
PropTypeDefault
tone'info' | 'success' | 'warning' | 'danger''info'
childrenReactNoderequired
titlestring—
action{ label: string; onClick: () => void }—
onClose() => void—
closeLabelstring'Dismiss'
announcebooleanfalse
classNamestring—