Sidebar
App navigation that collapses to icons or slides away, drop-in compatible with shadcn's Sidebar. There are no divider lines: the panel is a tonal surface, groups are separated by space, and the active item sits on a pill that springs from item to item. On phones it becomes a sheet.
Install
npx shadcn@latest add @nelumbo/sidebarApp sidebar
A team switcher in a dropdown menu, grouped navigation with icons, a badge, an item action on hover, a collapsible sub-menu and a user menu in the footer. Pick another item and the pill springs over; open and close Projects to see the sub-menu slide and its chevron turn. The trigger slides the whole sidebar away.
Icon collapsible
collapsible=icon shrinks the sidebar to a rail of icons. The width eases on a spring while labels fade; the icons never move. The Inbox count becomes a dot on its icon, hovering an item names it in a tooltip, and the sub-menu folds into its parent. The strip on the sidebar's edge also toggles.
Floating
The panel stands off the edge with rounded corners and elevation instead of meeting it.
Inset
The page content becomes a raised, rounded card set into the sidebar's surface. The margin eases when the sidebar collapses.
Loading
SidebarMenuSkeleton stands in for rows that are still coming. Its widths are stable between server and client.
Usage
Same structure as shadcn. Put a SidebarProvider at the top of the layout; use Nelumbo's Icon inside buttons.
import { Sidebar, SidebarProvider, SidebarTrigger, SidebarInset, SidebarContent, SidebarGroup, SidebarGroupLabel, SidebarGroupContent, SidebarMenu, SidebarMenuItem, SidebarMenuButton, SidebarMenuBadge, SidebarCollapsible, SidebarCollapsibleTrigger, SidebarCollapsibleContent, SidebarMenuChevron, SidebarMenuSub, SidebarMenuSubItem, SidebarMenuSubButton,} from "@/components/ui/sidebar"<SidebarProvider> <Sidebar collapsible="icon"> <SidebarContent> <SidebarGroup> <SidebarGroupLabel>Platform</SidebarGroupLabel> <SidebarGroupContent> <SidebarMenu> <SidebarMenuItem> <SidebarMenuButton asChild isActive={pathname === "/inbox"} tooltip="Inbox"> <Link href="/inbox"><Icon name="inbox" /><span>Inbox</span></Link> </SidebarMenuButton> <SidebarMenuBadge>12</SidebarMenuBadge> </SidebarMenuItem> <SidebarCollapsible asChild defaultOpen> <SidebarMenuItem> <SidebarCollapsibleTrigger asChild> <SidebarMenuButton tooltip="Projects"> <Icon name="folder" /><span>Projects</span><SidebarMenuChevron /> </SidebarMenuButton> </SidebarCollapsibleTrigger> <SidebarCollapsibleContent> <SidebarMenuSub> <SidebarMenuSubItem> <SidebarMenuSubButton asChild isActive><Link href="/p/roadmap"><span>Roadmap</span></Link></SidebarMenuSubButton> </SidebarMenuSubItem> </SidebarMenuSub> </SidebarCollapsibleContent> </SidebarMenuItem> </SidebarCollapsible> </SidebarMenu> </SidebarGroupContent> </SidebarGroup> </SidebarContent> </Sidebar> <SidebarInset> <SidebarTrigger /> {children} </SidebarInset></SidebarProvider>Inside a card or preview
A sidebar is fixed to the viewport by default. Pass contained to the provider to lay it out inside the provider's box instead, give the box a height, and scope the shortcut so it doesn't act page-wide (this page does both).
<div className="h-[41rem] overflow-hidden rounded-3xl"> <SidebarProvider contained shortcutScope="provider" cookieName={false}> … </SidebarProvider></div>Props
Every other shadcn part (Header, Footer, Content, Group, GroupLabel, GroupAction, GroupContent, Menu, MenuItem, MenuBadge, MenuSkeleton, MenuSub, MenuSubItem, Input, Separator, Rail, Trigger) takes the same props as shadcn's.
| Prop | Type | Default | Notes |
|---|---|---|---|
SidebarProvider defaultOpen / open / onOpenChange | boolean | true | Uncontrolled or controlled open state |
SidebarProvider contained | boolean | false | Lay the sidebar out inside the provider (absolute) instead of the viewport (fixed) |
SidebarProvider keyboardShortcut | string | false | "b" | Ctrl/Cmd plus this key toggles; false turns it off |
SidebarProvider shortcutScope | "window" | "provider" | "window" | Provider: only while focus is inside it |
SidebarProvider cookieName | string | false | "sidebar_state" | Cookie that remembers the open state |
Sidebar side | "left" | "right" | "left" | Which edge |
Sidebar variant | "sidebar" | "floating" | "inset" | "sidebar" | Attached, lifted with elevation, or set into a card page |
Sidebar collapsible | "offcanvas" | "icon" | "none" | "offcanvas" | Slides away, shrinks to icons, or never collapses |
SidebarMenuButton isActive | boolean | false | Tonal pill, filled icon, aria-current=page |
SidebarMenuButton tooltip | string | TooltipContent props | Shown while collapsed to icons | |
SidebarMenuButton size | "sm" | "default" | "lg" | "default" | 40px rows; lg (48px) is for avatars and two lines |
SidebarMenuButton variant | "default" | "outline" | "default" | Outline is a raised tile |
SidebarMenuAction showOnHover | boolean | false | Reveal on hover or focus |
SidebarMenuSubButton size / isActive | "sm" | "md" / boolean | "md" | |
SidebarInset asChild | boolean | false | Render your own element instead of main |
SidebarCollapsible / Trigger / Content | Radix Collapsible | Sub-menu wrapper with the accordion height animation | |
useSidebar() | object | state, open, setOpen, openMobile, setOpenMobile, isMobile, toggleSidebar |