Patched Sidebar Component.
- Added
openMobileprop, mobile sidebar does not useopenprop - Fix for mobile sidebar not closing upon routing
https://github.com/shadcn-ui/ui/issues/5561 - Fix for
--sidebar-width-mobile
https://github.com/shadcn-ui/ui/issues/5509
<SidebarProvider
open={isSidebarEnabled ? undefined : false}
openMobile={isSidebarEnabled ? undefined : false}
style={
{
"--sidebar-width": "12rem",
"--sidebar-width-mobile": "12rem",
} as CSSProperties
}
>export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
const { setOpenMobile } = useSidebar();
const pathname = usePathname();
useEffect(() => {
setOpenMobile(false);
}, [pathname, setOpenMobile]);
return (
<Sidebar {...props} >
'...'
</Sidebar>
);
}Usage
Install package
pnpm dlx shadcn@latest add https://zerocn.zeroopensource.org/r/sidebar.jsonInstall package (workspace)
pnpm --filter=$WORKSPACE shadcn add https://zerocn.zeroopensource.org/r/sidebar.json