Create

Layout

Sidebar

Experimental
Copy page View as Markdown Open in ChatGPT Open in Claude

A composable, themeable and collapsible side panel for app navigation.

Usage#

app.component.ts
import { 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 projectJane Doe[email protected]My accountAccountBillingNotificationsLog out
PlaygroundHistory

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
Home

Collapsible group#

Inside wds-collapsible-trigger, wds-sidebar-group-label becomes a button, and the group content in wds-collapsible-content expands smoothly. group-open: on the chevron follows the open attribute of wds-collapsible.

Help Documentation Contact Service status Account Profile Security Billing

wds-sidebar-menu-skeleton stands in for the items while the menu loads; show-icon adds an icon placeholder.

ReloadProjects

Second panel#

Nested wds-sidebar elements sit side by side. The first one with collapsible="icon" is a fixed bar of sections with tooltips, the second one lists the pages of the chosen section. The outer sidebar has collapsible="icon", so when collapsed only the bar stays, and a click on a section opens the panel again.

AAdminOrganizationsUsersSystemsSettingsSettingsGeneralGeneralAppearanceNotificationsAccess and identityGroupsRolesAPI tokens
SettingsGeneral

Controlled#

open and wds-open-change keep the state in the app, for example to remember it between visits; setting open does not fire the event. toggle() toggles it from code. --wds-sidebar-width, --wds-sidebar-width-icon and --wds-sidebar-width-mobile on the provider set the widths. shortcut="" turns off ⌘/Ctrl+B: on this page only the Default example has it.

Collapseopen: true
Width 20remHomeInboxCalendarSettings

API References#

wds-sidebar-provider#

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

AttributeTypeDefaultDescription
openbooleantrueExpanded sidebar on desktop. Setting it from outside does not fire wds-open-change.
open-mobile.openMobilebooleanfalseOpen panel on phones.
shortcutstring'b'Shortcut key used with ⌘ (macOS) or Ctrl. An empty string turns the shortcut off.

Events

EventDescription
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

MethodDescription
toggle()Toggles the sidebar: collapses or expands it on desktop, opens or closes the panel on phones.

Slots

SlotDescription
(default)wds-sidebar and wds-sidebar-inset (the page content).

CSS custom properties

PropertyDescription
--wds-sidebar-widthWidth of the expanded sidebar (default 16rem).
--wds-sidebar-width-iconWidth of the sidebar collapsed to icons (default 3rem).
--wds-sidebar-width-mobileWidth of the panel on phones (default 18rem).

wds-sidebar#

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

AttributeTypeDefaultDescription
sideWdsSidebarSide'left'Edge: left or right (a right sidebar goes after the content).
variantWdsSidebarVariant'sidebar'sidebar: at the edge; floating: a floating card; inset: the content as a card on the sidebar background.
collapsibleWdsSidebarCollapsible'offcanvas'Collapsed state: offcanvas (slides out), icon (icons only), none (always expanded).
labelstring'Panel boczny'Name of the panel on phones (aria-label of the dialog).

Slots

SlotDescription
(default)wds-sidebar-header, wds-sidebar-content, wds-sidebar-footer, wds-sidebar-rail or nested wds-sidebar elements.

CSS parts (::part)

PartDescription
containerContainer of the panel on desktop (sticks to the top of the window).
innerBackground of the panel with the content.
sheetThe <dialog> with the panel on phones.

wds-sidebar-header#

Top of the sidebar (such as a team switcher or a search field). Does not scroll.

Slots

SlotDescription
(default)Content.

CSS parts (::part)

PartDescription
baseColumn with padding around the content.

wds-sidebar-content#

Scrolling part of the sidebar with groups (wds-sidebar-group).

Slots

SlotDescription
(default)Groups.

Bottom of the sidebar (such as a user menu). Does not scroll.

Slots

SlotDescription
(default)Content.

CSS parts (::part)

PartDescription
baseColumn with padding around the content.

wds-sidebar-separator#

Horizontal line between sections of the sidebar.

CSS parts (::part)

PartDescription
baseThe line.

wds-sidebar-group#

Section of the sidebar: a label, an action and content (usually wds-sidebar-menu).

Slots

SlotDescription
(default)wds-sidebar-group-label, wds-sidebar-group-action, wds-sidebar-group-content.

CSS parts (::part)

PartDescription
baseColumn with padding around the content.

wds-sidebar-group-label#

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

SlotDescription
(default)Text and an optional <svg> icon (such as a chevron).

CSS parts (::part)

PartDescription
labelThe label (<div> or <button>).

wds-sidebar-group-action#

Button in the top right corner of a group (such as "Add project"). Hidden when the sidebar is collapsed to icons.

Attributes

AttributeTypeDefaultDescription
labelstring''Accessible name (required: the button shows only an icon).

Slots

SlotDescription
(default)An <svg> icon.

CSS parts (::part)

PartDescription
buttonThe native <button>.

wds-sidebar-group-content#

Content of a group.

Slots

SlotDescription
(default)Usually wds-sidebar-menu.

wds-sidebar-menu#

List of menu items (role="list").

Slots

SlotDescription
(default)wds-sidebar-menu-item.

wds-sidebar-menu-item#

Menu item (role="listitem"): a button, an action, a badge and a submenu.

Slots

SlotDescription
(default)wds-sidebar-menu-button, wds-sidebar-menu-action, wds-sidebar-menu-badge, wds-sidebar-menu-sub.

wds-sidebar-menu-button#

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

AttributeTypeDefaultDescription
activebooleanfalseMarks the current item; on a link it sets aria-current="page".
sizeWdsSidebarMenuButtonSize'default'Height: sm, default or lg (two lines of text, such as a name and an email).
variantWdsSidebarMenuButtonVariant'default'outline: with a background and a border.
disabledbooleanfalseDisables the item.
hrefstring | undefinedURL: the item renders as a link.
targetstring | undefinedLink target (such as _blank), used with href.
tooltipstring''Tooltip with the name, shown only when the sidebar is collapsed to icons.

Slots

SlotDescription
(default)An <svg> icon and text (a <span> is truncated with an ellipsis).

CSS parts (::part)

PartDescription
buttonThe native <button> or <a>.
tooltipTooltip bubble with the name in icon mode.

wds-sidebar-menu-action#

Icon button on the right of an item (such as "More" opening a wds-dropdown). Hidden when the sidebar is collapsed to icons.

Attributes

AttributeTypeDefaultDescription
labelstring''Accessible name (required: the button shows only an icon).
show-on-hover.showOnHoverbooleanfalseShown only when the item is hovered or focused.

Slots

SlotDescription
(default)An <svg> icon.

CSS parts (::part)

PartDescription
buttonThe native <button>.

wds-sidebar-menu-badge#

Counter on the right of an item (such as the number of unread messages). Hidden when the sidebar is collapsed to icons.

Slots

SlotDescription
(default)Text.

CSS parts (::part)

PartDescription
baseThe counter box.

wds-sidebar-menu-skeleton#

Placeholder item while the menu loads. Hidden from screen readers.

Attributes

AttributeTypeDefaultDescription
show-icon.showIconbooleanfalseAlso shows an icon placeholder.

CSS parts (::part)

PartDescription
baseRow with the icon and text placeholders.

wds-sidebar-menu-sub#

Submenu under an item (role="list") with a line on the left. Hidden when the sidebar is collapsed to icons.

Slots

SlotDescription
(default)wds-sidebar-menu-sub-item.

CSS parts (::part)

PartDescription
baseColumn with the line on the left.

wds-sidebar-menu-sub-item#

Submenu item (role="listitem").

Slots

SlotDescription
(default)wds-sidebar-menu-sub-button.

wds-sidebar-menu-sub-button#

Link or button in a submenu.

Attributes

AttributeTypeDefaultDescription
activebooleanfalseMarks the current item; on a link it sets aria-current="page".
sizeWdsSidebarMenuSubButtonSize'md'Text size: sm or md.
disabledbooleanfalseDisables the item.
hrefstring | undefinedURL: the item renders as a link.
targetstring | undefinedLink target (such as _blank), used with href.

Slots

SlotDescription
(default)Text (and an optional <svg> icon).

CSS parts (::part)

PartDescription
buttonThe native <a> or <button>.

wds-sidebar-trigger#

Button that toggles the sidebar of the closest wds-sidebar-provider (like ⌘/Ctrl+B).

Attributes

AttributeTypeDefaultDescription
labelstring'Przełącz panel boczny'Accessible name.

Slots

SlotDescription
(default)A custom icon instead of the default one.

CSS parts (::part)

PartDescription
buttonThe native <button>.

wds-sidebar-rail#

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

AttributeTypeDefaultDescription
labelstring'Przełącz panel boczny'Accessible name.

wds-sidebar-inset#

Page content next to the sidebar. With wds-sidebar variant="inset" it becomes a card on the sidebar background.

Slots

SlotDescription
(default)Content (a header with wds-sidebar-trigger, the page).

CSS parts (::part)

PartDescription
baseColumn 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#

KeyFunction
⌘ + BCtrl + BToggles the sidebar (shortcut changes the key; an empty string turns it off).
TabShift + TabMoves focus between the buttons of the sidebar, the trigger and the page.
EnterSpaceActivates the focused button or link, toggles a collapsible item or group, or opens its menu.
EscapeHides the tooltip of the focused button; on phones closes the panel.
Footer