feedbackcss
Alert
Dismissible inline message with status variants, styled by CSS and dismissed by the shared close system.
CSS Variables
| Variable | Default | Scope | Description |
|---|---|---|---|
--z-alert-bg | var(--z-muted) | .z-alert | Background base color, mixed with transparency using --z-alert-bg-o. |
--z-alert-bg-o | 4% | .z-alert | Background opacity percentage used in the background color mix. |
--z-alert-border | var(--z-border) | .z-alert | Border base color, mixed with transparency using --z-alert-border-o. |
--z-alert-border-o | var(--z-border-o) | .z-alert | Border opacity percentage used in the border color mix. |
--z-alert-color | var(--z-muted-f) | .z-alert | Text base color, mixed with transparency using --z-alert-color-o. |
--z-alert-color-o | 100% | .z-alert | Text opacity percentage used in the text color mix. |
--z-alert-radius | var(--z-global-radius) | .z-alert | Corner radius of the alert box. |
Events
| Event | Detail | Flags | Description |
|---|---|---|---|
z-alert:before-hide | { target: HTMLElement; trigger: HTMLElement | null } | cancelable, bubbles | Fires on the alert before it is dismissed. Cancelable: preventDefault() keeps the alert in the page. Detail carries target (the alert) and trigger (the clicked close element, or null). |
z-alert:hide | { target: HTMLElement; trigger: HTMLElement | null } | bubbles | Fires on the alert after dismissal is confirmed, before it is removed. Detail carries target and trigger. |
Data Hooks
| Attribute | Values | Applies to | Role | Description |
|---|---|---|---|---|
data-close | — | external-trigger | trigger | Dismisses through the shared close system. An empty value closes the nearest .z-alert or [data-dismissible] ancestor of the trigger; a selector or #id value closes that target. Object syntax accepts target, animation (false to remove instantly), and duration in milliseconds (default 150). |
data-dismissible | — | host | marker | Marks an element as dismissible without the .z-alert class; the close system's ancestor search matches .z-alert, [data-dismissible]. |
CSS Classes
| Class | Role | Applies to | Description |
|---|---|---|---|
.z-alert | root | .z-alert | Root class of the alert box: a padded, bordered, rounded container with a tinted background. |
.z-alert-close | element | .z-alert | Close affordance positioned in the top inline-end corner; put data-close on the button or link that uses it. |
.z-alert-danger | modifier | .z-alert | Danger variant: re-tints background, border, and text with the danger color. |
.z-alert-info | modifier | .z-alert | Info variant: re-tints background, border, and text with the info color. |
.z-alert-success | modifier | .z-alert | Success variant: re-tints background, border, and text with the success color. |
.z-alert-warning | modifier | .z-alert | Warning variant: re-tints background, border, and text with the warning color. |
Accessibility
- While a timed dismissal runs the alert is set
inert, removing it from the tab order and accessibility tree before it is removed from the DOM.