Sidebar

The Sidebar is twelve squares wide. Each row is one square high, with half a square of indentation per level. Labels use regular text; counts and supporting information use small text. Disclosure arrows follow their labels. Selection fills the whole row with 2px corners, scaled with the surface.

A sidebar is navigation: the places of an application, every row a link or a button of its own and a stop for Tab, the current destination the page being shown.

An exhibition index

Icons, nested labels and counts share compact navigation rows.

Compact document navigation

Open a section, choose a document, or navigate with the arrow keys.

Set the items property to an array of visible rows. Each row has a unique id and a label; optional fields are depth, href, expanded, current, disabled, icon (a name from the icon library), detail (small muted words just after the label, such as a version), meta (small muted words at the row’s end, such as a count), and action: { id, label }. Omit expanded for a leaf. Collapsed children must be omitted from the array.

The application owns the hierarchy, filtering, selected destination and saved expansion state. The Unit owns the row layout, disclosure controls, focus and keyboard navigation. Supply a label for the navigation landmark and empty for its empty state. The header and footer slots hold optional search and supporting controls. When the host has a constrained height, only the navigation rows scroll; header and footer controls stay visible.

EventDetailApplication response
sidebar-activate{ id }Cancel with preventDefault() to handle routing or guard unsaved changes.
sidebar-toggle{ id, expanded }Update the visible items if expansion is accepted.
sidebar-action{ id, action }Run the independent trailing action.

Links retain their native destinations, context menus and modified clicks. Buttons support Enter and Space. Up and Down move between available rows; Home and End move to the first and last. Right expands a closed section or enters its children; Left collapses an open section or moves to its parent. Tab also reaches disclosure and trailing actions.

A label too long for its row fades out over its last square, never an ellipsis, and shows in full in the shared tooltip on hover or focus; a label that fits has none, and no row carries the browser’s title. The Sidebar loads the tooltip module itself.

expand-icon and collapse-icon name the icons of a closed and an open row, such as chevron-down and chevron-up.

Call focusItem(id) after updateComplete to focus a row, or scrollToCurrent() to reveal the current destination. --ds-sf scales the width, rows, text, icons and indentation. A containing layout may set the host width to another whole number of squares.

The rows’ fills and the current row’s weight are the shared row tokens (--ds-row-fill-hover, --ds-row-fill-current, --ds-row-current-weight), so a navigation row and the sidebar’s current row look the same.

narrow is the navigation for an application’s few places beside its work: eight squares wide instead of twelve, every row hugging its words. The pointer’s fill and the current row’s fill wrap the label, its count and its disclosure, 4px either side, rather than running across the column, so a short list of places reads as words on the paper. Rows stay one square apart and half a square further in per level, with the same keyboard and events as the wider navigation. Use it in ds-page’s navigation area with --ds-page-nav set to eight squares, so the work starts two squares after it:

<code><span class="line"><span style="color:var(--docs-code-ink)"><</span><span style="color:var(--docs-code-tag)">ds-page</span><span style="color:var(--docs-code-keyword)"> layout</span><span style="color:var(--docs-code-ink)">=</span><span style="color:var(--docs-code-string)">"sidebar"</span><span style="color:var(--docs-code-keyword)"> divided</span><span style="color:var(--docs-code-keyword)"> fill</span><span style="color:var(--docs-code-keyword)"> drawer</span><span style="color:var(--docs-code-keyword)"> style</span><span style="color:var(--docs-code-ink)">=</span><span style="color:var(--docs-code-string)">"--ds-page-nav: calc(8 * var(--ds-unit))"</span><span style="color:var(--docs-code-ink)">></span></span><span class="line"><span style="color:var(--docs-code-ink)">  <</span><span style="color:var(--docs-code-tag)">ds-sidebar</span><span style="color:var(--docs-code-keyword)"> slot</span><span style="color:var(--docs-code-ink)">=</span><span style="color:var(--docs-code-string)">"nav"</span><span style="color:var(--docs-code-keyword)"> narrow</span><span style="color:var(--docs-code-keyword)"> label</span><span style="color:var(--docs-code-ink)">=</span><span style="color:var(--docs-code-string)">"Application"</span><span style="color:var(--docs-code-ink)">></</span><span style="color:var(--docs-code-tag)">ds-sidebar</span><span style="color:var(--docs-code-ink)">></span></span><span class="line"><span style="color:var(--docs-code-ink)">  <</span><span style="color:var(--docs-code-tag)">main</span><span style="color:var(--docs-code-ink)">>…</</span><span style="color:var(--docs-code-tag)">main</span><span style="color:var(--docs-code-ink)">></span></span><span class="line"><span style="color:var(--docs-code-ink)"></</span><span style="color:var(--docs-code-tag)">ds-page</span><span style="color:var(--docs-code-ink)">></span></span></code>

A place that has things of its own (documents, apps) can list them as deeper rows under its own row.

CMS sidebar

Open the sidebar from the rail. The account stays in view while the links scroll.

Use variant="cms" for a workspace with its identity at the top, destinations in the scrollable middle, and supporting links and the signed-in account pinned below. The sidebar sits beside the workspace from edge to edge. ds-page[sidebar-rail] leaves a small vertical rail for reopening the sidebar and uses the page drawer on a narrow screen.

Place the workspace link in header, navigation links and disclosure groups in the default slot, site links in footer, and the account link in account. The slots accept native links, buttons and details. The host owns the destination, access rules and persisted state.

Load @0001-labs/design-system-1/ds1/3-unit/styles/cms-sidebar.css for the slotted content. Mark links with data-sidebar-row, their labels with data-sidebar-label, an account initial with data-sidebar-avatar, and thumbnail links with data-sidebar-site. The current destination uses aria-current="page".

The sidebar opens and closes with a button that retains focus. Synchronize ds-page[sidebar-collapsed] with the sidebar’s collapsed property using the bubbling sidebar-collapse event, whose detail is { collapsed }. Omit collapsed when drawing the open sidebar in the narrow-screen drawer. Set expand-label and collapse-label when translating the button.

For a workspace that exposes a bar when the sidebar is closed, place the bar in the page’s header slot. Hide the sidebar and reveal the header on desktop when collapsed. In narrow layouts, add sidebar-topbar to position the drawer button next to the header. Move focus to the header’s open button on collapse and use focusToggle() on the sidebar after reopening.

The native link or button covers the whole navigation row, including its empty space. Its text, indentation and disclosure stay in the same place. A section with no href toggles when pressed anywhere; a linked section still navigates and has a separate disclosure button. Optional actions remain independent of both.

An icon action uses the same action event and keeps its accessible label:

<code><span class="line"><span style="color:var(--docs-code-ink)">sidebar.items </span><span style="color:var(--docs-code-keyword)">=</span><span style="color:var(--docs-code-ink)"> [</span></span><span class="line"><span style="color:var(--docs-code-ink)">  { id: </span><span style="color:var(--docs-code-string)">"pages"</span><span style="color:var(--docs-code-ink)">, label: </span><span style="color:var(--docs-code-string)">"Pages"</span><span style="color:var(--docs-code-ink)">, expanded: </span><span style="color:var(--docs-code-number)">true</span><span style="color:var(--docs-code-ink)">,</span></span><span class="line"><span style="color:var(--docs-code-ink)">    action: { id: </span><span style="color:var(--docs-code-string)">"create"</span><span style="color:var(--docs-code-ink)">, label: </span><span style="color:var(--docs-code-string)">"Add page"</span><span style="color:var(--docs-code-ink)">, icon: </span><span style="color:var(--docs-code-string)">"plus"</span><span style="color:var(--docs-code-ink)"> } },</span></span><span class="line"><span style="color:var(--docs-code-ink)">  { id: </span><span style="color:var(--docs-code-string)">"intro"</span><span style="color:var(--docs-code-ink)">, label: </span><span style="color:var(--docs-code-string)">"Introduction"</span><span style="color:var(--docs-code-ink)">, depth: </span><span style="color:var(--docs-code-number)">1</span><span style="color:var(--docs-code-ink)">, href: </span><span style="color:var(--docs-code-string)">"/intro"</span><span style="color:var(--docs-code-ink)"> },</span></span><span class="line"><span style="color:var(--docs-code-ink)">];</span></span></code>

Set action.disabled to disable only that action; item.disabled disables all of the row’s controls. No plus button appears unless the application supplies it.

Set sidebar.reorderable = true to enable desktop HTML drag-and-drop in navigation mode. Drop in the top or bottom half of a sibling row to request a move before or after it. Alt+Up and Alt+Down request the same moves from the keyboard. Set an item’s reorderable: false to exclude it. Disabled rows, other parents and external drags are excluded. Touch dragging and reparenting are not implemented.

sidebar-move carries { id, targetId, position: "before" | "after" }. The component never changes or saves items: validate permissions and the hierarchy in the application, move the whole subtree when moving a parent, then replace items if the move is accepted. Keep reorderable false while saving. A rejected request leaves the order intact. After accepting a keyboard move, call focusItem(id) after updateComplete to retain focus. Supply translated keyboard guidance alongside any reorderable surface.

Reordering is off unless enabled; the documentation navigation does not enable editing or reordering.