Skip to content
synccn

Sidebar

Collapsible app sidebar with groups, badges and nested items.

Home

Installation

$ pnpm dlx shadcn@latest add @synccn/sidebar

First time in this project? Connect synccn with one command.

Usage

import { Sidebar } from "@/components/ui/sidebar";<Sidebar groups={groups}>{(active) => …}</Sidebar>

API reference

Generated from the component's TypeScript types, so it always matches the code.

Sidebar

Collapsible app sidebar. Collapsed mode shows icons with tooltips. groups: [{ label, items: [{ label, icon, badge?, children?: [{ label }] }] }]

  • groupsrequired
    SidebarGroup[]

    Navigation groups.

  • header
    React.ReactNode

    Shown at the top (hidden when collapsed).

  • footer
    React.ReactNode | ((collapsed: boolean) => React.ReactNode)

    Shown at the bottom; a function receives the collapsed state.

  • defaultCollapsed
    boolean

    Default false

    Start in icon-only mode.

  • active
    string

    Label of the item active at first.

  • onSelect
    (label: string) => void

    Called when an item is chosen.

  • children
    React.ReactNode | ((active: string) => React.ReactNode)

    Main content; a function receives the active label.

  • className
    string

    Extra classes for the root element.

Dependencies

Read from the component's imports when the site builds. The CLI installs all of these for you.

Components

Helpers

npm packages

Accessibility

From the source

Read from this component's code when the site builds, so it can't drift.

  • ARIA attributes: aria-current, aria-expanded, aria-label