BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/muffled-ui-registry/sidebar

Sidebar

muffled-ui-registry/sidebar
FreeComponent

Collapsible app navigation on ink and paper. Off-canvas mobile sheet, icon collapse, hairline borders.

Live preview

live · rendered by the registry
Rendered by muffled-ui-registry on their own page — this is the component running, not a screenshot of it.

Install it

npx shadcn@latest add https://ui.muffled.studio/r/sidebar.json

Source

registry/ui/sidebar.tsxui.muffled.studio/r/sidebar.json · first 6 KB
1import * as React from "react"
2import { mergeProps } from "@base-ui/react/merge-props"
3import { useRender } from "@base-ui/react/use-render"
4import { cva, type VariantProps } from "class-variance-authority"
5
6import { useIsMobile } from "@/registry/hooks/use-mobile"
7import { cn } from "@/registry/lib/surface"
8import { Button } from "@/registry/ui/button"
9import { Input } from "@/registry/ui/input"
10import { Separator } from "@/registry/ui/separator"
11import {
12 Sheet,
13 SheetContent,
14 SheetDescription,
15 SheetHeader,
16 SheetTitle,
17} from "@/registry/ui/sheet"
18import { Skeleton } from "@/registry/ui/skeleton"
19import {
20 Tooltip,
21 TooltipContent,
22 TooltipTrigger,
23} from "@/registry/ui/tooltip"
24import { PanelLeftIcon } from "lucide-react"
25
26const SIDEBAR_COOKIE_NAME = "sidebar_state"
27const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7
28const SIDEBAR_WIDTH = "16rem"
29const SIDEBAR_WIDTH_MOBILE = "18rem"
30const SIDEBAR_WIDTH_ICON = "3rem"
31const SIDEBAR_KEYBOARD_SHORTCUT = "b"
32
33type SidebarContextProps = {
34 state: "expanded" | "collapsed"
35 open: boolean
36 setOpen: (open: boolean) => void
37 openMobile: boolean
38 setOpenMobile: (open: boolean) => void
39 isMobile: boolean
40 toggleSidebar: () => void
41}
42
43const SidebarContext = React.createContext<SidebarContextProps | null>(null)
44
45function useSidebar() {
46 const context = React.useContext(SidebarContext)
47 if (!context) {
48 throw new Error("useSidebar must be used within a SidebarProvider.")
49 }
50
51 return context
52}
53
54function SidebarProvider({
55 defaultOpen = true,
56 open: openProp,
57 onOpenChange: setOpenProp,
58 className,
59 style,
60 children,
61 ...props
62}: React.ComponentProps<"div"> & {
63 defaultOpen?: boolean
64 open?: boolean
65 onOpenChange?: (open: boolean) => void
66}) {
67 const isMobile = useIsMobile()
68 const [openMobile, setOpenMobile] = React.useState(false)
69
70 // This is the internal state of the sidebar.
71 // We use openProp and setOpenProp for control from outside the component.
72 const [_open, _setOpen] = React.useState(defaultOpen)
73 const open = openProp ?? _open
74 const setOpen = React.useCallback(
75 (value: boolean | ((value: boolean) => boolean)) => {
76 const openState = typeof value === "function" ? value(open) : value
77 if (setOpenProp) {
78 setOpenProp(openState)
79 } else {
80 _setOpen(openState)
81 }
82
83 // This sets the cookie to keep the sidebar state.
84 document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`
85 },
86// … truncated

What it pulls in

npm packages

  • class-variance-authority
  • @base-ui/react
  • lucide-react

Other registry items

  • @muffled/surface
  • @muffled/button
  • @muffled/separator
  • @muffled/tooltip
  • @muffled/input
  • @muffled/skeleton
  • @muffled/use-mobile

Files it writes

  • registry/ui/sheet.tsx
  • registry/ui/sidebar.tsx

Facts

Registry
muffled-ui-registry
Type
registry:ui
Access
Free
Files written
2
Licence
the repository states none
First indexed
2026-08-02
Last confirmed
yesterday

Go to the source

Docs on muffled-ui-registry ui.muffled.studio muffled-studio/muffled.ui on GitHub Raw registry item This item as JSON

More from muffled-ui-registry

All 55 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Accordionaccordionmuffled-ui-registryComponentsFree2 deps
Alertalertmuffled-ui-registryComponentsFree1 dep
Alert Dialogalert-dialogmuffled-ui-registryComponentsFree1 dep
Avataravatarmuffled-ui-registryComponentsFree1 dep
Badgebadgemuffled-ui-registryComponentsFree2 deps
Breadcrumbbreadcrumbmuffled-ui-registryComponentsFree2 deps
Buttonbuttonmuffled-ui-registryComponentsFree2 deps
Button Groupbutton-groupmuffled-ui-registryComponentsFree2 deps
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex