WlSidebar
Change props to see the result: the example and code use the same settings. “Reset” restores the initial values.
Settings
Product name.
Short text brand mark.
Uses locale.mainNavigation when omitted or undefined; English fallback: Main navigation.
Uses locale.pinSidebar when omitted or undefined; English fallback: Pin sidebar.
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
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>Props
Types, accepted values and literal defaults come from the public manifest. Inherited settings name their source; “Not set” means no default is declared.
v-model: Item["key"]Active item key.
| Prop | Type / values | Default | Purpose |
|---|---|---|---|
groups | readonly (WlSidebarGroup< | [] | WlSidebarGroup[]: sections with WlSidebarItem[] and an optional separator. |
footerItems | readonly Item[] | [] | WlSidebarItem[] for the pinned bottom region. |
brand | string | "" | Product name. |
brandMark | string | "" | Short text brand mark. |
ariaLabel | string | Not set | Uses locale.mainNavigation when omitted or undefined; English fallback: Main navigation. |
collapsible | boolean | true | — |
expandOnHover | boolean | true | — |
showPin | boolean | true | — |
pinLabel | string | Not set | Uses locale.pinSidebar when omitted or undefined; English fallback: Pin sidebar. |
unpinLabel | string | Not set | Uses locale.unpinSidebar when omitted or undefined; English fallback: Unpin sidebar. |
density | WlDensity | "default" | — |
pinned | boolean | false | Named v-model:pinned model. |
mobileOpen | boolean | false | Named v-model:mobile-open model. |
pt | WlPt< | Not set | Attributes and callbacks for the component's documented pass-through sections. |
Events
| Event | Payload | When emitted |
|---|---|---|
select | [item: Item, | Item selected. The application handles navigation. |
update:modelValue | Item["key"] | Emitted when the component requests a model change; the payload is the next value. |
update:pinned | boolean | Emitted when the component requests a model change; the payload is the next value. |
update:mobileOpen | boolean | Emitted when the component requests a model change; the payload is the next value. |
Slots
| Slot | Type / values | Content |
|---|---|---|
brand-mark | "brand-mark"?(props: {}): unknown; | Custom brand mark. |
brand | brand?(props: {}): unknown; | Custom brand name. |
item | item?(props: { key: Item["key"]; item: Item; group: Group; active: boolean; expanded: boolean; select: () => void }): unknown; | Main group item; scope { item, group, active, expanded, select }. |
footer-item | "footer-item"?(props: { key: Item["key"]; item: Item; active: boolean; expanded: boolean; select: () => void }): unknown; | Footer item; scope { item, active, expanded, select }. |
footer | footer?(props: { expanded: boolean }): unknown; | Additional footer; scope { expanded }. |
Pass-through: pt
Sections WlSidebar 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 | div.wl-sidebar-shell | Main element of the component. |
aside | aside.wl-sidebar | Sidebar surface; becomes a dialog while mobile navigation is open. |
inner | div.wl-sidebar__inner | Inner sidebar layout container. |
brand | div.wl-sidebar__brand | Brand name and mark area. |
brandMark | span.wl-sidebar__brand-mark | Compact visible brand mark. |
nav | nav.wl-sidebar__nav | Main sidebar navigation region. |
group | section.wl-sidebar__group | Group of related navigation items. |
divider | div.wl-sidebar__divider | Decorative separator before a sidebar group. |
groupLabel | div.wl-sidebar__group-label | Visible heading of a navigation group. |
item | button / a | One repeated item. |
footer | div.wl-sidebar__footer | Footer area below the main content. |
footerItem | button / a | One navigation item in the sidebar footer. |
pinButton | button / a | Button that pins or unpins the sidebar. |
backdrop | button.wl-sidebar__backdrop | Backdrop that closes the mobile surface. |
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
- AriaLabel names the navigation region; each item's label/ariaLabel persists in collapsed mode.
- V-model stores the active key; v-model:pinned and v-model:mobile-open control pinning and the mobile panel.
- The mobile panel traps focus and closes on Escape, backdrop interaction or selection. In a custom item slot, keep an accessible name and call scoped select.
Keyboard and application responsibilities
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 PracticesChanges are emitted through v-model. After selection, cancellation and reset, labels and states must remain clear.
In your application, check keyboard controls, zoom and focus visibility. State labels and required information must be readable in every theme.