feedbackcss

Alert

Dismissible inline message with status variants, styled by CSS and dismissed by the shared close system.

CSS Variables

VariableDefaultScopeDescription
--z-alert-bgvar(--z-muted).z-alertBackground base color, mixed with transparency using --z-alert-bg-o.
--z-alert-bg-o4%.z-alertBackground opacity percentage used in the background color mix.
--z-alert-bordervar(--z-border).z-alertBorder base color, mixed with transparency using --z-alert-border-o.
--z-alert-border-ovar(--z-border-o).z-alertBorder opacity percentage used in the border color mix.
--z-alert-colorvar(--z-muted-f).z-alertText base color, mixed with transparency using --z-alert-color-o.
--z-alert-color-o100%.z-alertText opacity percentage used in the text color mix.
--z-alert-radiusvar(--z-global-radius).z-alertCorner radius of the alert box.

Events

EventDetailFlagsDescription
z-alert:before-hide{ target: HTMLElement; trigger: HTMLElement | null }cancelable, bubblesFires 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 }bubblesFires on the alert after dismissal is confirmed, before it is removed. Detail carries target and trigger.

Data Hooks

AttributeValuesApplies toRoleDescription
data-close—external-triggertriggerDismisses 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—hostmarkerMarks an element as dismissible without the .z-alert class; the close system's ancestor search matches .z-alert, [data-dismissible].

CSS Classes

ClassRoleApplies toDescription
.z-alertroot.z-alertRoot class of the alert box: a padded, bordered, rounded container with a tinted background.
.z-alert-closeelement.z-alertClose affordance positioned in the top inline-end corner; put data-close on the button or link that uses it.
.z-alert-dangermodifier.z-alertDanger variant: re-tints background, border, and text with the danger color.
.z-alert-infomodifier.z-alertInfo variant: re-tints background, border, and text with the info color.
.z-alert-successmodifier.z-alertSuccess variant: re-tints background, border, and text with the success color.
.z-alert-warningmodifier.z-alertWarning 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.