Alert
A callout for a message the user should notice where it is shown: a failed save, a confirmation that something worked, a warning about a setting. Only the destructive variant interrupts a screen reader.
Intents
alert
informational
status
Variants
Every value of the attributes that change how it looks. The values come from the schema.
variant
Visual and live-region emphasis. destructive announces assertively; success, warning, and default announce politely.
variant="default"variant="success"variant="warning"variant="destructive"Examples
Each one rendered live, over the markup that produces it.
Default
Neutral information, announced politely as role="status".
<aihio-alert>
<div slot="title">Heads up!</div>
<div slot="description">You can add components to your app.</div>
</aihio-alert>
Destructive
A failure: the one variant announced assertively, as role="alert".
<aihio-alert variant="destructive">
<div slot="title">Error</div>
<div slot="description">Something went wrong.</div>
</aihio-alert>
Success
A confirmation that something worked.
<aihio-alert variant="success">
<div slot="title">Changes saved</div>
<div slot="description">Your profile is up to date.</div>
</aihio-alert>
Warning
Something that needs attention but has not failed.
<aihio-alert variant="warning">
<div slot="title">Trial ends in 3 days</div>
<div slot="description">Add a payment method to keep your workspace active.</div>
</aihio-alert>
Mistakes
Each one beside its fix, with what aihio lint says about it. The prompt fragment gives agents the
same pairs, and the build fails if the linter stops catching one or a fix stops passing.
variant="error" is not valid.
Use variant="destructive" for error states.
Don't
<aihio-alert variant="error">Oops</aihio-alert>
aihio lint reports
-
invalid-enum-attributeerror Suggestsvariant="destructive"
Do
<aihio-alert variant="destructive">
<div slot="title">Could not save</div>
</aihio-alert>
Alerts are non-interactive surfaces.
For acknowledgeable prompts use aihio-dialog.
Don't
<aihio-alert><aihio-button>OK</aihio-button></aihio-alert>
aihio lint reports
-
forbidden-descendanterror
Do
<aihio-alert>
<div slot="title">Your changes were saved</div>
</aihio-alert>
role="alert" interrupts the screen reader.
A confirmation should announce politely — drop the role and let the success variant set role="status".
Don't
<aihio-alert variant="success" role="alert">Saved</aihio-alert>
aihio lint reports
-
alert-roleerror
Do
<aihio-alert variant="success">Saved</aihio-alert>
API
Every attribute, property, method, and event the schema declares for aihio-alert.
Attributes
variant-
one of
defaultsuccesswarningdestructivedefaultdefault - Visual and live-region emphasis. destructive announces assertively; success, warning, and default announce politely.
Slots
default- Alert content
title- Alert title (use
slot="title") description- Alert description (use
slot="description")
Composition
- Allowed slots
-
defaulttitledescription - Forbidden descendants
-
aihio-buttonaihio-toggleaihio-switchaihio-inputaihio-comboboxaihio-dropdownaihio-dialog
Accessibility
What you have to provide, and what the component already does. The obligations with a rule are checked by
aihio lint and by the dev build's console warnings.
Your obligations
-
warn Whenvariant="destructive"Include
slot="title"orslot="description"so assistive tech has content to announce. Colour alone is not a sufficient signal.Checked as
alert-announced-content -
error When role is set on the alert to anything but its variant's own (alert for destructive, status otherwise)Remove the role and let the variant set it:
role="alert"for destructive, which interrupts the screen reader, androle="status"for the rest, which waits its turn.Checked as
alert-role
Handled for you
role="alert"(assertive) is set forvariant="destructive"; other variants getrole="status"(polite) so a confirmation does not interrupt the screen reader- An author-provided role is always left alone
In patterns
Canonical compositions that use aihio-alert.