App navigation with groups, pinned shortcuts and an icon rail: the active marker is a ball that rolls down the rail to the item you pick and squashes into place.
Click meTap me
Overview › Inbox
Inbox
Refund requested on #10459:41
Payout scheduled for Friday8:15
Team invite acceptedMon
sidebar · , lively
sidebar-demo.tsx
When to use
Use it as the main navigation of a dashboard or admin app: groups of destinations, a current item, collapsible groups and an account row. Cmd+B collapses it to an icon rail and on phones it becomes a drawer.
When not to use
For a handful of top-level pages use Morphing Navbar or Tabs. For navigating a deep folder hierarchy use Tree View.
Use it as the main navigation of a back-office app, a dashboard or an admin console: groups of
destinations, a current item, a collapsible group or two, an account row at the bottom. The current
item is marked by a ball on a hairline rail: pressing another item stretches the ball toward it, on
release it rolls down the rail, passes the items in between and squashes against the item it lands
on. ⌘B (Ctrl+B) collapses the panel to an icon rail: labels fade out in the first part of the move,
icons stay centred where they were and tooltips take over the names (with the group above them).
People keep their own shortcuts: a pin on hover adds a page to the Pinned group, where they drag
the pins into order. Unread counts roll to their new value, and in rail mode a dot on the icon
stands for them. For a handful of top-level pages use a navbar or tabs instead.
The shape follows shadcn's sidebar: Sidebar.Provider holds the state (current item, rail,
mobile drawer) and lays out Sidebar.Root (the nav) beside Sidebar.Inset (the main). Every
state is controlled or uncontrolled. Three presets set the layout:
rail (default): a flush panel with a hairline edge that collapses to a 48 px icon rail.
floating: a detached tile 8 px from the edges with a rim, a soft tinted shadow and a top
highlight; it collapses the same way. For analytics dashboards on a full-bleed canvas.
inset: a flush panel on the sidebar surface with the page content inset in a tile beside it.
When the app changes activeItem itself (a redirect, a link in the page), the ball travels the same
way, without the charge. If the current item sits inside a closed group, the ball parks beside the
group's trigger. Wrap header and footer text in Sidebar.Text so it leaves with the labels.
Below mobileBreakpoint (the shell's width, 768 px by default) the sidebar becomes a drawer from the
screen edge, ball included. The sidebar reads shadcn's --sidebar-* tokens and falls back to the
base tokens in themes that do not define them.
Mark items pinnable and place Sidebar.Pinned where the shortcuts belong (usually first in
Sidebar.Content). Hovering a pinnable row shows a pin at its end (on touch, on the current row);
pressing it, or P on the focused row, adds a copy of the item to the Pinned group. The copy is the
same destination: same icon, same badge, your link when the item uses asChild. Drag a copy (or
Alt + ArrowUp/ArrowDown) to reorder; its pin unpins it. The ball goes to the row you used, the copy
or the original, so it never jumps to a part of the list you did not touch. Keep the list per
person with pinned and onPinnedChange (or read it with useSidebar().pinned); defaultPinned
seeds it. Without empty, the group stays hidden until something is pinned.
badge takes a count or a short status. When a count changes, the old value rolls out and the new
one rolls in (up when it grows, down when it shrinks); a badge that appears or goes away pops in or
out. In rail mode the badge leaves with the label and a small dot on the icon keeps the news visible.
The preview at the top: Orders and Billing are pinned (Billing lives in the closed Settings group,
the pin keeps it one click away). Hover any row to pin it, drag the pins to reorder them. In the
Inbox, reading a message counts the sidebar badge down.
The floating preset beside KPI tiles. The Projects group loads (three placeholder rows), then its
items cascade in; Refresh loads it again; Saved views shows its empty line; Exports is disabled.
The inset preset collapsed to the icon rail by default. Focus or hover an icon to see its name in
a tooltip; ⌘B or the toggle expands the labels with a cascade.
Under mobileBreakpoint (768 px of the shell by default) the sidebar becomes a drawer from the
screen edge. Open it with the toggle: the ball sits beside the current item and picking another
one throws it there; Escape, the overlay or a swipe toward the edge (past a third of its width,
or a flick) closes the drawer. Its rows fill the drawer, so nothing overflows at 320 px.
nav labelled "Main" by default (pass aria-label); each group is a ul labelled by its heading
or its trigger. Items are buttons or, with asChild, your links. The current item has
aria-current="page", the capsule and a heavier weight, so it is never conveyed by the ball alone.
The ball, the rail hairline, the hover capsule and the rail-mode group rules are aria-hidden.
In rail mode the labels stay in the DOM (faded and clipped), so every icon keeps its accessible
name; the tooltip is a visual extra.
Collapsible groups use Radix Collapsible: the trigger is a button with aria-expanded and
aria-controls; a closed group's items are inert.
Disabled items keep aria-disabled="true": discoverable, never activated.
The pin is a toggle button named Pin <label> with aria-pressed, outside the row's tab order
(P on the focused row does the same; the row announces it with aria-keyshortcuts). Pinning,
unpinning and moving a pin are announced in a polite live region ("Orders pinned", "Orders,
position 1 of 2"). The Pinned group is a ul labelled by its heading.
In rail mode an item's tooltip names its group above the label; the unread dot is aria-hidden
(the badge text stays in the item's accessible name).
The toggle has aria-expanded. The mobile drawer is a Radix Dialog: focus is trapped and returns
to the trigger on close.
The ball still glides to the new item, in the short fade time, with no charge stretch and no squash:
a marker that moves is easier to follow than one that jumps. Rows do not sink. Groups open and the
rail collapses in the same fade while labels fade in place. The mobile drawer fades in and out in place instead of
sliding across the screen. Badge counts and new pins fade in place without rolling or popping, and
the pin stands upright without leaning. At rest the sidebar is identical: the
ball on its rail with its highlight, the active capsule and the preset's depth.
The component is 12.2 kB gzip of our code (with the shared ball, beats and pill helpers).
Third-party: motion, @radix-ui/react-collapsible, @radix-ui/react-tooltip and
@radix-ui/react-dialog (the mobile drawer), each a few kB gzip and shared with other components.
Nothing runs at rest. A trip animates one transform on the ball (position and scale on nested
layers); collapsing animates the panel's width on the calm spring and the labels' opacity. Stops are
measured from layout offsets on change and from one ResizeObserver; the drawer mounts only when
open. A pinned copy re-renders only when its item's icon, label or badge changes.
Technical sheet
Motion
calm
260 ms · bounce 0
lively
400 ms · bounce 0.3
playful
540 ms · bounce 0.45
Main spring of each temperament. Set it with the temperament prop or MotionKitProvider; the default is lively.
The ball glides to the new item in the short fade time, no stretch or squash; groups, the rail and the drawer fade in place; badge counts and new pins fade without rolling or popping.
Keyboard
Tab / Shift + Tab
Into the sidebar (lands on the current item), then out to the page
ArrowDown / ArrowUp
Next or previous visible item or group trigger
Home / End
First or last visible item
ArrowRight
On a closed group opens it; on an open group moves into its first item
ArrowLeft
On an item inside a group returns to the trigger; on an open group closes it
Enter / Space
Activates the item (the ball travels to it) or toggles a group
P
Pins or unpins the focused pinnable item
Alt + ArrowUp / ArrowDown
Moves the focused pinned copy up or down
⌘ B / Ctrl + B
Collapses or expands the icon rail
Escape
Closes the mobile drawer and returns focus to the trigger
Browsers
Last 2 versions of Chrome, Edge, Firefox and Safari (iOS 16.4+)