OAlert
OAlert displays important feedback or information. It uses role="alert" and can expose an optional native close button.
Usage
Step by step
- Import
OAlertfrom theooko-ui/alertpublic subpath. - Choose a semantic
colorand provide a concisetitlewhen it helps readers scan the message. - Add
closableonly when the parent also listens forcloseand removes the alert.
Example
The rendered example and its source come from the same Vue single-file component.
Interactive playground
Change the alert's color, title, alignment, and close action. The preview updates immediately.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
color | "primary" | "secondary" | "info" | "success" | "warning" | "danger" | "neutral" | "info" | Visual color applied to the alert. |
title | string | undefined | Optional title displayed before the alert content. |
center | boolean | false | Centers the title and content. |
closable | boolean | false | Displays a button that emits the close event. |
closeLabel | string | "Dismiss alert" | Accessible name of the close button. |
glass | boolean | false | Uses a translucent, blurred surface with default text; the tone stays on the border and a dot and faintly tints the background. Defaults to the app's glass option. |
Events
| Event | Payload | Description |
|---|---|---|
close | none | Requests that the alert be closed. |
Slots
| Slot | Props | Description |
|---|---|---|
default | none | Provides the alert message. |
Related types
| Type | Definition |
|---|---|
OokoColor | type OokoColor = (typeof OOKO_COLORS)[number]; |
CSS custom properties
| Custom property | Default | Description |
|---|---|---|
--o-alert-padding | var(--o-space-4) | Sets the inner spacing around the alert content. |
--o-alert-gap | var(--o-space-2) | Sets the spacing between the title and main content. |
--o-alert-border | 0 | Sets the alert border shorthand; its color follows the color prop. |
--o-alert-border-radius | var(--o-radius-surface) | Sets the alert corner radius. |
--o-alert-close-size | 1.75rem | Sets the close button size; the close icon scales with this value. |
--o-alert-glass-background | var(--o-background-glass) | Sets the translucent background of a glass alert. |
--o-alert-glass-tint | 12% | Sets how strongly the color tone tints the background of a glass alert. |
--o-alert-glass-backdrop-filter | var(--o-backdrop-filter-glass) | Sets the filter applied to the content behind a glass alert. |
Override example
:root {
--o-alert-border-radius: var(--o-radius-xl);
--o-alert-close-size: 2rem;
--o-alert-border: 1px dashed;
}Define the same custom properties on a container instead of :root to limit an override to one part of an application.
Accessibility
- The root uses
role="alert"so important dynamic content is announced. - The close control is a native
buttonwith standard keyboard and focus behavior. - Its decorative Lucide
Xicon is hidden from assistive technologies. - Set
closeLabelto a localized, context-specific accessible name. - Additional attributes such as
aria-live,aria-atomic, andidare forwarded to the alert root. - Forced-colors mode receives explicit borders for the alert and close button.
Behavior and edge cases
App defaults may configure
colorandcloseLabel; direct props take precedence.Semantic alert text uses the
deepshade in the light theme anddeeperin explicit or system-selected dark themes.glassis the soft variant for translucent interfaces: a translucent, blurred surface with default text, readable in both themes, while thecolortone moves to the border and a dot before the content and faintly tints the background (--o-alert-glass-tint). It follows the app'sglassoption unless set on the alert, and--o-alert-glass-*tunes it.Emitting
closedoes not hide the alert. The parent owns its visibility, for example withv-ifas shown above.The close button is rendered only when
closableistrue.The close action uses Lucide's
Xicon;CircleXis reserved for error or invalid states.Because
role="alert"is assertive, use this component for important dynamic feedback rather than routine static content.