WlAlert
Appearance
Full example
<div class="wl-stack" data-space="md">
<WlAlert
v-if="visible"
title="Changes saved"
closable
@close="visible = false"
>{{ "You can continue working." }}<template #action>
<WlButton size="sm" variant="ghost" @click="visible = false">{{ "Got it" }}</WlButton>
</template></WlAlert>
<WlButton v-else @click="visible = true">{{ "Show notification" }}</WlButton>
</div>Content
Full example
<div class="wl-stack" data-space="md">
<WlAlert
v-if="visible"
title="Changes saved"
closable
@close="visible = false"
>{{ "You can continue working." }}<template #action>
<WlButton size="sm" variant="ghost" @click="visible = false">{{ "Got it" }}</WlButton>
</template></WlAlert>
<WlButton v-else @click="visible = true">{{ "Show notification" }}</WlButton>
</div>Semantic tones and retry
Info/ok/warn/err, action slot, closable with a clear label and restoring a hidden error.
Checks in this example: 0. Error: visible.
Full example
<script setup lang="ts">
import { WlAlert, WlButton } from "legato-ui";
import { nextTick, ref } from "vue";
const error = ref(true);
const attempts = ref(0);
const errorRegion = ref<HTMLElement | null>(null);
async function showError(visible: boolean, retry = false): Promise<void> {
if (retry) attempts.value++;
error.value = visible;
await nextTick();
errorRegion.value?.querySelector<HTMLButtonElement>("button")?.focus();
}
</script>
<template>
<div class="wl-stack" data-space="lg">
<WlAlert tone="neutral" live="off">{{ "Local example notification." }}</WlAlert>
<WlAlert tone="accent" live="off">{{ "New version available" }}</WlAlert>
<WlAlert tone="info" title="Tip">{{ "Your application saves the settings." }}</WlAlert>
<WlAlert tone="success" title="Saved">{{
"All changes are recorded in the local example."
}}</WlAlert>
<WlAlert tone="warning" title="Low on space">
{{ "Free up space before adding another attachment." }}
<template #action>
<WlButton size="sm" @click="attempts++">{{ "Check space" }}</WlButton>
</template>
</WlAlert>
<div ref="errorRegion">
<WlAlert
v-if="error"
tone="danger"
title="Could not save"
closable
close-label="Hide error message"
@close="showError(false)"
>
{{ "The draft is saved. Try again." }}
<template #action>
<WlButton size="sm" @click="showError(false, true)">{{ "Retry saving" }}</WlButton>
</template>
</WlAlert>
<div v-else>
<WlButton size="sm" variant="soft" @click="showError(true)">{{ "Show error again" }}</WlButton>
</div>
</div>
<p class="wl-text-small" role="status">
{{ "Checks in this example:" }} {{ attempts }}{{ ". Error:" }}
{{ error ? "visible" : "hidden" }}.
</p>
</div>
</template>Props
Types, accepted values and literal defaults come from the public manifest. Inherited settings name their source; “Not set” means no default is declared.
| Prop | Type / values | Default | Purpose |
|---|---|---|---|
tone | WlTone | "info" | Semantic notification color. |
title | string | Not set | Title. |
closable | boolean | false | Button that closes the surface. |
closeLabel | string | Not set | Uses locale.close when omitted or undefined; English fallback: Close. |
live | "assertive" | | Not set | Announcement priority: determined by tone, polite, assertive, or off for a static block. |
pt | WlPt< | Not set | Attributes for internal DOM sections. |
Events
| Event | Payload | When emitted |
|---|---|---|
close | [event: MouseEvent] | Close button click. |
Slots
| Slot | Type / values | Content |
|---|---|---|
default | — | Notification text. |
action | — | Trailing action (button). |
Pass-through: pt
Sections WlAlert are listed below. Attributes merge in this order: createWlPt() WlConfig.ptpt instance. Class and style merge; the last supplied value takes priority for other attributes.
| Section | DOM | Purpose |
|---|---|---|
root | div.wl-alert | Main element of the component. |
icon | span.wl-alert__icon | Decorative component icon. |
body | div.wl-alert__body | Main component content. |
title | div.wl-alert__title | Visible component heading. |
text | div.wl-alert__text | Text content of the component. |
action | div.wl-alert__action | Action area within the component. |
closeButton | button.wl-alert__close | Button that closes the surface. |
closeIcon | span | Decorative icon inside the close button. |
Sections refer to the component DOM. Dotted names identify a configuration group and its section; composite parts use their own pt groups. Global and local attributes merge, with class and style added together.
Keyboard and accessibility
- Card, Accordion, Alert and Segmented expose component font-size, line-height, font-weight and font-family tokens. Defaults retain 1.0 typography. Import styles/primitives.css and add wl-type-scale to opt into semantic roles; the mapping table and live toggle are in Typography → Scale. Set local scale values on the same group, or override a component token on a closer element. Select and MultiSelect use the font size of each role. To scale a local dropdown, pass the class and role values through pt.overlay.
- The message uses role=alert: its text must explain the problem and next step, not just its colour.
- For closable, set a specific closeLabel. Close emits an event; the application hides and restores the message.
- The action slot should contain a clear button. If a focused action disappears, the consumer should restore focus sensibly.
Keyboard and application responsibilities
Provide a meaningful accessible name and connect labels, hints and errors to the focusable element. Check the behavior with your own data and a screen reader.
WAI-ARIA Authoring PracticesIn your application, check keyboard controls, zoom and focus visibility. State labels and required information must be readable in every theme.