MCPcopy Create free account
hub / github.com/code-with-antonio/nodebase / Sidebar

Function Sidebar

src/components/ui/sidebar.tsx:154–254  ·  view source on GitHub ↗
({
  side = "left",
  variant = "sidebar",
  collapsible = "offcanvas",
  className,
  children,
  ...props
}: React.ComponentProps<"div"> & {
  side?: "left" | "right"
  variant?: "sidebar" | "floating" | "inset"
  collapsible?: "offcanvas" | "icon" | "none"
})

Source from the content-addressed store, hash-verified

152}
153
154function Sidebar({
155 side = "left",
156 variant = "sidebar",
157 collapsible = "offcanvas",
158 className,
159 children,
160 ...props
161}: React.ComponentProps<"div"> & {
162 side?: "left" | "right"
163 variant?: "sidebar" | "floating" | "inset"
164 collapsible?: "offcanvas" | "icon" | "none"
165}) {
166 const { isMobile, state, openMobile, setOpenMobile } = useSidebar()
167
168 if (collapsible === "none") {
169 return (
170 <div
171 data-slot="sidebar"
172 className={cn(
173 "bg-sidebar text-sidebar-foreground flex h-full w-(--sidebar-width) flex-col",
174 className
175 )}
176 {...props}
177 >
178 {children}
179 </div>
180 )
181 }
182
183 if (isMobile) {
184 return (
185 <Sheet open={openMobile} onOpenChange={setOpenMobile} {...props}>
186 <SheetContent
187 data-sidebar="sidebar"
188 data-slot="sidebar"
189 data-mobile="true"
190 className="bg-sidebar text-sidebar-foreground w-(--sidebar-width) p-0 [&>button]:hidden"
191 style={
192 {
193 "--sidebar-width": SIDEBAR_WIDTH_MOBILE,
194 } as React.CSSProperties
195 }
196 side={side}
197 >
198 <SheetHeader className="sr-only">
199 <SheetTitle>Sidebar</SheetTitle>
200 <SheetDescription>Displays the mobile sidebar.</SheetDescription>
201 </SheetHeader>
202 <div className="flex h-full w-full flex-col">{children}</div>
203 </SheetContent>
204 </Sheet>
205 )
206 }
207
208 return (
209 <div
210 className="group peer text-sidebar-foreground hidden md:block"
211 data-state={state}

Callers

nothing calls this directly

Calls 2

cnFunction · 0.90
useSidebarFunction · 0.85

Tested by

no test coverage detected