Shadcn's new Sidebar covering (overlapping) any header or navbar #5636
Replies: 11 comments 7 replies
-
Have you tried putting the overlapped elements inside the sidebar provider? I am currently experimenting with it as well and it seems that anything outside the sidebarprovider gets overlapped. I have done it this way
|
Beta Was this translation helpful? Give feedback.
-
Hello! How are you? Sorry for this probably stupid question, but I don't fully know about front topis 😅 I have a similar issue with Sidebar component integrating ReacFlow, I get this I tried to modify Tailwind, CSS, and make a div, but nothing happened. If I remove the group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar All works fine. I change the order of in/out but, it doesn't work either. Could you solved? Thanks in advance! |
Beta Was this translation helpful? Give feedback.
-
I still have the same problem, the sidebar, when opened, covers the header of my application, even though it is a parent element of the sidebar, has anyone found a solution for this? |
Beta Was this translation helpful? Give feedback.
-
Hi @ViniciusPilati2005 ! Maybe this helps you page.tsx'use client'
import React from 'react'
import { Provider } from 'react-redux'
import { store } from '@/lib/store'
import { SidebarProvider } from '@/components/ui/sidebar'
import AppContent from '@/components/AppContent'
const App: React.FC = () => {
return (
<Provider store={store}>
<SidebarProvider>
<AppContent />
</SidebarProvider>
</Provider>
)
}
export default App AppContent.tsxreturn (
<>
<SidebarInset className="flex-grow relative">
<Toolbar />
<Canvas />
</SidebarInset>
{isSidebarVisible && <ElementSidebar element={element} />}
<Toast />
</>
) |
Beta Was this translation helpful? Give feedback.
-
Same issues, It covering |
Beta Was this translation helpful? Give feedback.
-
I was having the same issue over here. The behavior is a feature since the side bar is fixed while you scroll. If you're are okay with the sidebar rolling with the rest of the page you can try this: Find the keyword fixed in src/components/ui/sidebar.tsx and replace it for absolute. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
If needed help, i could help u
…On Wed, Feb 5, 2025 at 3:00 AM Joshua10052000 ***@***.***> wrote:
I also encountered the same problem, I just styled the <SidebarHeader />
how I will style the header and the outcome is actually great.
Untitled.png (view on web)
<https://github.com/user-attachments/assets/97ddd38d-306c-40a3-b647-c101765f89d7>
Here's how I did it.
import {
Sidebar,
SidebarContent,
SidebarHeader,
SidebarMenu,
SidebarMenuButton,
SidebarMenuItem,
SidebarProvider,
SidebarRail,
} from "@/components/ui/sidebar";
import { Input } from "@/components/ui/input";
import { Button } from "@/components/ui/button";
import { HomeIcon, MountainIcon, SearchIcon } from "lucide-react";
import { AppQueryProvider } from "@/components/globals/app-query-provider";
import { AppThemeProvider } from "@/components/globals/app-theme-provider";
import * as React from "react";
import "@/styles/globals.css";
interface RootLayoutProps {
children: React.ReactNode;
}
const RootLayout: React.FC<RootLayoutProps> = ({ children }) => {
return (
<html lang="en" suppressHydrationWarning>
<head />
<body className="bg-background font-sans antialiased">
<AppThemeProvider>
<AppQueryProvider>
<SidebarProvider>
<Sidebar collapsible="icon">
<SidebarHeader className="fixed inset-x-0 top-0 flex h-20 flex-row items-center justify-between border-b bg-background px-4 md:px-8">
<section>
<MountainIcon />
</section>
<section className="relative max-w-md flex-1">
<Input className="pr-9" placeholder="Search..." />
<Button
className="absolute right-0 top-0"
size="icon"
variant="ghost"
>
<SearchIcon />
</Button>
</section>
<section>
<Button>Sign In</Button>
</section>
</SidebarHeader>
<SidebarContent className="pt-20">
<SidebarMenu>
{[{ href: "/", label: "Home" }].map((link) => {
return (
<SidebarMenuItem key={link.href}>
<SidebarMenuButton>
<HomeIcon />
<span>{link.label}</span>
</SidebarMenuButton>
</SidebarMenuItem>
);
})}
</SidebarMenu>
</SidebarContent>
<SidebarRail />
</Sidebar>
<main className="min-h-screen pt-20">{children}</main>
</SidebarProvider>
</AppQueryProvider>
</AppThemeProvider>
</body>
</html>
);
};
export default RootLayout;
—
Reply to this email directly, view it on GitHub
<#5636 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AQH5RV5HQXA5A4B7ZRA3EOD2OFPCVAVCNFSM6AAAAABQ3KHJF2VHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTEMBWGEZTEMI>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Any update/fix for this? |
Beta Was this translation helpful? Give feedback.
-
This fixed it for me. replace all instances of |
Beta Was this translation helpful? Give feedback.
-
a solution here:
export const MySidebar = ({ ...props }: ComponentProps<typeof Sidebar>) => {
return (
<Sidebar {...props}>
{/* Your sidebar components here */}
</Sidebar>
);
};
...
<SidebarProvider>
<div className="flex flex-col w-full">
<MyHeader className="min-h-16" />
<div className="flex">
<MySidebar className="relative max-h-[calc(100dvh-64px)]" />
<SidebarInset>
{children}
</SidebarInset>
</div>
</div>
<SidebarProvider>
... |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Sidebar overlapping with header
Shadcn's new Sidebar component seems to cover any header or navbar. I was playing with the z index but can't make it work no matter how I try.
my current layout structure looks like this:
I tried to add z index in the Navbar component and Sidebar Component which is found in the app-sidebar.tsx file. But it didn't work.
Also how can I make the sidebar to scroll with the main content instead of fixed and sticky? Please help!
Beta Was this translation helpful? Give feedback.
All reactions