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.jsonSidebarSidebarItemSidebarGroupSidebarFooterSidebarHeader- +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
Recent activity
- Maya Chen deployed sheen-web to production4 min ago
- Leo Park opened a pull request: Glass tokens22 min ago
- Asha Verma reported a failing build on main1 h ago
import { useState } from "react";
import { Avatar } from "@/components/sheenui/avatar/avatar";
import { Badge } from "@/components/sheenui/badge/badge";
import { Button } from "@/components/sheenui/button/button";
import { Sidebar, SidebarFooter, SidebarGroup, SidebarHeader, SidebarItem } from "@/components/sheenui/sidebar/sidebar";
// Package build (after the first npm release, or a packed tarball): import { Avatar, Badge, Button, Sidebar, SidebarFooter, SidebarGroup, SidebarHeader, SidebarItem } from "@sheenui/theme";
// This example also uses avatar, badge, button: 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
export function Example() {
const [collapsed, setCollapsed] = useState(false);
return (
<div className="flex h-[30rem] w-full gap-3">
<Sidebar aria-label="Acme workspace" collapsed={collapsed} className="shrink-0">
<SidebarHeader>
<strong className={collapsed ? "sr-only" : "text-sm"}>Acme Cloud</strong>
</SidebarHeader>
<SidebarItem href="#overview" active>Overview</SidebarItem>
<SidebarGroup label="Workspace">
<SidebarItem href="#projects" badge="12">Projects</SidebarItem>
<SidebarItem href="#reports">Reports</SidebarItem>
<SidebarItem href="#deploys" badge="3">Deployments</SidebarItem>
</SidebarGroup>
<SidebarGroup label="Team">
<SidebarItem href="#members">Members</SidebarItem>
<SidebarItem href="#billing">Billing</SidebarItem>
</SidebarGroup>
<SidebarFooter>
<SidebarItem onClick={() => setCollapsed((c) => !c)}>Collapse</SidebarItem>
</SidebarFooter>
</Sidebar>
<div className="flex min-w-0 flex-1 flex-col gap-3">
<header className="glass-2 flex items-center gap-3 rounded-sheen-xl px-3 py-2">
<h3 className="m-0 flex-1 text-sm font-semibold">Overview</h3>
<Button size="sm">New project</Button>
<Avatar name="Maya Chen" size="sm" />
</header>
<div className="grid gap-3 sm:grid-cols-3">
{["Active users 12,480", "Revenue $48.2k", "Error rate 0.42%"].map((stat) => (
<div key={stat} className="glass-2 flex flex-col gap-1 rounded-sheen-xl p-3 text-sm">
{stat}
<Badge tone="success" className="w-fit">+8.2%</Badge>
</div>
))}
</div>
</div>
</div>
);
}Files to copy
6 folders · 3 files · 4 packages
- From
theme/src/ components/sidebar/components/collapsible/components/status-icons/hooks/use-controllable.tslib/{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.tsxcomponents/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.
import { useState } from "react";
import { Sidebar, SidebarGroup, SidebarItem } from "@/components/sheenui/sidebar/sidebar";
// Package build (after the first npm release, or a packed tarball): import { Sidebar, SidebarGroup, SidebarItem } from "@sheenui/theme";
function Dot() {
return (
<svg aria-hidden width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="1.5">
<circle cx="8" cy="8" r="5.5" />
</svg>
);
}
export function CurvedSidebar() {
const [collapsed, setCollapsed] = useState(false);
return (
<div className="h-96">
<Sidebar shape="curved" morph collapsed={collapsed} aria-label="Workspace">
<SidebarGroup label="Projects">
<SidebarItem href="#alpha" active icon={<Dot />}>
Alpha
</SidebarItem>
<SidebarItem href="#beta" icon={<Dot />} badge="3">
Beta
</SidebarItem>
<SidebarItem href="#gamma" icon={<Dot />}>
Gamma
</SidebarItem>
</SidebarGroup>
<SidebarItem onClick={() => setCollapsed((c) => !c)} icon={<Dot />}>
{collapsed ? "Expand" : "Collapse"}
</SidebarItem>
</Sidebar>
</div>
);
}Sidebar props
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.
import { Button } from "@/components/sheenui/button/button";
import { Drawer, DrawerTrigger } from "@/components/sheenui/drawer/drawer";
import { DrawerContent } from "@/components/sheenui/drawer/parts/content";
import { DrawerBody, DrawerDescription, DrawerHeader, DrawerTitle } from "@/components/sheenui/drawer/parts/parts";
import { Sidebar, SidebarGroup, SidebarItem } from "@/components/sheenui/sidebar/sidebar";
// Package build (after the first npm release, or a packed tarball): import { Button, Drawer, DrawerBody, DrawerContent, DrawerDescription, DrawerHeader, DrawerTitle, DrawerTrigger, Sidebar, SidebarGroup, SidebarItem } from "@sheenui/theme";
// This example also uses button, drawer: npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/button.json https://lokendra-builds.github.io/sheenui/r/drawer.json
// Below lg, show the same sidebar in a Drawer that opens from a menu button; from lg up render <Sidebar> in the layout as usual.
export function PhoneNav() {
return (
<Drawer side="start">
<DrawerTrigger render={<Button variant="glass" />}>Menu</DrawerTrigger>
<DrawerContent>
<DrawerHeader>
<DrawerTitle>Navigation</DrawerTitle>
<DrawerDescription>Pages of the workspace</DrawerDescription>
</DrawerHeader>
<DrawerBody>
<Sidebar aria-label="Workspace">
<SidebarGroup label="Projects" defaultOpen>
<SidebarItem href="#alpha" active>Alpha</SidebarItem>
<SidebarItem href="#beta">Beta</SidebarItem>
</SidebarGroup>
<SidebarItem href="#settings">Settings</SidebarItem>
</Sidebar>
</DrawerBody>
</DrawerContent>
</Drawer>
);
}SidebarGroup props
SidebarItem props
Other parts
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
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
Related pages
67 components pages in all: browse them on All components.
By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .