# Alert (`.z-alert`)

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

- **Kind:** css
- **Category:** feedback

## Reference inventories

- [CSS Variables (7)](https://next.0build.dev/docs/components/alert/css-vars.md)
- [CSS Classes (6)](https://next.0build.dev/docs/components/alert/css-classes.md)

## Events

| Event | Cancelable | Detail | Description |
| --- | --- | --- | --- |
| `z-alert:before-hide` | ✓ | `{ target: HTMLElement; trigger: HTMLElement \| null }` | 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 }` | 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]`. |

## Notes

- Alerts have no component class: dismissal is driven by the shared close singleton (`singletons/close.ts`) through the document-level toggle delegate installed by the essentials bundle.
- Dismissal plays the `z-closing` transition (default 150 ms) and removes the alert when it ends; `animation: false` or `duration: 0` in the `data-close` value removes it instantly.
- Unclassed links inside an alert are underlined and medium-weight so they stand out against the tinted background.

## Guides

- [Styling with cls and stl](https://next.0build.dev/docs/guides/styling.md)
- [Translating Components](https://next.0build.dev/docs/guides/i18n.md)
- [Icon Resolution](https://next.0build.dev/docs/guides/icons.md)
- [The data-source Convention](https://next.0build.dev/docs/guides/data-source.md)
- [Openers & Triggers](https://next.0build.dev/docs/guides/triggers.md)
- [Dialog Behavior](https://next.0build.dev/docs/guides/dialogs.md)
- [Utilities](https://next.0build.dev/docs/guides/utilities.md)
- [Runtime](https://next.0build.dev/docs/guides/runtime.md)

## Related

- [Toast](https://next.0build.dev/docs/components/toast.md)
