WlNavItem

Navigation item: button or link (href) with icon, badge and active state.
Components / Actions v0.1.0

Change props to see the result: the example and code use the same settings. “Reset” restores the initial values.

Settings

label

Item text (when no slot is provided).

icon

Leading icon.

badge

Trailing badge: number | string. Enter a number here. Set a text label in the SFC.

ariaLabel

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

Focus: outside the example · pointer: outside the 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>