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