Skip to content

Commit

Permalink
Auto-Hide Sidebar on mobile (#9758)
Browse files Browse the repository at this point in the history
  • Loading branch information
abhimanyurajeesh authored Jan 5, 2025
1 parent ef649a4 commit 35c0436
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/components/ui/sidebar/nav-main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
SidebarMenu,
SidebarMenuButton,
SidebarMenuItem,
useSidebar,
} from "@/components/ui/sidebar";

export function NavMain({
Expand All @@ -20,6 +21,8 @@ export function NavMain({
icon?: string;
}[];
}) {
const { isMobile, setOpenMobile } = useSidebar();

return (
<SidebarGroup>
<SidebarMenu>
Expand All @@ -31,6 +34,11 @@ export function NavMain({
className={
"text-gray-600 transition font-normal hover:bg-gray-200 hover:text-green-700"
}
onClick={() => {
if (isMobile) {
setOpenMobile(false);
}
}}
>
<ActiveLink
href={link.url}
Expand Down

0 comments on commit 35c0436

Please sign in to comment.