WlSidebar

Responsive sidebar built from WlNavItem: navigation groups, footer, collapsed/hover and pinning. Opens as a Drawer on mobile. No router required.
Components / Composites v0.2.0

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

Settings

density
brand

Product name.

brandMark

Short text brand mark.

ariaLabel

Uses locale.mainNavigation when omitted or undefined; English fallback: Main navigation.

pinLabel

Uses locale.pinSidebar when omitted or undefined; English fallback: Pin sidebar.

unpinLabel

Uses locale.unpinSidebar when omitted or undefined; English fallback: Unpin sidebar.

Props groups, footerItems, pinned, mobileOpen, 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 { WlButton, WlSidebar } from "legato-ui";
import { ref } from "vue";
const active = ref("materials");
const mobileOpen = ref(false);
const pinned = ref(true);
</script>

<template>
  <div class="wl-stack" data-space="md">
    <WlButton @click="mobileOpen = true">{{ "Open navigation" }}</WlButton><WlSidebar
      v-model="active"
      v-model:mobile-open="mobileOpen"
      v-model:pinned="pinned"
      brand="Team"
      brand-mark="T"
      :groups="[{ id: 'main', items: [
        { key: 'materials', label: 'Materials', icon: 'file' },
        { key: 'settings', label: 'Settings', icon: 'settings' }
      ] }]"
      
    />
  </div>
</template>

Groups, pinning and mobile

Main/bottom items, brand-mark/footer, disabled, hover/pinned and a controlled mobile drawer.

Active item: materials

Hover expands the unpinned sidebar. On mobile, a button opens the drawer; choosing an item closes it.

Pinned: yes. Mobile sidebar: closed.

Vue SFC · additional example
<script setup lang="ts">
import { WlButton, WlIcon, WlSidebar, type WlSidebarGroup, type WlSidebarItem } from "legato-ui";
import { ref } from "vue";
const active = ref("materials");
const pinned = ref(true);
const mobileOpen = ref(false);
const groups: WlSidebarGroup[] = [{ id: "work", label: "Work", items: [{ key: "materials", label: "Materials", icon: "file", badge: 12 }, { key: "tasks", label: "Tasks", icon: "check", badge: 3 }] }, { id: "team", label: "Team", separator: true, items: [{ key: "people", label: "Members", icon: "user" }, { key: "archive", label: "Archive", icon: "folder", disabled: true }] }];
const footerItems: WlSidebarItem[] = [{ key: "settings", label: "Settings", icon: "settings" }];
</script>

<template>
  <div class="wl-stack" data-space="lg">
    <div class="wl-inline" data-space="sm">
      <WlButton size="sm" @click="pinned = !pinned">
        {{ pinned ? "Unpin sidebar" : "Pin sidebar" }}
      </WlButton>
      <WlButton class="showcase-sidebar-mobile" size="sm" @click="mobileOpen = true">
        {{ "Open mobile sidebar" }}
      </WlButton>
    </div>
    <div class="showcase-sidebar-stage">
      <WlSidebar
        v-model="active"
        v-model:pinned="pinned"
        v-model:mobile-open="mobileOpen"
        :groups="groups"
        :footer-items="footerItems"
        brand="Team"
        brand-mark="T"
        aria-label="Example team navigation"
      >
        <template #brand-mark><span class="showcase-sidebar-mark"><WlIcon name="grid" :size="18" /></span></template>
        <template #footer="{ expanded }">
          <p v-if="expanded" class="wl-text-small wl-text-muted">{{ "Local example" }}</p>
        </template>
      </WlSidebar>
      <div class="showcase-sidebar-content wl-stack" data-space="md">
        <h3 class="wl-text-subheading">{{ "Active item:" }} {{ active }}</h3>
        <p class="wl-text-body">{{ "Hover expands the unpinned sidebar. On mobile, a button opens the drawer; choosing an item closes it." }}</p>
        <p class="wl-text-small" role="status">
          {{ "Pinned:" }} {{ pinned ? "yes" : "none" }}{{
            ". Mobile sidebar:"
          }} {{ mobileOpen ? "open" : "closed" }}.
        </p>
      </div>
    </div>
  </div>
</template>

<style scoped>
.showcase-sidebar-stage {
  height: 380px;
  display: flex;
  min-width: 0;
  border: 1px solid var(--wl-border);
  border-radius: var(--wl-corner-surface);
  background: var(--wl-bg-soft);
}
.showcase-sidebar-content { min-width: 0; flex: 1; padding: var(--wl-space-lg); overflow: auto; }
.showcase-sidebar-mark { display: inline-flex; align-items: center; justify-content: center; padding: var(--wl-space-xs); }
.showcase-sidebar-mobile { display: none; }
@media (max-width: 900px) { .showcase-sidebar-mobile { display: inline-flex; } }
</style>