Alert
Contextual feedback for an action or a state change. Renders withrole="alert" so assistive tech announces it.
Variants
Heads up. This is an informational message.
Saved. Your changes are live.
Careful. This cannot be undone later.
Failed. The request was rejected.
<Alert><strong>Heads up.</strong> This is an informational message.</Alert>
<Alert variant="success"><strong>Saved.</strong> Your changes are live.</Alert>
<Alert variant="warning"><strong>Careful.</strong> This cannot be undone later.</Alert>
<Alert variant="danger"><strong>Failed.</strong> The request was rejected.</Alert>Dismissible
Click the close button to remove this alert.
<Alert variant="info" dismissible>
Click the close button to remove this alert.
</Alert>Styles: filled and outline
Saved. Filled style, white text.
Failed. Outline style, transparent body.
<Alert variant="success" style="filled">...</Alert>
<Alert variant="danger" style="outline">...</Alert>Listening for dismissal
Dismissing dispatches a bubbling ink:alert:dismiss event from the alert root:
document.addEventListener("ink:alert:dismiss", (event) => {
console.log("alert dismissed", event.target);
});Alerts rendered after page load (client-side HTML) are wired by callingwindow.Ink.init(root).
Props
| Prop | Type | Default | Description |
|---|---|---|---|
variant | info | success | warning | danger | info | Semantic color. |
style | tint | filled | outline | tint | Filled uses white text on the semantic color (AA in the default theme). |
dismissible | boolean | false | Shows a close button that removes the alert. |
role | string | alert | ARIA role. Use status for less urgent announcements. |
Theming
:root {
--ink-alert-radius: 0; /* square alerts */
}Accessibility
role="alert"announces the content when it appears dynamically. For static alerts rendered in the page source, passrole="status"to avoid an unnecessary announcement on load.- The close button has
aria-label="Dismiss alert"and is keyboard operable. - Variant color is paired with the border and background, never color alone.