Skip to content

Alert

Heads up

Your changes are saved as a draft.

Something failed

Your session expired. Sign in again.

<div class="alert" role="alert">
<h3 class="alert-title">Heads up</h3>
<p class="alert-description">Your changes are saved as a draft.</p>
</div>

Heads up

The icon, the title and the description each sit in their own slot.

ClassPart
.alertContainer
.alert-titleHeading line
.alert-descriptionBody copy
.alert-actionControl pinned to the trailing corner
.alert-destructiveError variant

An svg as the first child takes its own column and the text shifts across; .alert-action takes the trailing corner and reserves room so a long title never runs under it.

Draft saved

Scheduled maintenance

The API is read-only between 02:00 and 03:00 UTC.

A title on its own is a complete alert. The description is for the consequence, not a restatement.

Payment failed

Your card was declined. Update it to keep the service running.

The variant recolours the text and the icon. The surface stays the card colour, so the alert does not turn into a solid block of red.

Update available

Version 2.1 is ready to install.

light-dark() picks the pair for the theme in use, which works because partialkit sets color-scheme on the root.

Deployment finished

Version 2.1 is live in every region.

Set dir="rtl" on the page or on any subtree — padding, corners and positions follow the reading direction on their own. See the button page for a live example.

An alert that is on the page from the start needs nothing. One that appears in response to something must be announced, and the role decides how:

RoleWhen
role="alert"Errors and anything the user must act on. Interrupts what is being read.
role="status"Confirmations and progress. Waits for a pause.
<div class="alert alert-destructive" role="alert">
<h3 class="alert-title">Payment failed</h3>
</div>

Put the element in the DOM before you fill it, or the announcement can be missed — assistive tech watches an existing live region for changes rather than discovering a new one.

If the alert has a dismiss control, that control needs a name: aria-label="Dismiss" on an icon-only button.