A composable, themeable and customizable sidebar component.
pnpm dlx shadcn@latest add https://ui.ahmet.studio/r/sidebar
The difference is that this sidebar allows you to have 2 sidebars , one on the left and one on the right but, both are independently controllable by providing the side
prop to the Sidebar
component.
const Sidebar = () => { return ( <SidebarProvider> <AppSidebar side="left" /> <SidebarInset className="h-full overflow-hidden"> <div className="p-4">Hello World</div> </SidebarInset> <RightSidebar side="right" /> </SidebarProvider> ); }; export default Sidebar;
SidebarContext
SidebarContext
+ SidebarInnerContext
Property | Default Sidebar | Dual Sidebar |
---|---|---|
defaultOpen | ✅ | ✅ (legacy support) |
open | ✅ | ✅ (legacy support) |
onOpenChange | ✅ | ✅ (legacy support) |
defaultOpenLeft | ❌ | ✅ |
defaultOpenRight | ❌ | ✅ |
openLeft | ❌ | ✅ |
openRight | ❌ | ✅ |
onOpenChangeLeft | ❌ | ✅ |
onOpenChangeRight | ❌ | ✅ |
Cmd/Ctrl + B
- Toggle sidebarCmd/Ctrl + B
- Toggle left sidebarCmd/Ctrl + N
- Toggle right sidebaruseSidebar() // Returns single sidebar state
useSidebar() // Returns current sidebar state (based on context) useSidebarWithSide(side: "left" | "right") // Returns specific sidebar state
Both files export the same set of components, with one key difference:
side?: "left" | "right"
prop to control which sidebar to togglesidebar_state
cookiesidebar_state_left
cookiesidebar_state_right
cookie{ state: "expanded" | "collapsed" open: boolean setOpen: (open: boolean) => void openMobile: boolean setOpenMobile: (open: boolean) => void isMobile: boolean toggleSidebar: () => void }
{ left: SidebarState // same as Context Value of Default Sidebar right: SidebarState // same as Context Value of Default Sidebar isMobile: boolean }
Both implementations handle mobile sidebars identically using sheet overlays, but the Dual Sidebar maintains separate mobile states for left and right sidebars.
Choose Default Sidebar when:
Choose Dual Sidebar when:
If migrating from Default Sidebar to Dual Sidebar:
defaultOpen
, open
, onOpenChange
) are supporteduseSidebar()
hook works similarly but returns the "current" sidebar based on contextOn This Page
InstallationUsageCore Architectural DifferencesDefault SidebarDual SidebarProvider Props ComparisonKeyboard ShortcutsAvailable HooksDefault SidebarDual SidebarComponent DifferencesSidebarTriggerCookie StorageState ManagementDefault Sidebar Context ValueDual Sidebar Context ValueMobile BehaviorUse CasesMigration Notes