Skip to content
Vertical Jump Designs-uiFront-End Studio
Get Pro

v3.9 is out.

Navigation

Sidebar

Free25.5 KB gzipped

App side navigation. See SidebarProps and the parts (Sidebar.Header, .Body, .Section, .Item, .Group, .Footer, .Toggle).

Accessibility: WCAG 2.2 AA · No A or AA violations in light or dark mode · Keys: Tab, Enter, Space and 1 more · Full report

Import

tsx
import { Sidebar } from "@vjdesigns/vjdesigns-ui";

Importing only Sidebar adds about 25.5 KB of minified, gzipped JavaScript to your app (React not included). The stylesheet is shared by every component and loaded once: 75.1 KB gzipped.

Examples

Basic

App navigation with sections, badges and collapsible groups. Sidebar.Toggle collapses it to icons, with tooltips. Use mode="overlay" to show it as a drawer on small screens.

tsx
import { useState, type MouseEvent } from "react";
import {
  BellIcon,
  Box,
  CalendarIcon,
  FileIcon,
  HelpIcon,
  HomeIcon,
  MailIcon,
  SettingsIcon,
  Sidebar,
  Text,
  UsersIcon,
} from "@vjdesigns/vjdesigns-ui";

export function Basic() {
  const [active, setActive] = useState("dashboard");
  const item = (id: string) => ({
    href: `#${id}`,
    active: active === id,
    onClick: (event: MouseEvent<HTMLElement>) => {
      event.preventDefault();
      setActive(id);
    },
  });

  return (
    <Box border radius="lg" overflow="hidden" display="flex" surface="surface" style={{ width: "100%", height: "30rem" }}>
      <Sidebar aria-label="Example app">
        <Sidebar.Header>
          <Text weight="black">Acme</Text>
          <Sidebar.Toggle />
        </Sidebar.Header>
        <Sidebar.Body>
          <Sidebar.Section>
            <Sidebar.Item {...item("dashboard")} icon={<HomeIcon />}>
              Dashboard
            </Sidebar.Item>
            <Sidebar.Item {...item("inbox")} icon={<MailIcon />} badge={3} badgeLabel="3 unread">
              Inbox
            </Sidebar.Item>
            <Sidebar.Item {...item("alerts")} icon={<BellIcon />}>
              Alerts
            </Sidebar.Item>
          </Sidebar.Section>
          <Sidebar.Section heading="Workspace">
            <Sidebar.Item {...item("team")} icon={<UsersIcon />}>
              Team
            </Sidebar.Item>
            <Sidebar.Item {...item("calendar")} icon={<CalendarIcon />}>
              Calendar
            </Sidebar.Item>
            <Sidebar.Group label="Documents" icon={<FileIcon />} defaultOpen>
              <Sidebar.Item {...item("briefs")}>Briefs</Sidebar.Item>
              <Sidebar.Item {...item("contracts")}>Contracts</Sidebar.Item>
            </Sidebar.Group>
          </Sidebar.Section>
        </Sidebar.Body>
        <Sidebar.Footer>
          <Sidebar.Section>
            <Sidebar.Item {...item("settings")} icon={<SettingsIcon />}>
              Settings
            </Sidebar.Item>
            <Sidebar.Item {...item("help")} icon={<HelpIcon />}>
              Help
            </Sidebar.Item>
          </Sidebar.Section>
        </Sidebar.Footer>
      </Sidebar>
      <Box p={6} style={{ flex: 1 }}>
        <Text weight="semibold">Current page: {active}</Text>
      </Box>
    </Box>
  );
}

Collapsed

Collapsed to an icon rail, every item still has its name: it's shown as a tooltip on hover and focus, and remains the item's accessible name. Sidebar.Toggle is a named button that reports whether the sidebar is expanded.

Hover or tab through the rail to see the names.

tsx
import {
  Box,
  CalendarIcon,
  HomeIcon,
  MailIcon,
  Sidebar,
  Text,
} from "@vjdesigns/vjdesigns-ui";

export function Collapsed() {
  return (
    <Box border radius="lg" overflow="hidden" display="flex" surface="surface" style={{ width: "100%", height: "22rem" }}>
      <Sidebar aria-label="Collapsed example" defaultCollapsed>
        <Sidebar.Header>
          <Sidebar.Toggle />
        </Sidebar.Header>
        <Sidebar.Body>
          <Sidebar.Section>
            <Sidebar.Item href="#example-collapsed" icon={<HomeIcon />} active>
              Dashboard
            </Sidebar.Item>
            <Sidebar.Item href="#example-collapsed" icon={<MailIcon />} badge={3} badgeLabel="3 unread">
              Inbox
            </Sidebar.Item>
            <Sidebar.Item href="#example-collapsed" icon={<CalendarIcon />}>
              Calendar
            </Sidebar.Item>
          </Sidebar.Section>
        </Sidebar.Body>
      </Sidebar>
      <Box p={6} style={{ flex: 1 }}>
        <Text tone="muted">Hover or tab through the rail to see the names.</Text>
      </Box>
    </Box>
  );
}

Accessibility

The sidebar is a navigation landmark named by aria-label. The active item is marked as the current page, badges are spoken through badgeLabel ("3 unread", not "3"), and each Sidebar.Group is a disclosure button that reports whether it's expanded.

Main content.

tsx
import {
  BellIcon,
  Box,
  FileIcon,
  HomeIcon,
  Sidebar,
  Text,
} from "@vjdesigns/vjdesigns-ui";

export function Accessibility() {
  return (
    <Box border radius="lg" overflow="hidden" display="flex" surface="surface" style={{ width: "100%", height: "24rem" }}>
      <Sidebar aria-label="Workspace">
        <Sidebar.Body>
          <Sidebar.Section heading="Projects" headingLevel={3}>
            <Sidebar.Item href="#example-accessibility" icon={<HomeIcon />} active>
              Overview
            </Sidebar.Item>
            <Sidebar.Item href="#example-accessibility" icon={<BellIcon />} badge={3} badgeLabel="3 unread">
              Updates
            </Sidebar.Item>
            <Sidebar.Group label="Reports" icon={<FileIcon />}>
              <Sidebar.Item href="#example-accessibility">Quarterly</Sidebar.Item>
              <Sidebar.Item href="#example-accessibility">Annual</Sidebar.Item>
            </Sidebar.Group>
          </Sidebar.Section>
        </Sidebar.Body>
      </Sidebar>
      <Box p={6} style={{ flex: 1 }}>
        <Text tone="muted">Main content.</Text>
      </Box>
    </Box>
  );
}

Translated

In Hebrew the sidebar moves to the right and its contents mirror. The collapse button's names come from the locale; the item labels are your own text.

תוכן ראשי.

tsx
import {
  Box,
  HomeIcon,
  SettingsIcon,
  Sidebar,
  Text,
  UsersIcon,
  LocaleProvider,
} from "@vjdesigns/vjdesigns-ui";
import he from "@vjdesigns/vjdesigns-ui/locales/he";

export function Translated() {
  return (
    <LocaleProvider locale="he" messages={he}>
      <Box border radius="lg" overflow="hidden" display="flex" surface="surface" style={{ width: "100%", height: "22rem" }}>
        <Sidebar aria-label="ניווט">
          <Sidebar.Header>
            <Text weight="black">אקמה</Text>
            <Sidebar.Toggle />
          </Sidebar.Header>
          <Sidebar.Body>
            <Sidebar.Section>
              <Sidebar.Item href="#example-translated" icon={<HomeIcon />} active>
                לוח בקרה
              </Sidebar.Item>
              <Sidebar.Item href="#example-translated" icon={<UsersIcon />}>
                צוות
              </Sidebar.Item>
              <Sidebar.Item href="#example-translated" icon={<SettingsIcon />}>
                הגדרות
              </Sidebar.Item>
            </Sidebar.Section>
          </Sidebar.Body>
        </Sidebar>
        <Box p={6} style={{ flex: 1 }}>
          <Text tone="muted">תוכן ראשי.</Text>
        </Box>
      </Box>
    </LocaleProvider>
  );
}

API reference

Sidebar

Sidebar props
PropTypeDefault
children

Sidebar.Header, Sidebar.Body (with sections), and Sidebar.Footer.

ReactNode—
aria-label

Accessible name of the navigation landmark. Use a different name for each nav on the page. Ignored when aria-labelledby is set.

string"Main navigation"
mode

static (default): an in-flow column that can collapse to an icon rail. overlay: the same content in a modal Drawer from the inline-start edge, opened with open / onOpenChange. Switch modes responsively by driving this prop from a media query in your app shell (for example mode={isWide ? "static" : "overlay"}); keep the same children for both.

"static""overlay""static"
collapsed

Controlled collapsed (icon rail) state. Static mode only.

boolean—
defaultCollapsed

Initial collapsed state when uncontrolled.

booleanfalse
onCollapsedChange

Called with the next collapsed state (from Sidebar.Toggle, or a rail group press).

(collapsed: boolean) => void—
open

Overlay mode: controlled open state of the drawer.

boolean—
defaultOpen

Overlay mode: initial open state when uncontrolled.

booleanfalse
onOpenChange

Overlay mode: called with the next open state (close button, Escape, backdrop, or navigation).

(open: boolean) => void—
closeOnNavigate

Overlay mode: close the drawer when a Sidebar.Item is activated, including router links whose onClick calls preventDefault(). Group buttons never close it.

booleantrue
overlayLabel

Overlay mode: the drawer dialog's accessible name. Defaults to the sidebar's aria-label.

string—
size

Item height and type size (--control-height-sm|md|lg). Also sets the rail width.

"sm""md""lg""md"
tooltipPlacement

Side for rail tooltips. The default "end" follows the text direction (right in left-to-right layouts, left in right-to-left ones); use "start" for a sidebar on the inline-end side of the page.

TooltipPlacement"end"

Also accepts native <nav> attributes, plus className, style and ref.

Sidebar.Header

Sidebar.Header props
PropTypeDefault
children

Brand, workspace switcher, and usually a Sidebar.Toggle. Pinned above the scrolling body.

ReactNode—

Also accepts native <div> attributes, plus className, style and ref.

Sidebar.Body

Sidebar.Body props
PropTypeDefault
children

Sidebar.Sections. Scrolls when taller than the sidebar, while the header and footer stay pinned.

ReactNode—

Also accepts native <div> attributes, plus className, style and ref.

Sidebar.Section

Sidebar.Section props
PropTypeDefault
heading

Visible group label, e.g. "Teams". The section becomes role="group" named by it (aria-labelledby). In rail mode the heading is visually hidden (still the group's name) and a divider separates sections instead.

ReactNode—
headingLevel

Renders the heading as h2-h6 so it appears in the page's heading outline. When omitted, the heading is a styled div that only names the group.

23456—
children

Sidebar.Items and Sidebar.Groups. Rendered inside a <ul>.

ReactNode—

Also accepts native <div> attributes, plus className, style and ref.

Sidebar.Item

Sidebar.Item props
PropTypeDefault
childrenRequired

The visible label. It is the item's accessible name, including in rail mode (where it also appears as a tooltip).

ReactNode—
icon

Decorative icon before the label. Required for a usable rail: it's all that shows when collapsed.

ReactNode—
active

Marks the current page: sets aria-current="page" and shows a soft primary tint, a start-edge indicator bar, and bold text.

booleanfalse
badge

A count (rendered with Badge count, capped at 99+, hidden at 0) or a short text such as "New". In rail mode it shrinks to a dot on the icon and the full badge shows in the tooltip.

SidebarBadgeValue—
badgeLabel

Screen-reader text for the badge, e.g. "3 unread messages". Replaces the visible badge text in the accessible name.

string—
badgeTone

Badge color.

"neutral""primary""accent""success""warning""danger""info""accent"
disabled

Disables the item. Buttons use the native disabled attribute; links drop href and get aria-disabled.

booleanfalse
href

Pass a URL to render the item as a link (<a>).

string—

Also accepts native <button> attributes, plus className, style and ref.

Sidebar.Group

Sidebar.Group props
PropTypeDefault
labelRequired

The disclosure button's visible label, and its accessible name.

ReactNode—
icon

Decorative icon before the label. Shown alone in rail mode.

ReactNode—
children

Nested Sidebar.Items. Rendered in a <ul> that the button controls.

ReactNode—
open

Controlled open state.

boolean—
defaultOpen

Initial open state when uncontrolled.

booleanfalse
onOpenChange

Called with the next open state.

(open: boolean) => void—
active

One of the nested items is the current page. While the group is closed (or the sidebar is a rail), the button shows the active look so users can see where they are. It doesn't set aria-current; the nested item does.

booleanfalse
badge

A count or short text on the group button, like Sidebar.Item's badge.

SidebarBadgeValue—
badgeLabel

Screen-reader text for the badge.

string—
badgeTone

Badge color.

"neutral""primary""accent""success""warning""danger""info""accent"
disabled

Disables the disclosure button.

booleanfalse
value

A stable key for the group. An uncontrolled group's open state is kept by key, so it survives a mode switch (which remounts the nav). Defaults to label when that is plain text.

string—

Also accepts native <li> attributes, plus className, style and ref.

Sidebar.Footer props
PropTypeDefault
children

Account, settings, or help links (a Sidebar.Section), or a Sidebar.Toggle. Pinned to the bottom.

ReactNode—

Also accepts native <div> attributes, plus className, style and ref.

Sidebar.Toggle

Sidebar.Toggle props
PropTypeDefault
href

Pass a URL to render the control as a link (<a>).

undefined—
disabled

Disables the control. Buttons use the native disabled attribute; links drop href and get aria-disabled.

booleanfalse
loading

Replaces the icon with a spinner, sets aria-busy, and ignores clicks.

booleanfalse
variant

Visual style. Inherits from a surrounding ButtonGroup.

"solid""soft""outline""ghost""link""inverse""solid"
tone

Semantic color. Inherits from a surrounding ButtonGroup.

"neutral""primary""accent""success""warning""danger""info""primary"
size

Control size. xs (24px, the minimum target size) fits inside a sm field without making it taller. Inherits from a surrounding ButtonGroup.

"sm""md""lg""xs""md"
radius

Corner rounding. When omitted, uses --control-radius (pill).

"none""xs""sm""md""lg""xl""2xl""pill""pill"
collapseLabel

Accessible name (and tooltip) while expanded.

string"Collapse sidebar"
expandLabel

Accessible name (and tooltip) while collapsed.

string"Expand sidebar"
children

Custom icon. Defaults to a chevron that points toward the collapse direction.

ReactNode—

Also accepts standard HTML attributes, plus className, style and ref.

See what changed in each version in the Changelog.

Accessibility report

Sidebar targets WCAG 2.2 AA. Below: a live axe-core audit of this page's examples, Lighthouse scores for the page in both modes, the accessibility behavior built into the component, and the checks only a person can do.

axe-core audit (live)

Running accessibility audit

Checking the examples above…

Lighthouse audit

Light mode

Score 100

35 passed · 0 failed · 30 not applicable · 10 to check by hand

Dark mode

Score 100

35 passed · 0 failed · 30 not applicable · 10 to check by hand

Lighthouse 13.5.0 audits the whole docs page (header and sidebar included), not just the examples, in English. Last run 11/27/2026. Some failed audits carry no weight in the score, so a page can score 100 and still list one.

Built-in behavior

Keyboard

Keyboard
KeyAction
TabMoves through the items. It's a list of links, not a menu.
EnterSpaceToggles a group, or the collapsed rail (Sidebar.Toggle).
EscapeOverlay mode: closes the sidebar.

Roles and states

Roles and states
ElementRoleStates and properties
Sidebarnavigationaria-label
Itemlinkaria-current="page" when active
Group buttonbuttonaria-expanded, aria-controls
BadgenoneSpoken through badgeLabel ("3 unread")

Manual checks

Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.

Manual accessibility checks
CheckWhat to testWCAG 2.2
KeyboardEvery action works with Tab, Shift+Tab, Enter, Space and the arrow keys, and focus never gets stuck.2.1.1 (A), 2.1.2 (A)
FocusFocus moves in a logical order, is always visible, and isn't hidden behind sticky headers.2.4.3 (A), 2.4.7 (AA), 2.4.11 (AA), 2.4.13 (AAA)
Screen readersNames, roles and states are announced correctly, and status changes are announced without moving focus.1.3.1 (A), 4.1.2 (A), 4.1.3 (AA)
ColorMeaning never depends on color alone; your own colors meet contrast in both modes.1.4.1 (A), 1.4.3 (AA), 1.4.11 (AA), 1.4.6 (AAA)
Zoom and reflowAt 200% text size and at 320px wide (400% zoom), nothing is cut off and no sideways scrolling is needed.1.4.4 (AA), 1.4.10 (AA), 1.4.12 (AA)
Pointer targetsClick and tap targets are at least 24×24px (44×44px for AAA), or spaced so they don't overlap.2.5.8 (AA), 2.5.5 (AAA)
MotionAnimations respect the reduced-motion setting.2.3.3 (AAA)