MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / Sidebar

Function Sidebar

packages/react/src/components/sidebar.tsx:138–238  ·  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

136}
137
138function Sidebar({
139 side = "left",
140 variant = "sidebar",
141 collapsible = "offcanvas",
142 className,
143 children,
144 ...props
145}: React.ComponentProps<"div"> & {
146 side?: "left" | "right";
147 variant?: "sidebar" | "floating" | "inset";
148 collapsible?: "offcanvas" | "icon" | "none";
149}) {
150 const { isMobile, state, openMobile, setOpenMobile } = useSidebar();
151
152 if (collapsible === "none") {
153 return (
154 <div
155 data-slot="sidebar"
156 className={cn(
157 "flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground",
158 className,
159 )}
160 {...props}
161 >
162 {children}
163 </div>
164 );
165 }
166
167 if (isMobile) {
168 return (
169 <Sheet open={openMobile} onOpenChange={setOpenMobile} {...props}>
170 <SheetContent
171 data-sidebar="sidebar"
172 data-slot="sidebar"
173 data-mobile="true"
174 className="w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden"
175 style={
176 {
177 "--sidebar-width": SIDEBAR_WIDTH_MOBILE,
178 } as React.CSSProperties
179 }
180 side={side}
181 >
182 <SheetHeader className="sr-only">
183 <SheetTitle>Sidebar</SheetTitle>
184 <SheetDescription>Displays the mobile sidebar.</SheetDescription>
185 </SheetHeader>
186 <div className="flex h-full w-full flex-col">{children}</div>
187 </SheetContent>
188 </Sheet>
189 );
190 }
191
192 return (
193 <div
194 className="group peer hidden text-sidebar-foreground md:block"
195 data-state={state}

Callers

nothing calls this directly

Calls 2

cnFunction · 0.90
useSidebarFunction · 0.85

Tested by

no test coverage detected