How can I make the popover panel full width in Header? #3744
Replies: 1 comment
-
|
The For a mega-menu style full-width panel, you need to break it out of the button's positioning context. Here is how: Approach: Use a wrapper with relative positioning on the full-width container Wrap your entire header nav in a <div className="relative"> {/* full-width header container */}
<nav className="flex items-center justify-between px-6 py-4">
<Popover>
<PopoverButton>Products</PopoverButton>
<PopoverPanel
anchor="bottom start"
className="absolute left-0 right-0 w-full z-50 bg-white shadow-lg"
style={{ position: "fixed", left: 0, right: 0, width: "100vw" }}
>
<div className="mx-auto max-w-7xl px-6 py-8">
{/* mega menu content */}
</div>
</PopoverPanel>
</Popover>
</nav>
</div>Alternatively, use <PopoverPanel portal className="fixed inset-x-0 top-[64px] z-50 bg-white shadow-lg">
<div className="mx-auto max-w-7xl px-6 py-8">
{/* mega menu content */}
</div>
</PopoverPanel>Replace The portal approach is generally the cleanest for mega menus since you have full control over placement. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
How can I make the popover panel full-width in the Header? I'm making a mega menu. It doesn't work even after I put the w-full CSS class on the popover panel.
Beta Was this translation helpful? Give feedback.
All reactions