Sidebar

Sidebar is a collapsible vertical navigation panel.

Widelab31 seats
Onboarding3/5
Fulfill personal information
AS
online
Adam Smithhello@wideset.co
tsx
import { RiDashboardLine, RiFolder3Line, RiUser3Line } from '@remixicon/react';
import { Sidebar } from '@/components/ui/wideset/sidebar/Sidebar';

<Sidebar>
  <Sidebar.Header>
    <div className="flex items-center gap-ws-7 py-ws-3">
      <Sidebar.Expanded>
        <span className="pl-ws-5 typography-label-strong-sm text-ws-static-strong">Northwind</span>
      </Sidebar.Expanded>
      <Sidebar.Trigger />
    </div>
  </Sidebar.Header>
  <Sidebar.Section>
    <nav className="flex flex-col gap-ws-2">
      <Sidebar.Item href="#" icon={RiDashboardLine} label="Dashboard" active />
      <Sidebar.Item href="#" icon={RiFolder3Line} label="Projects" />
      <Sidebar.Item href="#" icon={RiUser3Line} label="Customers" />
    </nav>
  </Sidebar.Section>
</Sidebar>

Installation

pnpm dlx wideset add sidebar

Copies the component and any Wideset components it uses into your project.

Examples

Collapsed

Collapsed keeps only the icons; each item's label becomes its aria-label and the trigger flips to Expand. The same tree serves both modes, so the trigger and the items keep focus across a toggle; Sidebar.Expanded wraps what exists only when expanded, here the product name.

tsx
import { RiDashboardLine, RiFolder3Line, RiUser3Line } from '@remixicon/react';
import { Sidebar } from '@/components/ui/wideset/sidebar/Sidebar';

const NAV = [
  { label: 'Dashboard', Icon: RiDashboardLine },
  { label: 'Projects', Icon: RiFolder3Line },
  { label: 'Customers', Icon: RiUser3Line },
];

const nav = (
  <nav className="gap-ws-2 flex flex-col">
    {NAV.map(({ label, Icon }) => (
      <Sidebar.Item key={label} href="#" icon={Icon} label={label} active={label === 'Dashboard'} />
    ))}
  </nav>
);

export default function SidebarCollapsedMode() {
  return (
    <div className="gap-ws-12 flex flex-wrap items-start justify-center">
      {[false, true].map((collapsed) => (
        <div
          key={String(collapsed)}
          className="rounded-ws-control-lg border-ws-static-base flex h-[16rem] overflow-hidden border"
        >
          <Sidebar defaultCollapsed={collapsed}>
            <Sidebar.Header>
              <div className="gap-ws-7 py-ws-3 flex items-center">
                <Sidebar.Expanded>
                  <span className="typography-label-strong-sm text-ws-static-strong pl-ws-5">
                    Northwind
                  </span>
                </Sidebar.Expanded>
                <Sidebar.Trigger />
              </div>
            </Sidebar.Header>
            <Sidebar.Section>{nav}</Sidebar.Section>
          </Sidebar>
        </div>
      ))}
    </div>
  );
}

Groups

Sidebar.SectionHeader titles a group of items. Give it an id and point the group's aria-labelledby at it. Collapsed, the rail cuts its text short ("P…"), so the groups stay apart and named.

tsx
import {
  RiBarChartLine,
  RiDashboardLine,
  RiFileCopyLine,
  RiSecurePaymentLine,
  RiUser3Line,
} from '@remixicon/react';
import { Sidebar } from '@/components/ui/wideset/sidebar/Sidebar';

export default function SidebarGroups() {
  return (
    <div className="gap-ws-12 flex flex-wrap items-start justify-center">
      {[false, true].map((collapsed) => (
        <div
          key={String(collapsed)}
          className="rounded-ws-control-lg border-ws-static-base flex h-[20rem] overflow-hidden border"
        >
          <Sidebar defaultCollapsed={collapsed}>
            <Sidebar.Section scrollable>
              <nav aria-label="Main" className="gap-ws-2 flex flex-col">
                <Sidebar.Item href="#" icon={RiDashboardLine} label="Dashboard" active />
                <Sidebar.Item href="#" icon={RiUser3Line} label="Customers" />
                <Sidebar.SectionHeader id={`products-${collapsed}`}>Products</Sidebar.SectionHeader>
                <div
                  role="group"
                  aria-labelledby={`products-${collapsed}`}
                  className="gap-ws-2 flex flex-col"
                >
                  <Sidebar.Item href="#" icon={RiSecurePaymentLine} label="Payments" />
                  <Sidebar.Item href="#" icon={RiFileCopyLine} label="Billing" />
                  <Sidebar.Item href="#" icon={RiBarChartLine} label="Reporting" />
                </div>
              </nav>
            </Sidebar.Section>
          </Sidebar>
        </div>
      ))}
    </div>
  );
}

States

active marks the page the user is on: one item per sidebar, announced with aria-current="page". disabled dims an item, takes it out of the tab order and blocks the link, for a page the user's plan or role does not include yet. Prefer hiding a page the user will never reach over showing it disabled.

tsx
import { RiBarChartLine, RiDashboardLine, RiFolder3Line, RiUser3Line } from '@remixicon/react';
import { Sidebar } from '@/components/ui/wideset/sidebar/Sidebar';

export default function SidebarStates() {
  return (
    <div className="rounded-ws-control-lg border-ws-static-base flex h-[16rem] w-fit overflow-hidden border">
      <Sidebar>
        <Sidebar.Section>
          <nav aria-label="Main" className="gap-ws-2 flex flex-col">
            <Sidebar.Item href="#" icon={RiDashboardLine} label="Dashboard" active />
            <Sidebar.Item href="#" icon={RiFolder3Line} label="Projects" />
            <Sidebar.Item href="#" icon={RiUser3Line} label="Customers" />
            <Sidebar.Item href="#" icon={RiBarChartLine} label="Reports" disabled />
          </nav>
        </Sidebar.Section>
      </Sidebar>
    </div>
  );
}

Suffixes

suffix puts a count or a badge on the item's right edge, where it stays: it is content. A keyboard shortcut is a hint instead: with suffixOnHover it shows only while the row is hovered or has keyboard focus, and keeps its space, so the label never shifts. Collapsed, the sidebar hides every suffix.

tsx
import { RiCalendarLine, RiDashboardLine, RiInbox2Line, RiSearchLine } from '@remixicon/react';
import { Sidebar } from '@/components/ui/wideset/sidebar/Sidebar';

export default function SidebarSuffixes() {
  return (
    <div className="rounded-ws-control-lg border-ws-static-base flex h-[16rem] w-fit overflow-hidden border">
      <Sidebar>
        <Sidebar.Section>
          <nav aria-label="Main" className="gap-ws-2 flex flex-col">
            <Sidebar.Item href="#" icon={RiDashboardLine} label="Dashboard" active />
            <Sidebar.Item href="#" icon={RiInbox2Line} label="Inbox" suffix="12" />
            <Sidebar.Item
              href="#"
              icon={RiCalendarLine}
              label="Calendar"
              suffix="⌘2"
              suffixOnHover
            />
            <Sidebar.Item href="#" icon={RiSearchLine} label="Search" suffix="⌘K" suffixOnHover />
          </nav>
        </Sidebar.Section>
      </Sidebar>
    </div>
  );
}

API reference

Sidebar

NameDescriptionDefault
collapsed

Controls the collapsed state. When provided, the sidebar is in controlled mode.

boolean
false
defaultCollapsed

Whether the sidebar starts collapsed in uncontrolled mode. Has no effect when `collapsed` is provided.

boolean
—
defaultMotion

Turns the component's built-in animations on or off. When omitted, inherits the value from the nearest `MotionProvider`.

boolean
true
onCollapsedChange

Fired when the collapsed state changes. Receives the new `collapsed` value.

((collapsed: boolean) => void)
—
surface

What the sidebar sits on. Inside an `AppShell` it follows the app's direction, so leave it off there; set it to override the direction, or for a sidebar outside an `AppShell`. `page`: the page's white with a subtle line on its right edge (Flat). `tinted`: a grey tint over the app's white, no line (Frame). `frame`: no fill and no line, so it shows the grey app frame behind it, its nav centred in the column beside an inset page (Inset, Canvas).

NonNullable<'page' | 'frame' | 'tinted' | undefined>
'the AppShell direction's surface, `page` outside an AppShell'
Every other prop of <div> is passed through to it. See MDN: <div>.

Sidebar.Collapsed

NameDescriptionDefault
children

Content rendered inside the component.

ReactNode
—

Sidebar.Expanded

NameDescriptionDefault
children

Content rendered inside the component.

ReactNode
—

Sidebar.Footer

No props of its ownIt takes its content as children.
Every other prop of <div> is passed through to it. See MDN: <div>.

Sidebar.Header

No props of its ownIt takes its content as children.
Every other prop of <div> is passed through to it. See MDN: <div>.

Sidebar.Item

NameDescriptionDefault
active

Marks the row as the current page: active styling plus `aria-current="page"`.

boolean
false
asChild

Merges props onto the child element instead of rendering an `<a>` — e.g. a react-router or tanstack-router `Link`. The icon and label are injected into it. Renders the built-in item element; use the slotted branch for custom links.

boolean
false
children

The element to render as, e.g. `<Link to="/dashboard" />`. Required with `asChild`.

ReactElement<unknown, string | JSXElementConstructor<any>>
—
defaultMotion

Turns the component's built-in animations on or off. When omitted, inherits the value from the nearest `MotionProvider`.

boolean
true
disabled

Blocks navigation and applies disabled styling via `aria-disabled`.

boolean
false
icon

Leading icon. Rendered on its own when the sidebar is collapsed.

RemixiconComponentType
—
label

Row label. Hidden when the sidebar is collapsed, where it falls back to `aria-label`.

ReactNode
—
nested

A child of the item above it (Figma `Nesting=Level 1`), e.g. a page inside "Pages": indented so its icon starts under the parent's label. One level only; the indent is the whole cue, so draw no guide line. Collapsed, nested items line up like the rest.

boolean
false
suffix

Trailing content on the row's right edge: a count (`3`) or a `StatusBadge`. Not interactive, since the row is a link. Hidden when the sidebar is collapsed.

ReactNode
—
suffixOnHover

Shows the `suffix` only while the row is hovered or has keyboard focus, as for a keyboard shortcut (`⌘1`): a hint, not content. It keeps its space, so the label never shifts. Leave it off for counts and badges, which are content.

boolean
false

Sidebar.SectionHeader

No props of its ownIt takes its content as children.
Every other prop of <div> is passed through to it. See MDN: <div>.

Sidebar.Section

NameDescriptionDefault
scrollable

Makes the section fill the remaining height and scroll its overflow inside a `ScrollArea`.

boolean
—
Every other prop of <div> is passed through to it. See MDN: <div>.

Sidebar.Trigger

NameDescriptionDefault
asChild

Merges props onto the immediate child element instead of rendering the default icon button.

boolean
—
collapseLabel

Accessible label used when the sidebar is expanded (button collapses it). Defaults to `'Collapse sidebar'`. Ignored when `aria-label` is set explicitly.

string
'Collapse sidebar'
defaultMotion

Turns the component's built-in animations on or off. When omitted, inherits the value from the nearest `MotionProvider`.

boolean
true
expandLabel

Accessible label used when the sidebar is collapsed (button expands it). Defaults to `'Expand sidebar'`. Ignored when `aria-label` is set explicitly.

string
'Expand sidebar'
Every other prop of <button> is passed through to it. See MDN: <button>.

Accessibility

  • Wrap items in a <nav aria-label="…">; the sidebar root is a plain div.
  • Collapsed items fall back to label as aria-label when it is a string; pass aria-label when label is a node.
  • Write the trigger and the items once, outside Sidebar.Expanded / Sidebar.Collapsed, so they keep focus when the sidebar toggles.
  • Sidebar.SectionHeader keeps its text in both modes; give it an id and point the group’s aria-labelledby at it.
  • Sidebar.Trigger names itself (“Collapse sidebar” / “Expand sidebar”, via collapseLabel / expandLabel) and sets aria-expanded / aria-controls.
PartRendersDescription
Sidebar<div>Props for the root Sidebar container. Supports both controlled and uncontrolled collapsed state.
Sidebar.Collapsed—Props for content that exists only when the sidebar is collapsed.
Sidebar.Expanded—Props for content that exists only when the sidebar is expanded, e.g. the product name.
Sidebar.Footer<div>Props for the sidebar's bottom area (invite, account). Pinned to the bottom, never scrolls.
Sidebar.Header<div>Props for the Sidebar header — the title/branding row. Never scrolls; hidden when empty.
Sidebar.Item—Props for a Sidebar navigation row. Renders an `<a>`; use `asChild` for a router Link.
Sidebar.SectionHeader<div>Props for the title of a group of items. Collapsed, it keeps its height and its text stays available to screen readers.
Sidebar.Section<div>Props for a Sidebar section. Its content stays mounted in both modes; the parts inside adapt.
Sidebar.Trigger<button>Props for the Sidebar toggle trigger button.
Dashboard
tsx
import { RiDashboardLine, RiFolder3Line, RiUser3Line } from '@remixicon/react';
import { Sidebar } from '@/components/ui/wideset/sidebar/Sidebar';

<Sidebar>
  <Sidebar.Header>
    <div className="flex items-center gap-ws-7 py-ws-3">
      <Sidebar.Expanded>
        <span className="pl-ws-5 typography-label-strong-sm text-ws-static-strong">Northwind</span>
      </Sidebar.Expanded>
      <Sidebar.Trigger />
    </div>
  </Sidebar.Header>
  <Sidebar.Section>
    <nav className="flex flex-col gap-ws-2">
      <Sidebar.Item href="#" icon={RiDashboardLine} label="Dashboard" active />
      <Sidebar.Item href="#" icon={RiFolder3Line} label="Projects" />
      <Sidebar.Item href="#" icon={RiUser3Line} label="Customers" />
    </nav>
  </Sidebar.Section>
</Sidebar>

Appearance

Surface

Content

Current page
Header

State

Collapsed