WlNavItem
Change props to see the result: the example and code use the same settings. “Reset” restores the initial values.
Settings
Item text (when no slot is provided).
Leading icon.
Trailing badge: number | string. Enter a number here. Set a text label in the SFC.
Overrides the item's accessible name.
Current item (aria-current=page).
Disables the item.
Hides the label and badge while preserving the item's accessible name.
Props href, to, size, density, pt, 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 { WlIcon, WlNavItem } from "legato-ui";
import { ref } from "vue";
const active = ref(false);
</script>
<template>
<div class="wl-stack" data-space="md">
<WlNavItem
label="Team materials"
icon="folder"
:badge="12"
:active="active"
@click="active = !active"
>
<template #icon="{ icon }"><WlIcon v-if="icon" :name="icon" :size="17" /></template>
<template #badge="{ badge }"><strong>{{ badge }}</strong></template>
</WlNavItem>
</div>
</template>Active items and collapsed labels
Section buttons, counts, disabled, a real link and collapsed mode that retains accessible names.
Selected section: Tasks.
Vue SFC · additional example
<script setup lang="ts">
import { WlCheckbox, WlNavItem } from "legato-ui";
import { ref } from "vue";
const active = ref<"tasks" | "notes" | "profile">("tasks");
const collapsed = ref(false);
</script>
<template>
<div class="wl-stack" data-space="lg">
<WlCheckbox v-model="collapsed">{{ "Collapse item labels" }}</WlCheckbox>
<nav class="showcase-nav wl-stack" data-space="xs" aria-label="Workspace sections">
<WlNavItem
label="Tasks"
icon="check"
:badge="12"
:active="active === 'tasks'"
:collapsed="collapsed"
@click="active = 'tasks'"
/>
<WlNavItem
label="Notes"
icon="edit"
:badge="4"
:active="active === 'notes'"
:collapsed="collapsed"
@click="active = 'notes'"
/>
<WlNavItem
label="Profile"
icon="user"
:active="active === 'profile'"
:collapsed="collapsed"
@click="active = 'profile'"
><span>{{ "My profile" }}</span></WlNavItem>
<WlNavItem
label="Archive"
icon="trash"
disabled
:collapsed="collapsed"
/>
<WlNavItem
label="Documentation"
icon="file"
href="?view=docs"
:collapsed="collapsed"
/>
</nav>
<p class="wl-text-small" role="status">
{{ "Selected section:" }} {{ {
tasks: "Tasks",
notes: "Notes",
profile: "Profile"
}[active] }}.
</p>
</div>
</template>
<style scoped>
.showcase-nav { max-width: 260px; }
</style>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 |
|---|---|---|---|
label | string | Not set | Item text (when no slot is provided). |
icon | WlIconInput | Not set | Leading icon. |
badge | number | | Not set | Trailing badge: number | string. |
active | boolean | false | Current item (aria-current=page). |
disabled | boolean | false | Disables the item. |
href | string | Not set | Uses <a> with href, otherwise <button>. |
collapsed | boolean | false | Hides the label and badge while preserving the item's accessible name. |
ariaLabel | string | Not set | Overrides the item's accessible name. |
to | unknown | Not set | Application router destination handled by the configured link adapter. |
size | WlSizeSm | "md" | Size within the component family's documented scale. |
density | WlDensity | "default" | Spacing density for this component family. |
pt | WlPt< | Not set | Attributes and callbacks for the component's documented pass-through sections. |
Events
| Event | Payload | When emitted |
|---|---|---|
click | [event: MouseEvent] | Click (not emitted when disabled). |
Slots
| Slot | Type / values | Content |
|---|---|---|
default | default?(props: Record< | Custom text instead of label. |
icon | icon?(props: { icon: WlIconInput | | Custom icon content. |
badge | badge?(props: { badge: string | | Custom navigation badge content. |
Pass-through: pt
Sections WlNavItem 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 | button / a.wl-nav-item | Main element of the component. |
icon | span.wl-nav-item__icon | Decorative component icon. |
label | span.wl-nav-item__label | Visible component label. |
badge | span.wl-nav-item__badge | Supplementary item count or status. |
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
- Label or ariaLabel describes the item's destination. Collapsed mode keeps the name even when the label is visually hidden.
- Href creates a real link; without href, a native button is created. Active sets aria-current=page.
- Unavailable links have no href and are outside the Tab order; disabled buttons are blocked natively.
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.