Usage#
app.component.tsimport { WDS_SIDEBAR } from '@wds/angular/sidebar';Examples#
Default#
wds-sidebar-provider holds the state and the ⌘/Ctrl+B shortcut; wds-sidebar-inset is the page next to the sidebar. With collapsible="icon" only the icons stay, and tooltip shows the names. Toggle it with wds-sidebar-trigger, a click on the edge (wds-sidebar-rail) or the shortcut. Below 768 px the sidebar opens as a panel over the content. wds-sidebar-menu-button can be the trigger of wds-collapsible (submenus) and wds-dropdown (team switcher, user menu).
Acme IncEnterpriseTeamsAcme IncAcme Corp.Evil Corp.Add teamPlatformPlaygroundHistoryStarredSettingsModelsGenesisExplorerQuantumDocumentationIntroductionGet StartedTutorialsChangelogSettingsGeneralTeamBillingLimitsProjectsDesign EngineeringView projectShare projectDelete projectSales & MarketingView projectShare projectDelete projectTravelView projectShare projectDelete projectJDJane Doe[email protected]My accountAccountBillingNotificationsLog out Show code
sidebar-default.tsimport { Component, signal } from '@angular/core';
import { WDS_AVATAR } from '@wds/angular/avatar';
import { WDS_BREADCRUMB } from '@wds/angular/breadcrumb';
import { WDS_COLLAPSIBLE } from '@wds/angular/collapsible';
import { WDS_DROPDOWN } from '@wds/angular/dropdown';
import { WDS_SIDEBAR } from '@wds/angular/sidebar';
import { WdsIconComponent } from '@wds/angular/icon';
import '@wds/core/icons/lucide/audio-waveform';
import '@wds/core/icons/lucide/bell';
import '@wds/core/icons/lucide/book-open';
import '@wds/core/icons/lucide/bot';
import '@wds/core/icons/lucide/chart-pie';
import '@wds/core/icons/lucide/chevron-right';
import '@wds/core/icons/lucide/chevrons-up-down';
import '@wds/core/icons/lucide/command';
import '@wds/core/icons/lucide/credit-card';
import '@wds/core/icons/lucide/folder';
import '@wds/core/icons/lucide/forward';
import '@wds/core/icons/lucide/frame';
import '@wds/core/icons/lucide/gallery-vertical-end';
import '@wds/core/icons/lucide/log-out';
import '@wds/core/icons/lucide/map';
import '@wds/core/icons/lucide/more-horizontal';
import '@wds/core/icons/lucide/plus';
import '@wds/core/icons/lucide/settings';
import '@wds/core/icons/lucide/square-terminal';
import '@wds/core/icons/lucide/trash';
import '@wds/core/icons/lucide/user';
const TEAMS = [
{ name: 'Acme Inc', plan: 'Enterprise', icon: 'lucide-gallery-vertical-end' },
{ name: 'Acme Corp.', plan: 'Startup', icon: 'lucide-audio-waveform' },
{ name: 'Evil Corp.', plan: 'Free', icon: 'lucide-command' },
];
const NAV = [
{ title: 'Playground', icon: 'lucide-square-terminal', pages: ['History', 'Starred', 'Settings'] },
{ title: 'Models', icon: 'lucide-bot', pages: ['Genesis', 'Explorer', 'Quantum'] },
{ title: 'Documentation', icon: 'lucide-book-open', pages: ['Introduction', 'Get Started', 'Tutorials', 'Changelog'] },
{ title: 'Settings', icon: 'lucide-settings', pages: ['General', 'Team', 'Billing', 'Limits'] },
];
const PROJECTS = [
{ name: 'Design Engineering', icon: 'lucide-frame' },
{ name: 'Sales & Marketing', icon: 'lucide-chart-pie' },
{ name: 'Travel', icon: 'lucide-map' },
];
@Component({
selector: 'app-sidebar-default-demo',
host: { class: 'block w-full' },
imports: [WdsIconComponent, ...WDS_SIDEBAR, ...WDS_AVATAR, ...WDS_COLLAPSIBLE, ...WDS_DROPDOWN, ...WDS_BREADCRUMB],
template: `
<wds-sidebar-provider class="h-[600px] min-h-0 rounded-xl border border-border">
<wds-sidebar collapsible="icon">
<wds-sidebar-header>
<wds-sidebar-menu>
<wds-sidebar-menu-item>
<wds-dropdown class="block" style="--wds-dropdown-min-width: 14rem" (wdsSelect)="selectTeam($event.value)">
<wds-sidebar-menu-button slot="trigger" size="lg" [tooltip]="team().name">
<span class="flex size-8 flex-none items-center justify-center rounded-lg bg-sidebar-primary text-sidebar-primary-foreground">
<wds-icon [name]="team().icon" size="sm" />
</span>
<span class="grid flex-1 leading-tight">
<span class="truncate font-medium">{{ team().name }}</span>
<span class="truncate text-xs">{{ team().plan }}</span>
</span>
<wds-icon name="lucide-chevrons-up-down" size="sm" class="ml-auto" />
</wds-sidebar-menu-button>
<wds-dropdown-label>Teams</wds-dropdown-label>
@for (t of teams; track t.name) {
<wds-dropdown-item [value]="t.name" [iconStart]="t.icon">{{ t.name }}</wds-dropdown-item>
}
<wds-dropdown-separator />
<wds-dropdown-item value="add" icon-start="lucide-plus">Add team</wds-dropdown-item>
</wds-dropdown>
</wds-sidebar-menu-item>
</wds-sidebar-menu>
</wds-sidebar-header>
<wds-sidebar-content>
<wds-sidebar-group>
<wds-sidebar-group-label>Platform</wds-sidebar-group-label>
<wds-sidebar-menu>
@for (item of nav; track item.title) {
<wds-sidebar-menu-item>
<!-- group-open rotates the chevron while the collapsible is open -->
<wds-collapsible class="group" [open]="$first">
<wds-collapsible-trigger>
<wds-sidebar-menu-button [tooltip]="item.title" [iconStart]="item.icon">
<span>{{ item.title }}</span>
<wds-icon name="lucide-chevron-right" size="sm" class="ml-auto transition-transform duration-200 group-open:rotate-90" />
</wds-sidebar-menu-button>
</wds-collapsible-trigger>
<wds-collapsible-content>
<wds-sidebar-menu-sub>
@for (page of item.pages; track page) {
<wds-sidebar-menu-sub-item>
<wds-sidebar-menu-sub-button [active]="isActive(item.title, page)" (click)="open(item.title, page)">
<span>{{ page }}</span>
</wds-sidebar-menu-sub-button>
</wds-sidebar-menu-sub-item>
}
</wds-sidebar-menu-sub>
</wds-collapsible-content>
</wds-collapsible>
</wds-sidebar-menu-item>
}
</wds-sidebar-menu>
</wds-sidebar-group>
<wds-sidebar-group>
<wds-sidebar-group-label>Projects</wds-sidebar-group-label>
<wds-sidebar-group-action label="Add project"><wds-icon name="lucide-plus" size="sm" /></wds-sidebar-group-action>
<wds-sidebar-menu>
@for (project of projects; track project.name) {
<wds-sidebar-menu-item>
<wds-sidebar-menu-button [tooltip]="project.name" [active]="isActive('Projects', project.name)" (click)="open('Projects', project.name)" [iconStart]="project.icon">
<span>{{ project.name }}</span>
</wds-sidebar-menu-button>
<wds-dropdown align="start">
<wds-sidebar-menu-action slot="trigger" show-on-hover [label]="'More: ' + project.name">
<wds-icon name="lucide-more-horizontal" size="sm" />
</wds-sidebar-menu-action>
<wds-dropdown-item value="view" icon-start="lucide-folder">View project</wds-dropdown-item>
<wds-dropdown-item value="share" icon-start="lucide-forward">Share project</wds-dropdown-item>
<wds-dropdown-separator />
<wds-dropdown-item value="delete" variant="destructive" icon-start="lucide-trash">Delete project</wds-dropdown-item>
</wds-dropdown>
</wds-sidebar-menu-item>
}
</wds-sidebar-menu>
</wds-sidebar-group>
</wds-sidebar-content>
<wds-sidebar-footer>
<wds-sidebar-menu>
<wds-sidebar-menu-item>
<wds-dropdown class="block" side="top" style="--wds-dropdown-min-width: 14rem">
<wds-sidebar-menu-button slot="trigger" size="lg" tooltip="Jane Doe">
<wds-avatar class="[--wds-avatar-radius:var(--wds-radius-lg)]" aria-hidden="true">JD</wds-avatar>
<span class="grid flex-1 leading-tight">
<span class="truncate font-medium">Jane Doe</span>
<span class="truncate text-xs">jane@example.com</span>
</span>
<wds-icon name="lucide-chevrons-up-down" size="sm" class="ml-auto" />
</wds-sidebar-menu-button>
<wds-dropdown-label>My account</wds-dropdown-label>
<wds-dropdown-item value="account" icon-start="lucide-user">Account</wds-dropdown-item>
<wds-dropdown-item value="billing" icon-start="lucide-credit-card">Billing</wds-dropdown-item>
<wds-dropdown-item value="notifications" icon-start="lucide-bell">Notifications</wds-dropdown-item>
<wds-dropdown-separator />
<wds-dropdown-item value="logout" icon-start="lucide-log-out">Log out</wds-dropdown-item>
</wds-dropdown>
</wds-sidebar-menu-item>
</wds-sidebar-menu>
</wds-sidebar-footer>
<wds-sidebar-rail />
</wds-sidebar>
<wds-sidebar-inset>
<header class="box-border flex h-14 flex-none items-center gap-2 border-b border-border px-4">
<wds-sidebar-trigger class="-ml-1" />
<span class="mx-1 h-4 w-px bg-border"></span>
<wds-breadcrumb class="min-w-0" label="Breadcrumb" wrap="nowrap">
<wds-breadcrumb-item class="max-md:hidden">
<wds-breadcrumb-link (click)="openSection(active().section)">{{ active().section }}</wds-breadcrumb-link>
</wds-breadcrumb-item>
<wds-breadcrumb-item>
<wds-breadcrumb-page class="truncate">{{ active().page }}</wds-breadcrumb-page>
</wds-breadcrumb-item>
</wds-breadcrumb>
</header>
<div class="grid flex-1 grid-rows-[auto_1fr] gap-4 overflow-auto p-4">
<div class="grid grid-cols-3 gap-4">
<div class="aspect-video rounded-xl bg-muted"></div>
<div class="aspect-video rounded-xl bg-muted"></div>
<div class="aspect-video rounded-xl bg-muted"></div>
</div>
<div class="min-h-40 rounded-xl bg-muted"></div>
</div>
</wds-sidebar-inset>
</wds-sidebar-provider>
`,
})
export class SidebarDefaultDemo {
protected readonly teams = TEAMS;
protected readonly nav = NAV;
protected readonly projects = PROJECTS;
protected readonly team = signal(TEAMS[0]);
protected readonly active = signal({ section: 'Playground', page: 'History' });
protected selectTeam(name: string): void {
const team = TEAMS.find((t) => t.name === name);
if (team) this.team.set(team);
}
protected isActive(section: string, page: string): boolean {
const active = this.active();
return active.section === section && active.page === page;
}
protected open(section: string, page: string): void {
this.active.set({ section, page });
}
/** Breadcrumb link: the first page of the section. */
protected openSection(section: string): void {
this.open(section, NAV.find((item) => item.title === section)?.pages[0] ?? PROJECTS[0].name);
}
} Variants#
side sets the edge. variant: sidebar (at the edge), floating (a floating card) or inset (the content as a card). collapsible: offcanvas (slides out), icon (icons only) or none (always expanded). wds-sidebar-menu-badge adds a counter and variant="outline" a bordered button.
side: leftside: rightvariant: sidebarvariant: floatingvariant: insetcollapsible: offcanvascollapsible: iconcollapsible: none
ApplicationHomeInbox24CalendarSearchSettingsLog out Show code
sidebar-variants.tsimport { Component, signal } from '@angular/core';
import { WdsInputComponent } from '@wds/angular/input';
import { WDS_SELECT } from '@wds/angular/select';
import { WDS_SIDEBAR } from '@wds/angular/sidebar';
import type { WdsSidebarCollapsible, WdsSidebarSide, WdsSidebarVariant } from '@wds/core/sidebar';
import '@wds/core/icons/lucide/calendar';
import '@wds/core/icons/lucide/house';
import '@wds/core/icons/lucide/inbox';
import '@wds/core/icons/lucide/log-out';
import '@wds/core/icons/lucide/search';
import '@wds/core/icons/lucide/settings';
const ITEMS = [
{ title: 'Home', icon: 'lucide-house' },
{ title: 'Inbox', icon: 'lucide-inbox', badge: '24' },
{ title: 'Calendar', icon: 'lucide-calendar' },
{ title: 'Search', icon: 'lucide-search' },
{ title: 'Settings', icon: 'lucide-settings' },
];
@Component({
selector: 'app-sidebar-variants-demo',
host: { class: 'flex w-full flex-col gap-3' },
imports: [...WDS_SIDEBAR, ...WDS_SELECT, WdsInputComponent],
template: `
<div class="flex flex-wrap items-center gap-3">
<wds-select class="w-36" aria-label="Side" [value]="side()" (wdsChange)="side.set($any($event.value))">
<wds-select-item value="left">side: left</wds-select-item>
<wds-select-item value="right">side: right</wds-select-item>
</wds-select>
<wds-select class="w-44" aria-label="Variant" [value]="variant()" (wdsChange)="variant.set($any($event.value))">
<wds-select-item value="sidebar">variant: sidebar</wds-select-item>
<wds-select-item value="floating">variant: floating</wds-select-item>
<wds-select-item value="inset">variant: inset</wds-select-item>
</wds-select>
<wds-select class="w-52" aria-label="Collapsible" [value]="collapsible()" (wdsChange)="collapsible.set($any($event.value))">
<wds-select-item value="offcanvas">collapsible: offcanvas</wds-select-item>
<wds-select-item value="icon">collapsible: icon</wds-select-item>
<wds-select-item value="none">collapsible: none</wds-select-item>
</wds-select>
</div>
<!-- shortcut="" turns off ⌘/Ctrl+B: only one sidebar on a page should have it -->
<wds-sidebar-provider class="h-[420px] min-h-0 rounded-xl border border-border" shortcut="">
<wds-sidebar [side]="side()" [variant]="variant()" [collapsible]="collapsible()">
<wds-sidebar-header>
<wds-input class="w-full" type="search" placeholder="Search…" aria-label="Search the menu" />
</wds-sidebar-header>
<wds-sidebar-content>
<wds-sidebar-group>
<wds-sidebar-group-label>Application</wds-sidebar-group-label>
<wds-sidebar-group-content>
<wds-sidebar-menu>
@for (item of items; track item.title) {
<wds-sidebar-menu-item>
<wds-sidebar-menu-button [tooltip]="item.title" [active]="active() === item.title" (click)="active.set(item.title)" [iconStart]="item.icon">
<span>{{ item.title }}</span>
</wds-sidebar-menu-button>
@if (item.badge) {
<wds-sidebar-menu-badge>{{ item.badge }}</wds-sidebar-menu-badge>
}
</wds-sidebar-menu-item>
}
</wds-sidebar-menu>
</wds-sidebar-group-content>
</wds-sidebar-group>
</wds-sidebar-content>
<wds-sidebar-separator />
<wds-sidebar-footer>
<wds-sidebar-menu>
<wds-sidebar-menu-item>
<wds-sidebar-menu-button variant="outline" tooltip="Log out" icon-start="lucide-log-out"><span>Log out</span></wds-sidebar-menu-button>
</wds-sidebar-menu-item>
</wds-sidebar-menu>
</wds-sidebar-footer>
<wds-sidebar-rail />
</wds-sidebar>
<wds-sidebar-inset>
<header class="flex h-12 flex-none items-center gap-2 border-b border-border px-3" [class.flex-row-reverse]="side() === 'right'">
<wds-sidebar-trigger />
<span class="text-sm">{{ active() }}</span>
</header>
<div class="flex-1 p-4"><div class="h-full rounded-xl bg-muted"></div></div>
</wds-sidebar-inset>
</wds-sidebar-provider>
`,
})
export class SidebarVariantsDemo {
protected readonly items = ITEMS;
protected readonly side = signal<WdsSidebarSide>('left');
protected readonly variant = signal<WdsSidebarVariant>('sidebar');
protected readonly collapsible = signal<WdsSidebarCollapsible>('offcanvas');
protected readonly active = signal('Home');
} wds-sidebar-menu-skeleton stands in for the items while the menu loads; show-icon adds an icon placeholder.
sidebar-menu-skeleton.tsimport { Component, signal } from '@angular/core';
import { WdsButtonComponent } from '@wds/angular/button';
import { WDS_SIDEBAR } from '@wds/angular/sidebar';
import '@wds/core/icons/lucide/chart-pie';
import '@wds/core/icons/lucide/frame';
import '@wds/core/icons/lucide/map';
const PROJECTS = [
{ name: 'Design Engineering', icon: 'lucide-frame' },
{ name: 'Sales & Marketing', icon: 'lucide-chart-pie' },
{ name: 'Travel', icon: 'lucide-map' },
];
@Component({
selector: 'app-sidebar-menu-skeleton-demo',
host: { class: 'flex w-full flex-col items-start gap-3' },
imports: [...WDS_SIDEBAR, WdsButtonComponent],
template: `
<wds-button variant="outline" size="sm" (click)="load()">Reload</wds-button>
<wds-sidebar-provider class="h-[320px] min-h-0 rounded-xl border border-border" shortcut="">
<wds-sidebar collapsible="none">
<wds-sidebar-content>
<wds-sidebar-group>
<wds-sidebar-group-label>Projects</wds-sidebar-group-label>
<wds-sidebar-menu [attr.aria-busy]="loading() ? 'true' : null">
@if (loading()) {
@for (i of [1, 2, 3, 4, 5]; track i) {
<wds-sidebar-menu-item><wds-sidebar-menu-skeleton show-icon /></wds-sidebar-menu-item>
}
} @else {
@for (project of projects; track project.name) {
<wds-sidebar-menu-item>
<wds-sidebar-menu-button [iconStart]="project.icon"><span>{{ project.name }}</span></wds-sidebar-menu-button>
</wds-sidebar-menu-item>
}
}
</wds-sidebar-menu>
</wds-sidebar-group>
</wds-sidebar-content>
</wds-sidebar>
<wds-sidebar-inset><div class="m-4 flex-1 rounded-xl bg-muted"></div></wds-sidebar-inset>
</wds-sidebar-provider>
`,
})
export class SidebarMenuSkeletonDemo {
protected readonly projects = PROJECTS;
protected readonly loading = signal(true);
constructor() {
this.load();
}
/** Stands in for a request that takes 1.5 s. */
protected load(): void {
this.loading.set(true);
setTimeout(() => this.loading.set(false), 1500);
}
} Navigation rail#
Collapsed to icons, the sidebar is a rail of centered icons: --wds-sidebar-width-icon makes it wider than the default 3rem. The toggle sits in the footer next to the user and moves above the avatar when collapsed (group-data-[state=collapsed]: on the data-state of wds-sidebar). The search field (variant="outline") becomes a square button. On phones the page header has its own trigger.
sidebar-navigation-rail.tsimport { Component, signal } from '@angular/core';
import { WDS_AVATAR } from '@wds/angular/avatar';
import { WDS_BREADCRUMB } from '@wds/angular/breadcrumb';
import { WDS_DROPDOWN } from '@wds/angular/dropdown';
import { WDS_KBD } from '@wds/angular/kbd';
import { WDS_SIDEBAR } from '@wds/angular/sidebar';
import { WdsIconComponent } from '@wds/angular/icon';
import '@wds/core/icons/lucide/bell';
import '@wds/core/icons/lucide/braces';
import '@wds/core/icons/lucide/chevrons-up-down';
import '@wds/core/icons/lucide/gallery-vertical-end';
import '@wds/core/icons/lucide/git-branch';
import '@wds/core/icons/lucide/house';
import '@wds/core/icons/lucide/key';
import '@wds/core/icons/lucide/layout-grid';
import '@wds/core/icons/lucide/log-out';
import '@wds/core/icons/lucide/package';
import '@wds/core/icons/lucide/route';
import '@wds/core/icons/lucide/search';
import '@wds/core/icons/lucide/server';
import '@wds/core/icons/lucide/settings';
import '@wds/core/icons/lucide/square-terminal';
import '@wds/core/icons/lucide/tag';
import '@wds/core/icons/lucide/user';
import '@wds/core/icons/lucide/users';
const NAV = [
{
label: 'Workspace',
pages: [
{ title: 'Dashboard', icon: 'lucide-house' },
{ title: 'Projects', icon: 'lucide-layout-grid' },
{ title: 'Terminal', icon: 'lucide-square-terminal' },
],
},
{
label: 'Infrastructure',
pages: [
{ title: 'Servers', icon: 'lucide-server' },
{ title: 'Sources', icon: 'lucide-git-branch' },
{ title: 'Destinations', icon: 'lucide-route' },
{ title: 'Storage', icon: 'lucide-package' },
{ title: 'Shared variables', icon: 'lucide-braces' },
],
},
{
label: 'Manage',
pages: [
{ title: 'Team', icon: 'lucide-users' },
{ title: 'Notifications', icon: 'lucide-bell' },
{ title: 'Keys and tokens', icon: 'lucide-key' },
{ title: 'Tags', icon: 'lucide-tag' },
{ title: 'Settings', icon: 'lucide-settings' },
],
},
];
@Component({
selector: 'app-sidebar-navigation-rail-demo',
host: { class: 'block w-full' },
imports: [WdsIconComponent, ...WDS_SIDEBAR, ...WDS_AVATAR, ...WDS_BREADCRUMB, ...WDS_DROPDOWN, ...WDS_KBD],
template: `
<wds-sidebar-provider class="h-[600px] min-h-0 rounded-xl border border-border [--wds-sidebar-width-icon:3.5rem]" shortcut="">
<!-- group/sidebar: the footer reads the state (data-state) of the sidebar -->
<wds-sidebar class="group/sidebar" collapsible="icon">
<wds-sidebar-header>
<wds-sidebar-menu>
<wds-sidebar-menu-item>
<wds-sidebar-menu-button size="lg" tooltip="Acme" (click)="open('Workspace', 'Dashboard')">
<span class="flex size-8 flex-none items-center justify-center rounded-lg bg-sidebar-primary text-sidebar-primary-foreground">
<wds-icon name="lucide-gallery-vertical-end" size="sm" />
</span>
<span class="font-semibold">Acme</span>
<span class="text-xs text-muted-foreground">v2.4.0</span>
</wds-sidebar-menu-button>
</wds-sidebar-menu-item>
<wds-sidebar-menu-item>
<!-- collapsed, the outline button becomes a square with the icon -->
<wds-sidebar-menu-button variant="outline" tooltip="Search" icon-start="lucide-search">
<span class="text-muted-foreground">Search</span>
<wds-kbd class="ml-auto" aria-hidden="true">⌘K</wds-kbd>
</wds-sidebar-menu-button>
</wds-sidebar-menu-item>
</wds-sidebar-menu>
</wds-sidebar-header>
<wds-sidebar-content>
@for (group of nav; track group.label) {
<wds-sidebar-group>
<wds-sidebar-group-label>{{ group.label }}</wds-sidebar-group-label>
<wds-sidebar-menu>
@for (p of group.pages; track p.title) {
<wds-sidebar-menu-item>
<wds-sidebar-menu-button [tooltip]="p.title" [active]="active().page === p.title" (click)="open(group.label, p.title)" [iconStart]="p.icon">
<span>{{ p.title }}</span>
</wds-sidebar-menu-button>
</wds-sidebar-menu-item>
}
</wds-sidebar-menu>
</wds-sidebar-group>
}
</wds-sidebar-content>
<wds-sidebar-footer>
<!-- expanded: the user and the toggle in one row; collapsed: the toggle above the avatar -->
<div class="flex items-center gap-2 group-data-[state=collapsed]/sidebar:flex-col-reverse">
<wds-sidebar-menu class="min-w-0 flex-1">
<wds-sidebar-menu-item>
<wds-dropdown class="block" side="top" style="--wds-dropdown-min-width: 14rem">
<wds-sidebar-menu-button slot="trigger" size="lg" tooltip="Jane Doe">
<wds-avatar aria-hidden="true">JD</wds-avatar>
<span class="grid flex-1 leading-tight">
<span class="truncate font-medium">Jane Doe</span>
<span class="truncate text-xs">jane@example.com</span>
</span>
<wds-icon name="lucide-chevrons-up-down" size="sm" class="ml-auto" />
</wds-sidebar-menu-button>
<wds-dropdown-label>My account</wds-dropdown-label>
<wds-dropdown-item value="account" icon-start="lucide-user">Account</wds-dropdown-item>
<wds-dropdown-item value="notifications" icon-start="lucide-bell">Notifications</wds-dropdown-item>
<wds-dropdown-separator />
<wds-dropdown-item value="logout" icon-start="lucide-log-out">Log out</wds-dropdown-item>
</wds-dropdown>
</wds-sidebar-menu-item>
</wds-sidebar-menu>
<wds-sidebar-trigger class="max-md:hidden [&::part(button)]:size-8" />
</div>
</wds-sidebar-footer>
<wds-sidebar-rail />
</wds-sidebar>
<wds-sidebar-inset>
<header class="box-border flex h-14 flex-none items-center gap-2 border-b border-border px-4">
<!-- on phones the sidebar is a panel, so it needs a trigger in the page -->
<wds-sidebar-trigger class="-ml-1 md:hidden" />
<wds-breadcrumb class="min-w-0" label="Breadcrumb" wrap="nowrap">
<wds-breadcrumb-item class="max-md:hidden">{{ active().group }}</wds-breadcrumb-item>
<wds-breadcrumb-item>
<wds-breadcrumb-page class="truncate">{{ active().page }}</wds-breadcrumb-page>
</wds-breadcrumb-item>
</wds-breadcrumb>
</header>
<div class="flex-1 overflow-auto p-4"><div class="h-full min-h-40 rounded-xl bg-muted"></div></div>
</wds-sidebar-inset>
</wds-sidebar-provider>
`,
})
export class SidebarNavigationRailDemo {
protected readonly nav = NAV;
protected readonly active = signal({ group: 'Workspace', page: 'Projects' });
protected open(group: string, page: string): void {
this.active.set({ group, page });
}
} Second panel#
The sidebar from Navigation rail next to a second panel with the pages of the opened resource. The panel is a wds-sidebar collapsible="none" in wds-sidebar-inset, so it stays when the main sidebar collapses to icons; on phones it is hidden. For an icon bar and a panel that collapse together, nest wds-sidebar elements in one collapsible="icon" sidebar: a nested collapsible="icon" one is always the icon bar.
sidebar-second-panel.tsimport { Component, signal } from '@angular/core';
import { WDS_AVATAR } from '@wds/angular/avatar';
import { WDS_BREADCRUMB } from '@wds/angular/breadcrumb';
import { WDS_DROPDOWN } from '@wds/angular/dropdown';
import { WDS_KBD } from '@wds/angular/kbd';
import { WDS_SIDEBAR } from '@wds/angular/sidebar';
import { WdsIconComponent } from '@wds/angular/icon';
import '@wds/core/icons/lucide/activity';
import '@wds/core/icons/lucide/braces';
import '@wds/core/icons/lucide/chevrons-up-down';
import '@wds/core/icons/lucide/database';
import '@wds/core/icons/lucide/gallery-vertical-end';
import '@wds/core/icons/lucide/git-branch';
import '@wds/core/icons/lucide/house';
import '@wds/core/icons/lucide/layout-grid';
import '@wds/core/icons/lucide/life-buoy';
import '@wds/core/icons/lucide/list';
import '@wds/core/icons/lucide/log-out';
import '@wds/core/icons/lucide/package';
import '@wds/core/icons/lucide/search';
import '@wds/core/icons/lucide/send';
import '@wds/core/icons/lucide/server';
import '@wds/core/icons/lucide/settings';
import '@wds/core/icons/lucide/square-terminal';
import '@wds/core/icons/lucide/user';
import '@wds/core/icons/lucide/users';
interface Page {
title: string;
icon: string;
pages?: string[];
}
const NAV = [
{
label: 'Workspace',
pages: [
{ title: 'Dashboard', icon: 'lucide-house' },
{ title: 'Projects', icon: 'lucide-layout-grid' },
{ title: 'Terminal', icon: 'lucide-square-terminal' },
],
},
{
label: 'Infrastructure',
pages: [
{ title: 'Servers', icon: 'lucide-server' },
{ title: 'Sources', icon: 'lucide-git-branch' },
{ title: 'Storage', icon: 'lucide-package' },
],
},
{
label: 'Manage',
pages: [
{ title: 'Team', icon: 'lucide-users' },
{ title: 'Settings', icon: 'lucide-settings' },
],
},
];
/** Pages of the opened resource (a database). */
const PANEL: { label: string; pages: Page[] }[] = [
{
label: 'Settings',
pages: [
{
title: 'General',
icon: 'lucide-settings',
pages: ['Database details', 'Credentials', 'Runtime and network', 'Public access', 'Configuration'],
},
{ title: 'Environment variables', icon: 'lucide-braces' },
{ title: 'Persistent storage', icon: 'lucide-package' },
{ title: 'Healthcheck', icon: 'lucide-life-buoy' },
],
},
{
label: 'Observe',
pages: [
{ title: 'Runtime logs', icon: 'lucide-list' },
{ title: 'Terminal', icon: 'lucide-square-terminal' },
{ title: 'Metrics', icon: 'lucide-activity' },
],
},
{
label: 'Automation',
pages: [
{ title: 'Webhooks', icon: 'lucide-send' },
{ title: 'Backups', icon: 'lucide-database' },
],
},
];
@Component({
selector: 'app-sidebar-second-panel-demo',
host: { class: 'block w-full' },
imports: [WdsIconComponent, ...WDS_SIDEBAR, ...WDS_AVATAR, ...WDS_BREADCRUMB, ...WDS_DROPDOWN, ...WDS_KBD],
template: `
<wds-sidebar-provider class="h-[600px] min-h-0 rounded-xl border border-border [--wds-sidebar-width-icon:3.5rem]" shortcut="">
<!-- main sidebar: collapses to a rail of icons -->
<wds-sidebar class="group/sidebar" collapsible="icon">
<wds-sidebar-header>
<wds-sidebar-menu>
<wds-sidebar-menu-item>
<wds-sidebar-menu-button size="lg" tooltip="Acme">
<span class="flex size-8 flex-none items-center justify-center rounded-lg bg-sidebar-primary text-sidebar-primary-foreground">
<wds-icon name="lucide-gallery-vertical-end" size="sm" />
</span>
<span class="font-semibold">Acme</span>
<span class="text-xs text-muted-foreground">v2.4.0</span>
</wds-sidebar-menu-button>
</wds-sidebar-menu-item>
<wds-sidebar-menu-item>
<wds-sidebar-menu-button variant="outline" tooltip="Search" icon-start="lucide-search">
<span class="text-muted-foreground">Search</span>
<wds-kbd class="ml-auto" aria-hidden="true">⌘K</wds-kbd>
</wds-sidebar-menu-button>
</wds-sidebar-menu-item>
</wds-sidebar-menu>
</wds-sidebar-header>
<wds-sidebar-content>
@for (group of nav; track group.label) {
<wds-sidebar-group>
<wds-sidebar-group-label>{{ group.label }}</wds-sidebar-group-label>
<wds-sidebar-menu>
@for (p of group.pages; track p.title) {
<wds-sidebar-menu-item>
<wds-sidebar-menu-button [tooltip]="p.title" [active]="p.title === 'Projects'" [iconStart]="p.icon">
<span>{{ p.title }}</span>
</wds-sidebar-menu-button>
</wds-sidebar-menu-item>
}
</wds-sidebar-menu>
</wds-sidebar-group>
}
</wds-sidebar-content>
<wds-sidebar-footer>
<div class="flex items-center gap-2 group-data-[state=collapsed]/sidebar:flex-col-reverse">
<wds-sidebar-menu class="min-w-0 flex-1">
<wds-sidebar-menu-item>
<wds-dropdown class="block" side="top" style="--wds-dropdown-min-width: 14rem">
<wds-sidebar-menu-button slot="trigger" size="lg" tooltip="Jane Doe">
<wds-avatar aria-hidden="true">JD</wds-avatar>
<span class="grid flex-1 leading-tight">
<span class="truncate font-medium">Jane Doe</span>
<span class="truncate text-xs">jane@example.com</span>
</span>
<wds-icon name="lucide-chevrons-up-down" size="sm" class="ml-auto" />
</wds-sidebar-menu-button>
<wds-dropdown-label>My account</wds-dropdown-label>
<wds-dropdown-item value="account" icon-start="lucide-user">Account</wds-dropdown-item>
<wds-dropdown-separator />
<wds-dropdown-item value="logout" icon-start="lucide-log-out">Log out</wds-dropdown-item>
</wds-dropdown>
</wds-sidebar-menu-item>
</wds-sidebar-menu>
<wds-sidebar-trigger class="max-md:hidden [&::part(button)]:size-8" />
</div>
</wds-sidebar-footer>
<wds-sidebar-rail />
</wds-sidebar>
<wds-sidebar-inset>
<header class="box-border flex h-14 flex-none items-center gap-2 border-b border-border px-4">
<wds-sidebar-trigger class="-ml-1 md:hidden" />
<wds-breadcrumb class="min-w-0" label="Breadcrumb" wrap="nowrap">
<wds-breadcrumb-item class="max-md:hidden">Projects</wds-breadcrumb-item>
<wds-breadcrumb-item class="max-md:hidden">postgres</wds-breadcrumb-item>
<wds-breadcrumb-item>
<wds-breadcrumb-page class="truncate">{{ page() }}</wds-breadcrumb-page>
</wds-breadcrumb-item>
</wds-breadcrumb>
</header>
<div class="flex min-h-0 flex-1">
<!-- second panel: pages of the resource on the page background; it stays when the main sidebar collapses -->
<wds-sidebar class="max-md:hidden [--wds-sidebar-width:15rem] [&::part(inner)]:bg-background" collapsible="none" label="postgres">
<wds-sidebar-content>
@for (group of panel; track group.label) {
@if (!$first) {
<wds-sidebar-separator />
}
<wds-sidebar-group>
<wds-sidebar-group-label>{{ group.label }}</wds-sidebar-group-label>
<wds-sidebar-menu>
@for (p of group.pages; track p.title) {
<wds-sidebar-menu-item>
<wds-sidebar-menu-button [active]="page() === p.title" (click)="page.set(p.title)" [iconStart]="p.icon">
<span>{{ p.title }}</span>
</wds-sidebar-menu-button>
@if (p.pages) {
<wds-sidebar-menu-sub>
@for (sub of p.pages; track sub) {
<wds-sidebar-menu-sub-item>
<wds-sidebar-menu-sub-button [active]="page() === sub" (click)="page.set(sub)">
<span>{{ sub }}</span>
</wds-sidebar-menu-sub-button>
</wds-sidebar-menu-sub-item>
}
</wds-sidebar-menu-sub>
}
</wds-sidebar-menu-item>
}
</wds-sidebar-menu>
</wds-sidebar-group>
}
</wds-sidebar-content>
</wds-sidebar>
<div class="min-w-0 flex-1 overflow-auto p-4"><div class="h-full min-h-40 rounded-xl bg-muted"></div></div>
</div>
</wds-sidebar-inset>
</wds-sidebar-provider>
`,
})
export class SidebarSecondPanelDemo {
protected readonly nav = NAV;
protected readonly panel = PANEL;
protected readonly page = signal('General');
} API References#
Page layout with a sidebar. Holds the state (open on desktop, open-mobile on phones),
handles the ⌘/Ctrl+B shortcut and passes the state to the wds-sidebar, wds-sidebar-inset and
wds-sidebar-trigger inside it.
Attributes
| Attribute | Type | Default | Description |
|---|
| open | boolean | true | Expanded sidebar on desktop. Setting it from outside does not fire wds-open-change. |
| open-mobile.openMobile | boolean | false | Open panel on phones. |
| shortcut | string | 'b' | Shortcut key used with ⌘ (macOS) or Ctrl. An empty string turns the shortcut off. |
Events
| Event | Description |
|---|
| wds-open-changeCustomEvent<WdsSidebarOpenChangeDetail> | Expanded or collapsed on desktop (trigger, rail, shortcut, toggle()). |
| wds-open-mobile-changeCustomEvent<WdsSidebarOpenChangeDetail> | The panel opened or closed on a phone. |
Methods
| Method | Description |
|---|
| toggle() | Toggles the sidebar: collapses or expands it on desktop, opens or closes the panel on phones. |
Slots
| Slot | Description |
|---|
| (default) | wds-sidebar and wds-sidebar-inset (the page content). |
CSS custom properties
| Property | Description |
|---|
| --wds-sidebar-width | Width of the expanded sidebar (default 16rem). |
| --wds-sidebar-width-icon | Width of the sidebar collapsed to icons (default 3rem); the icons stay centered. |
| --wds-sidebar-width-mobile | Width of the panel on phones (default 18rem). |
Side panel of the app. It takes its state from wds-sidebar-provider:
on desktop it collapses (collapsible), on phones it opens as a panel over the content.
Nested wds-sidebar elements sit side by side (a sidebar with a second panel):
a nested collapsible="icon" is a fixed icon bar with tooltips, and the others fill the rest.
The outer collapsible="icon" leaves only the icon bar when collapsed.
Attributes
| Attribute | Type | Default | Description |
|---|
| side | WdsSidebarSide | 'left' | Edge: left or right (a right sidebar goes after the content). |
| variant | WdsSidebarVariant | 'sidebar' | sidebar: at the edge; floating: a floating card; inset: the content as a card on the sidebar background. |
| collapsible | WdsSidebarCollapsible | 'offcanvas' | Collapsed state: offcanvas (slides out), icon (icons only), none (always expanded). |
| label | string | '' | Name of the panel on phones (aria-label of the dialog). Empty: built-in text (sidebar.label). |
Slots
| Slot | Description |
|---|
| (default) | wds-sidebar-header, wds-sidebar-content, wds-sidebar-footer, wds-sidebar-rail or nested wds-sidebar elements. |
CSS parts (::part)
| Part | Description |
|---|
| container | Container of the panel on desktop (sticks to the top of the window). |
| inner | Background of the panel with the content. |
| sheet | The <dialog> with the panel on phones. |
Top of the sidebar (such as a team switcher or a search field). Does not scroll.
Slots
| Slot | Description |
|---|
| (default) | Content. |
CSS parts (::part)
| Part | Description |
|---|
| base | Column with padding around the content. |
Scrolling part of the sidebar with groups (wds-sidebar-group).
Slots
| Slot | Description |
|---|
| (default) | Groups. |
Bottom of the sidebar (such as a user menu). Does not scroll.
Slots
| Slot | Description |
|---|
| (default) | Content. |
CSS parts (::part)
| Part | Description |
|---|
| base | Column with padding around the content. |
Horizontal line between sections of the sidebar.
CSS parts (::part)
| Part | Description |
|---|
| base | The line. |
Section of the sidebar: a label, an action and content (usually wds-sidebar-menu).
Slots
| Slot | Description |
|---|
| (default) | wds-sidebar-group-label, wds-sidebar-group-action, wds-sidebar-group-content. |
CSS parts (::part)
| Part | Description |
|---|
| base | Column with padding around the content. |
Group heading. Inside wds-collapsible-trigger it renders as a button that expands the group
(it gets aria-expanded from wds-collapsible). Hidden when the sidebar is collapsed to icons.
Slots
| Slot | Description |
|---|
| (default) | Text and an optional <svg> icon (such as a chevron). |
CSS parts (::part)
| Part | Description |
|---|
| label | The label (<div> or <button>). |
Button in the top right corner of a group (such as "Add project"). Hidden when the sidebar is collapsed to icons.
Attributes
| Attribute | Type | Default | Description |
|---|
| label | string | '' | Accessible name (required: the button shows only an icon). |
Slots
| Slot | Description |
|---|
| (default) | An <svg> icon. |
CSS parts (::part)
| Part | Description |
|---|
| button | The native <button>. |
Content of a group.
Slots
| Slot | Description |
|---|
| (default) | Usually wds-sidebar-menu. |
List of menu items (role="list").
Slots
| Slot | Description |
|---|
| (default) | wds-sidebar-menu-item. |
Menu item (role="listitem"): a button, an action, a badge and a submenu.
Slots
| Slot | Description |
|---|
| (default) | wds-sidebar-menu-button, wds-sidebar-menu-action, wds-sidebar-menu-badge, wds-sidebar-menu-sub. |
Sidebar menu entry. Renders a native <button>, or a native <a> with href.
When the sidebar is collapsed to icons, only the icon stays and tooltip shows the name (a wds-tooltip).
aria-expanded, aria-haspopup and aria-label on the host go to the native element,
so the button can be the trigger of wds-collapsible and wds-dropdown.
Attributes
| Attribute | Type | Default | Description |
|---|
| active | boolean | false | Marks the current item; on a link it sets aria-current="page". |
| size | WdsSidebarMenuButtonSize | 'default' | Height: sm, default or lg (two lines of text, such as a name and an email). |
| variant | WdsSidebarMenuButtonVariant | 'default' | outline: with a background and a border. |
| disabled | boolean | false | Disables the item. |
| href | string | undefined | | URL: the item renders as a link. |
| target | string | undefined | | Link target (such as _blank), used with href. |
| tooltip | string | '' | Tooltip with the name, shown only when the sidebar is collapsed to icons. |
| icon-start.iconStart | string | undefined | | Icon before the content: the name of a registered icon, e.g. lucide-house (after import '@wds/core/icons/lucide/house'). |
| icon-end.iconEnd | string | undefined | | Icon after the content: the name of a registered icon. |
Slots
| Slot | Description |
|---|
| (default) | Text (a <span> is truncated with an ellipsis), or your own <svg> or <wds-icon> instead of icon-start. |
CSS parts (::part)
| Part | Description |
|---|
| icon-start | The icon before the content (icon-start); in a sidebar collapsed to icons it is all that shows. |
| icon-end | The icon after the content (icon-end). |
| button | The native <button> or <a>. |
| tooltip | Tooltip bubble with the name in icon mode. |
Icon button on the right of an item (such as "More" opening a wds-dropdown).
Hidden when the sidebar is collapsed to icons.
Attributes
| Attribute | Type | Default | Description |
|---|
| label | string | '' | Accessible name (required: the button shows only an icon). |
| show-on-hover.showOnHover | boolean | false | Shown only when the item is hovered or focused. |
Slots
| Slot | Description |
|---|
| (default) | An <svg> icon. |
CSS parts (::part)
| Part | Description |
|---|
| button | The native <button>. |
Counter on the right of an item (such as the number of unread messages). Hidden when the sidebar is collapsed to icons.
Slots
| Slot | Description |
|---|
| (default) | Text. |
CSS parts (::part)
| Part | Description |
|---|
| base | The counter box. |
Placeholder item while the menu loads. Hidden from screen readers.
Attributes
| Attribute | Type | Default | Description |
|---|
| show-icon.showIcon | boolean | false | Also shows an icon placeholder. |
CSS parts (::part)
| Part | Description |
|---|
| base | Row with the icon and text placeholders. |
Submenu under an item (role="list") with a line on the left. Hidden when the sidebar is collapsed to icons.
Slots
| Slot | Description |
|---|
| (default) | wds-sidebar-menu-sub-item. |
CSS parts (::part)
| Part | Description |
|---|
| base | Column with the line on the left. |
Submenu item (role="listitem").
Slots
| Slot | Description |
|---|
| (default) | wds-sidebar-menu-sub-button. |
Link or button in a submenu.
Attributes
| Attribute | Type | Default | Description |
|---|
| active | boolean | false | Marks the current item; on a link it sets aria-current="page". |
| size | WdsSidebarMenuSubButtonSize | 'md' | Text size: sm or md. |
| disabled | boolean | false | Disables the item. |
| href | string | undefined | | URL: the item renders as a link. |
| target | string | undefined | | Link target (such as _blank), used with href. |
Slots
| Slot | Description |
|---|
| (default) | Text (and an optional <svg> icon). |
CSS parts (::part)
| Part | Description |
|---|
| button | The native <a> or <button>. |
Button that toggles the sidebar of the closest wds-sidebar-provider (like ⌘/Ctrl+B).
Attributes
| Attribute | Type | Default | Description |
|---|
| label | string | '' | Accessible name. Empty: built-in text (sidebar.toggle). |
Slots
| Slot | Description |
|---|
| (default) | A custom icon instead of the default one. |
CSS parts (::part)
| Part | Description |
|---|
| button | The native <button>. |
Thin strip on the edge of the sidebar: a click toggles the sidebar. Put it as the last child of wds-sidebar.
Not in the Tab order (keyboard users have the trigger and the shortcut).
Attributes
| Attribute | Type | Default | Description |
|---|
| label | string | '' | Accessible name. Empty: built-in text (sidebar.toggle). |
Page content next to the sidebar. With wds-sidebar variant="inset" it becomes a card on the sidebar background.
Slots
| Slot | Description |
|---|
| (default) | Content (a header with wds-sidebar-trigger, the page). |
CSS parts (::part)
| Part | Description |
|---|
| base | Column with the page background; with variant="inset" a card with a margin and a shadow. |
Accessibility#
Screen reader#
wds-sidebar has no landmark role. When it holds the main navigation of the app, put the menus in a <nav> with an aria-label.
wds-sidebar-menu and wds-sidebar-menu-sub are lists (role="list") and their items list items. wds-sidebar-menu-button and wds-sidebar-menu-sub-button render a native <button>, or an <a> with href; active on a link sets aria-current="page".
Collapsed to icons, the text of a button is clipped but stays its accessible name; the tooltip is only visual (aria-hidden).
wds-sidebar-trigger has aria-expanded and the name from label (default Przełącz panel boczny, in Polish). wds-sidebar-rail is not in the Tab order. Icon-only buttons (wds-sidebar-group-action, wds-sidebar-menu-action) need a label.
Below 768 px the sidebar opens as a modal <dialog> named by label: the rest of the page is inert and focus stays inside. wds-sidebar-menu-skeleton is hidden from screen readers; set aria-busy on the menu while it loads.
Keyboard support#
| Key | Function |
|---|
| ⌘ + BCtrl + B | Toggles the sidebar (shortcut changes the key; an empty string turns it off). |
| TabShift + Tab | Moves focus between the buttons of the sidebar, the trigger and the page. |
| EnterSpace | Activates the focused button or link, toggles a collapsible item or group, or opens its menu. |
| Escape | Hides the tooltip of the focused button; on phones closes the panel. |