Skip to content

React Sidebar Component

A glass React sidebar for app shells with collapsible groups, badges and a collapsed icon rail. Use Sidebar for an app shell: a glass column with a header, collapsible groups of links and a footer for the user menu.

npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/sidebar.json
  • Sidebar
  • SidebarItem
  • SidebarGroup
  • SidebarFooter
  • SidebarHeader
  • +5 more
  • +2 more

A full app shell

Sidebar with groups and badges, a header with search and actions, stat cards and an activity list. Use Collapse to turn the sidebar into an icon rail; VerticalNav is the shorter choice for a flat list of sections.

Overview

Active users12,480+8.2%
Revenue$48.2k+3.1%
Error rate0.42%+0.1%

Recent activity

  • Maya Chen deployed sheen-web to production
  • Leo Park opened a pull request: Glass tokens
  • Asha Verma reported a failing build on main

Files to copy

6 folders · 3 files · 4 packages
From theme/src/
  • components/sidebar/
  • components/collapsible/
  • components/status-icons/
  • hooks/use-controllable.ts
  • lib/{cn.ts, warn-once.ts}
  • styles/
shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/sidebar.jsonRegistry item: sidebar. The styles need the Tailwind v4 glass UI setup.
The examples also use
  • components/avatar/
  • components/badge/
  • components/button/
  • components/drawer/drawer.tsx
  • components/drawer/parts/{content.tsx, model.ts, parts.tsx}
  • components/spinner/
  • hooks/{use-direction.ts, use-latest.ts, use-magnetic.ts, use-media-query.ts, use-preferences.ts}
  • motion/{gate.ts, tokens.ts}
  • lib/{form.ts, initials.ts, modal-tab-trap.ts, state-light.tsx}
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/avatar.json https://lokendra-builds.github.io/sheenui/r/badge.json https://lokendra-builds.github.io/sheenui/r/button.json https://lokendra-builds.github.io/sheenui/r/drawer.json
Packages
pnpm add @base-ui/react clsx motion tailwind-merge

A curved glass sheet

shape="curved" bows the trailing edge outward (the inline-end edge, so it flips in right-to-left layouts). The curve is the glass element's own corner radii, so the blur, the lit rim and the shadow follow it, and a soft light sits on the apex. With morph and the collapse item the rail bows more gently. Reduced transparency, more contrast and forced colours fall back to a plain rectangle.

PropTypeDefaultDescription
aria-labelstringlabels?.name ?? defaultSidebarLabels.nameDefines a string value that labels the current element.
childrenReactNodeNoneHolds SidebarHeader, SidebarGroups, SidebarItems and SidebarFooter.
collapsedbooleanfalseShow only the icons (a 64px rail). Labels stay as accessible names and tooltips; groups stay open.
defaultCollapsedbooleanfalseStarts as an icon rail when uncontrolled (collapsed left out). Change it from your own toggle with useSidebar().setCollapsed.
onCollapsedChange((collapsed: boolean) => void)NoneCalled with the new state when a part inside the sidebar asks to collapse or expand it (useSidebar().setCollapsed).
morphbooleanfalseMorph between the rail and the full panel instead of swapping them: icons stay exactly where they are, labels and badges fade and slide in on the content (opacity and translate only), and group headings keep their place. The width itself changes once, never through a transition, so nothing outside the sidebar shifts. Reduced motion: the labels switch in one frame.
shapeSidebarShape"rect"The outline of the glass. "curved" bows the trailing edge (inline-end, so it flips in right-to-left layouts) outward like a curved glass sheet: the blur, the lit rim and the shadow follow the curve and a soft light sits on its apex. The curve is the glass element's own corner radii, never a mask on a wrapper. With collapsed or morph the rail bows more gently. Reduced transparency, more contrast and forced colours fall back to "rect".
labelsPartial<SidebarLabels>defaultSidebarLabelsEvery string, for translation: { name: "Sidebar" } (the default landmark name; aria-label wins over it). Every other string, for translation: labels={{ name: "…" }}; omitted keys keep the English of defaultSidebarLabels. Its only key is listed in the key table under the props table.

On phones

The sidebar is a column, so on a narrow screen put the same Sidebar inside a Drawer that opens from the left (side="start" follows the reading direction) and give the page a Menu button. Keep the in-layout Sidebar for lg and up.

SidebarGroup props

PropTypeDefaultDescription
defaultOpenbooleantrueOpen at first when uncontrolled.
label (required)ReactNodeNoneThe group's heading, which is also the button that opens and closes it.
iconReactNodeNoneShows an icon before the heading.
childrenReactNodeNoneHolds the items of the group.

SidebarItem props

PropTypeDefaultDescription
iconReactNodeNoneShows an icon before the label.
badgeReactNodeNoneA count or tag at the end, such as "3". Hidden in a collapsed sidebar. A 0 is hidden unless showZero is set.
showZerobooleanfalseShow the badge when it is 0.
activebooleanfalseMarks the current page (aria-current="page") and fills the item.
disabledbooleanfalseMakes the item unclickable: it is dimmed and skipped by the keyboard.

Other parts

PropTypeDefaultDescription
SidebarHeader / SidebarFooterdiv propsNoneTop and bottom areas; the footer is pushed down.
useSidebar(){ collapsed: boolean }NoneRead the collapsed state from custom header or footer content.

All exports on this page

  • Sidebar — The app-shell sidebar: a glass column with a header, groups of links that fold open and shut, and a footer.
  • SidebarFooter — The bottom of a Sidebar, pushed down by mt-auto: a user menu or a help link.
  • SidebarGroup — A collapsible section of a Sidebar: a heading button and the items under it.
  • SidebarHeader — The top of a Sidebar: a logo or a workspace switcher.
  • SidebarItem — One link (or, without href, one button) of a Sidebar.
  • defaultSidebarLabels — The English SidebarLabels used when labels is omitted; a partial labels prop is merged over it.
  • useSidebar — Whether the surrounding Sidebar is collapsed to its icon rail.

Keyboard

KeysAction
TabMoves through group headings and items in order.
Enter/SpaceOpens or closes a focused group heading; follows a link or presses a button item.

Accessibility

  • A <nav> landmark (aria-label defaults to "Sidebar"; change it when a page has more than one).
  • Group headings are buttons with aria-expanded; closed items leave the tab order. The current page uses aria-current="page".
  • In the collapsed rail the labels stay as accessible names and as title tooltips; the icons are decorative.
  • Targets are 44px on touch screens. Under reduced motion the groups jump open and shut.

When to use Sidebar

  • Use Sidebar for the left navigation of an admin or dashboard app, where groups of links collapse, badges show unread counts and the whole column folds down to an icon rail.
  • Use collapsed to turn it into an icon rail on a narrow layout. Labels stay available as accessible names and title tooltips.
  • Give the nav an aria-label such as Workspace and mark the current page with the active prop, which sets aria-current="page".
  • Skip it for a short flat list of sections. VerticalNav is shorter, and Navbar suits a top bar on a marketing site.
  • Pair it with Drawer for a phone menu, Badge in SidebarItem for counts, and Breadcrumb inside the page header.

Frequently asked questions

67 components pages in all: browse them on All components.

By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .