WlIconButton
Change props to see the result: the example and code use the same settings. “Reset” restores the initial values.
Settings
Visual variant.
Button size.
Icon (when no slot is provided).
Numeric badge (shown when > 0).
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.
Badge description; the action still needs its own accessible name.
Accessible description for a meaningful status dot.
Highlight as active.
Disables the button.
Indicator dot (when count is absent).
Indicate pending work supplied by the application.
Props pt, tone, href, to, models, handlers and slots can be edited in the SFC. See their descriptions in API.
Example
Explore the live example and copy its Vue SFC into your application. Settings on the left can be combined.
Code for your application
Vue SFC · current settings
<script setup lang="ts">
import { WlIconButton } from "legato-ui";
</script>
<template>
<div class="wl-stack" data-space="md">
<WlIconButton
icon="bell"
aria-label="Notifications"
:count="3"
/>
</div>
</template>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.
Vue SFC · additional example
<script setup lang="ts">
import { WlIcon, WlIconButton, type WlIconButtonVariant } from "legato-ui";
import { ref } from "vue";
const variants = ["ghost", "secondary", "soft"] as const satisfies readonly WlIconButtonVariant[];
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">
<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. |
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. |
tone | WlTone | Not set | Semantic color, independent of the visual treatment. |
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.