Collapsible Sidebar
Installation
npx shadcn@latest add https://uibrik.com/r/collapsible-sidebar.jsonInstall the packages
npm install @tabler/icons-react motionAdd the cn helper
Imports
cnfrom@/lib/utils, whichshadcn initcreates. Add it by hand without shadcn.Copy the source into your project
components/uibrik/collapsible-sidebar/collapsible-sidebar.tsx"use client"; // An app sidebar that folds to an icon rail. Icons stay exactly where they are // while the labels fade, so the eye never has to find them again; in the rail, // each item names itself in a tooltip and counts become dots. A highlight // slides to the current page. Toggle with the button or ⌘B / Ctrl+B. import { AnimatePresence, motion, useReducedMotion } from "motion/react"; import { IconCalendar, IconChartBar, IconFileText, IconFolder, IconHome, IconInbox, IconLayoutKanban, IconLayoutSidebarLeftCollapse, IconLayoutSidebarLeftExpand, IconSelector, IconSettings, IconUsers, } from "@tabler/icons-react"; import { createContext, useContext, useEffect, useMemo, useRef, useState, useSyncExternalStore, type ReactNode } from "react"; import { cn } from "@/lib/utils";
Adds the files to
components/uibrik/collapsible-sidebar and installs @tabler/icons-react and motion. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/collapsible-sidebar.Props
CollapsibleSidebar- defaultCollapsed
- Type boolean
- false
- Folded to the icon rail at first. When unset, it starts folded on phones and open on larger screens.
- width
- Type number
- 248
- Width when open.
- shortcut
- Type boolean
- true
- Toggle with ⌘B / Ctrl+B.
- groups
- Type { label?; items: { label; icon?; href?; badge? }[] }[]
- sample app navigation
- The navigation. Same shape across all sidebars.
- brand
- Type { name; caption?; logo? }
- –
- Workspace shown at the top.
- user
- Type { name; email? }
- –
- Account shown at the bottom.
- current / onNavigate
- Type string / (label) => void
- –
- The current page, and a callback when one is chosen.
- className
- Type string
- –
- Classes for the sidebar.
- collapsed / onCollapsedChange
- Type boolean / (collapsed) => void
- –
- Folded state, controlled.