WlIconButton
Appearance
Full example
<div class="wl-stack" data-space="md">
<WlIconButton
icon="bell"
aria-label="Notifications"
:count="3"
/>
</div>Indicators
Full example
<div class="wl-stack" data-space="md">
<WlIconButton
icon="bell"
aria-label="Notifications"
:count="3"
/>
</div>States
Full example
<div class="wl-stack" data-space="md">
<WlIconButton
icon="bell"
aria-label="Notifications"
:count="3"
/>
</div>Variants, counts and icons
Ghost, secondary, soft, small size, active, disabled, count/dot and a custom default slot.
Click an icon button. Add mode: disabled.
Full example
<script setup lang="ts">
import { WlIcon, WlIconButton, type WlIconButtonVariant, type WlTone } from "legato-ui";
import { ref } from "vue";
const variants = ["ghost", "secondary", "soft"] as const satisfies readonly WlIconButtonVariant[];
const tones = ["neutral", "accent", "info", "success", "warning", "danger"] as const satisfies readonly WlTone[];
const active = ref(false);
const message = ref("Click an icon button.");
</script>
<template>
<div class="wl-stack" data-space="lg">
<div class="wl-inline" data-space="md"><WlIconButton
v-for="variant in variants"
:key="variant"
icon="search"
:variant="variant"
:aria-label="'Search — ' + variant"
@click="message = 'Search selected: ' + variant"
/></div>
<div class="wl-inline" data-space="md">
<div
v-for="tone in tones"
:key="tone"
class="wl-inline"
data-space="xs"
>
<WlIconButton
icon="search"
variant="soft"
:tone="tone"
:aria-label="'Search — ' + tone"
/>
<span class="wl-text-small">{{ tone }}</span>
</div>
</div>
<div class="wl-inline" data-space="md">
<WlIconButton
icon="bell"
:count="4"
aria-label="Notifications: 4 unread"
@click="message = 'Notifications opened'"
/>
<WlIconButton
icon="bell"
dot
variant="soft"
aria-label="There are new notifications"
@click="message = 'New notifications marked as read'"
/>
<WlIconButton
icon="user"
variant="secondary"
size="sm"
aria-label="Profile — small button"
@click="message = 'Profile opened'"
/>
<WlIconButton
icon="plus"
:active="active"
:aria-pressed="active"
aria-label="Add mode"
@click="active = !active"
/>
<WlIconButton icon="trash" disabled aria-label="Deletion unavailable" />
<WlIconButton
aria-label="Favorites — custom slot"
@click="message = 'Favorites opened'"
><WlIcon name="star" :size="18" /></WlIconButton>
</div>
<p class="wl-text-small" role="status">
{{ message }} {{ "Add mode:" }} {{ active ? "enabled" : "disabled" }}.
</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 |
|---|---|---|---|
variant | WlIconButtonVariant | "ghost" | Visual variant. |
size | "md" | | "md" | Button size. |
tone | WlTone | Not set | Semantic color, independent of the visual treatment. |
icon | WlIconInput | Not set | Icon (when no slot is provided). |
active | boolean | false | Highlight as active. |
disabled | boolean | false | Disables the button. |
count | number | Not set | Numeric badge (shown when > 0). |
dot | boolean | false | Indicator dot (when count is absent). |
ariaLabel | string | Not set | Action name. With icon, provide ariaLabel, native aria-label/aria-labelledby or a named pt.root. Without icon, default-slot text can name the action; badge and tooltip text remain descriptions. |
pt | WlPt< | Not set | Attributes of internal Legato UI elements. |
loading | boolean | Not set | Indicate pending work supplied by the application. |
href | string | Not set | Native link destination. |
to | unknown | Not set | Application router destination handled by the configured link adapter. |
countLabel | string | Not set | Badge description; the action still needs its own accessible name. |
dotLabel | string | Not set | Accessible description for a meaningful status dot. |
Events
| Event | Payload | When emitted |
|---|---|---|
click | [event: MouseEvent] | Click (not emitted when disabled). |
Slots
| Slot | Type / values | Content |
|---|---|---|
default | default?(props: Record< | Action text, optionally with a custom icon. Icon-only slot content still needs its own accessible name. |
Pass-through: pt
Sections WlIconButton 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 |
|---|---|---|
loadingIcon | span.wl-btn__spinner | Decorative loading indicator. |
root | button / a | The root section in WlConfig.pt.button configuration. |
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
- Every icon-only button gets a clear ariaLabel; decorative SVG is hidden from assistive technology.
- Tab, Enter and Space use the native button; disabled blocks the action and removes the button from the Tab order.
- Active controls appearance. For a real toggle, pass aria-pressed and store state in the application; give dot a text explanation.
Keyboard and application responsibilities
| Key | Action |
|---|---|
| Tab / Shift+Tab | Move between enabled links, actions and form controls. |
| Enter / Space | Activate native actions; links follow with Enter. |
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.