Skip to contentKino
Skip to Content

Sidebar

An app's navigation beside its page, which collapses to its icons or out of sight, and is a sheet on a phone.

npx shadcn add https://kinoui.com/r/sidebar.json
Share on

Examples

Billing revamp

  • KN-482Invoice totals round the tax twiceMC2h
  • KN-479Export to CSV drops the last rowTA5h
  • KN-475Onboarding checklist forgets skipped stepsPR1d
  • KN-471Dark mode chart labels are hard to readJL2d
  • KN-468Search misses issues renamed this weekMC3d

Default

Collapse it with the button in the page’s header, or ⌘B and Ctrl+B: it narrows to its icons, and each icon’s tooltip names its page.

Billing revamp

  • KN-482Invoice totals round the tax twiceMC2h
  • KN-479Export to CSV drops the last rowTA5h
  • KN-475Onboarding checklist forgets skipped stepsPR1d
  • KN-471Dark mode chart labels are hard to readJL2d
  • KN-468Search misses issues renamed this weekMC3d

Offcanvas

With collapsible='offcanvas', it slides out of sight. Rest the pointer on the screen’s edge and it comes back over the page until the pointer leaves.

Billing revamp

  • KN-482Invoice totals round the tax twiceMC2h
  • KN-479Export to CSV drops the last rowTA5h
  • KN-475Onboarding checklist forgets skipped stepsPR1d
  • KN-471Dark mode chart labels are hard to readJL2d
  • KN-468Search misses issues renamed this weekMC3d

Side

Set side to end to dock it at the other edge. Start and end follow the text direction.

Installation

npx shadcn@latest add https://kinoui.com/r/sidebar.json
Files
lib/reduce-motion.tslib/scroll.tslib/refs.tslib/resize.tslib/swap.tsxlib/popup.tslib/glide.tsxcomponents/kino/tooltip.tsxlib/cut.tsxcomponents/kino/badge.tsxcomponents/kino/spinner.tsxcomponents/kino/button.tsxcomponents/kino/collapsible.tsxlib/keys.tsxcomponents/kino/kbd.tsxcomponents/kino/scroll-area.tsxlib/panel.tsxcomponents/kino/sheet.tsxlib/controllable.tslib/run-progress.tslib/highlight.tscomponents/kino/sidebar.tsx
Packages
@base-ui/reactclass-variance-authority

New to Kino? Installation covers what your project needs first and the @kino namespace.

API reference

PropTypeDefaultDescription
defaultOpenbooleantrueWhether it is open at first, when you leave the state to it.
openbooleanNoneWhether it is docked open, when you hold the state.
onOpenChange(open: boolean) => voidNoneCalled when it opens or collapses.
shortcutstring[]null['Mod', 'B']The keys that toggle it from anywhere on the page, or null for none. Mod is ⌘ on Apple platforms and Ctrl elsewhere.
PropTypeDefaultDescription
collapsible'icon''offcanvas''icon'Whether it collapses to its icons or out of sight.
side'start''end''start'The edge it docks to, following the text direction.
variant'sidebar''inset''sidebar'inset draws no edge, for a page set beside it as a card, and keeps a gutter for the card while it is out of sight. The App shell’s Inset sets the card.
PropTypeDefaultDescription
isActivebooleanfalseMarks the page you are on, read out as the current page.
tooltipReactNodeNoneIts name in the rail, and in full while a long label is cut short. Usually its label.
size'default''lg''default'lg makes room for a picture, such as a workspace’s or a person’s.
PropTypeDefaultDescription
defaultOpenbooleanfalseWhether its rows show at first, when you leave the state to it.
openbooleanNoneWhether its rows show, when you hold the state.
onOpenChange(open: boolean) => voidNoneCalled when it opens or closes.

Data attributes

AttributeOnDescription
data-stateSidebarProvider and Sidebarexpanded or collapsed.
data-collapsibleSidebaricon or offcanvas.
data-variantSidebarsidebar or inset.
data-peekSidebaropen while an offcanvas sidebar shows over the page, and closing while it slides away.

CSS variables

VariableSet it onDefaultDescription
--sidebar-widthSidebarProvider, or anything above it16remIts width open.
--sidebar-width-iconSidebarProvider, or anything above ita row’s height and a gutter either sideIts width as an icon rail.
--sidebar-width-mobileSidebarProvider, or anything above it18remThe sheet’s width on a phone.

Accessibility

  • The sidebar is a nav landmark named by aria-label, and SidebarInset is the page’s main landmark. Rows are links or buttons in the tab order; the current page is aria-current="page".
  • The trigger is a button with aria-expanded and aria-controls, and aria-keyshortcuts names the shortcut. Its label says what it does: Collapse sidebar, Expand sidebar or, on a phone, Open sidebar.
  • A section follows the disclosure pattern: its row is a button with aria-expanded. In the rail it reads as closed, and focus inside a part that hides moves to the row that stays.
  • In the rail, every row is named by its tooltip, which opens on hover after 200ms and with keyboard focus. A label cut short shows whole in its tooltip.
  • An offcanvas sidebar that peeks never takes focus. While it shows, Escape sends it away and puts focus back on the trigger; a menu open inside, or focus moved in by the keyboard, keeps it.
  • On a phone it is a modal sheet: focus moves in, Escape closes it, and following a link closes it too.
  • The current page takes the system’s highlight colours under forced colours, and the focus ring keeps an outline there.
  • When the system asks for less motion, it collapses, opens and peeks at once, and labels only fade.