sigilUI

Sidebar

A token-driven application sidebar with navigation groups, icons, and an optional collapse control.

@sigil-ui/componentsReact

Preview

Live preview Interactive

Import

import {
  Sidebar, SidebarHeader, SidebarContent, SidebarFooter,
  SidebarGroup, SidebarGroupLabel, SidebarItem,
} from "@sigil-ui/components";

Usage

SidebarItem renders a button. Use its onClick handler to select a view or navigate with your application's router.

<Sidebar aria-label="Workspace navigation">
  <SidebarHeader>Fieldwork</SidebarHeader>
  <SidebarContent>
    <SidebarGroup>
      <SidebarGroupLabel>Workspace</SidebarGroupLabel>
      <SidebarItem
        icon={<HomeIcon />}
        active={view === "overview"}
        onClick={() => setView("overview")}
      >
        Overview
      </SidebarItem>
      <SidebarItem
        icon={<FolderIcon />}
        active={view === "projects"}
        onClick={() => setView("projects")}
      >
        Projects
      </SidebarItem>
    </SidebarGroup>
  </SidebarContent>
  <SidebarFooter>
    <SidebarItem icon={<SettingsIcon />} onClick={() => setView("settings")}>
      Settings
    </SidebarItem>
  </SidebarFooter>
</Sidebar>

Collapse behavior

The built-in edge button toggles between the full sidebar and an icon-only view. Provide an icon and an accessible label for items that need to remain usable while collapsed.

<Sidebar defaultCollapsed aria-label="Workspace navigation">
  <SidebarContent>
    <SidebarItem icon={<HomeIcon />} aria-label="Overview" onClick={() => setView("overview")}>
      Overview
    </SidebarItem>
  </SidebarContent>
</Sidebar>

For a persistent category list, set collapsible={false}. This keeps the sidebar expanded and removes the edge button, including when defaultCollapsed is set.

<Sidebar collapsible={false} aria-label="Component categories">
  <SidebarContent>{/* Category buttons */}</SidebarContent>
</Sidebar>

Token integration

CSS VariableUsed for
--s-sidebar-widthExpanded width
--s-sidebar-collapsedCollapsed width
--s-surfaceSidebar background
--s-textItem text
--s-text-mutedGroup labels and inactive icons
--s-primaryActive text and tinted item background
--s-borderSidebar, header, and footer borders
--s-border-styleBorder style
--s-duration-normalCollapse animation
--s-ease-outAnimation easing

Props

PropTypeDefaultDescription
collapsiblebooleantrueShow the built-in collapse control; false keeps the sidebar expanded
defaultCollapsedbooleanfalseStart collapsed when collapsing is enabled
classNamestring—Additional CSS classes
childrenReactNode—Sidebar content

SidebarItem

PropTypeDefaultDescription
iconReactNode—Leading icon, also shown while collapsed
activebooleanfalseHighlight the current item
onClickMouseEventHandler<HTMLButtonElement>—Handle selection or navigation
classNamestring—Additional CSS classes
childrenReactNode—Item label, hidden while collapsed

Accessibility

  • The sidebar renders an aside; provide aria-label to name the region.
  • The collapse control changes its accessible name between “Collapse sidebar” and “Expand sidebar.”
  • Active items use aria-current="page".
  • Give icon-only items an aria-label so their names remain available when collapsed.