Mega Menu
Full-width tailwind mega menu with a multi-column dropdown panel and featured card.
<div class="relative w-full bg-white border-b border-slate-200">
<div class="max-w-7xl mx-auto px-4 h-16 flex items-center gap-8">
<a href="#" class="text-lg font-black text-slate-900">Brand</a>
<button type="button" class="text-sm font-bold text-indigo-600 flex items-center gap-1">
Products
<svg class="w-4 h-4" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M19 9l-7 7-7-7"/></svg>
</button>
<a href="#" class="text-sm font-semibold text-slate-600 hover:text-slate-900">Pricing</a>
</div>
<div class="absolute left-0 right-0 top-full bg-white border-b border-slate-200 shadow-xl">
<div class="max-w-7xl mx-auto px-4 py-8 grid grid-cols-2 md:grid-cols-4 gap-8">
<div>
<p class="text-xs font-black uppercase tracking-wider text-slate-400 mb-3">Design</p>
<ul class="space-y-2.5 text-sm font-medium text-slate-600">
<li><a href="#" class="hover:text-indigo-600">UI Kits</a></li>
<li><a href="#" class="hover:text-indigo-600">Templates</a></li>
<li><a href="#" class="hover:text-indigo-600">Icons</a></li>
</ul>
</div>
<div>
<p class="text-xs font-black uppercase tracking-wider text-slate-400 mb-3">Develop</p>
<ul class="space-y-2.5 text-sm font-medium text-slate-600">
<li><a href="#" class="hover:text-indigo-600">Components</a></li>
<li><a href="#" class="hover:text-indigo-600">API Docs</a></li>
<li><a href="#" class="hover:text-indigo-600">Changelog</a></li>
</ul>
</div>
<div class="col-span-2 rounded-2xl bg-indigo-600 p-6 text-white">
<p class="font-bold">New: Component library v2</p>
<p class="text-sm text-indigo-100 mt-1">120 new blocks, dark mode included.</p>
<a href="#" class="inline-block mt-3 text-xs font-bold bg-white text-indigo-700 px-3 py-1.5 rounded-lg">Explore</a>
</div>
</div>
</div>
</div>Free to use in personal and commercial projects. No attribution required.
Variants
Same component, different looks. Preview each one live and copy the code you like.
Dark
For dark navbars on developer tools and dashboards.
Links only
Three link columns with no promo card when there is nothing to feature.
About this mega menu
A tailwind mega menu is the full-width dropdown that big sites use when a simple link list is not enough: product categories, documentation sections, and featured promos, all visible at once. The mega menu dropdown html pattern beats nested flyouts because users see every option without hovering through layers, which is why e-commerce and SaaS sites with deep catalogs rely on it.
This full width dropdown menu css is a relative header with an absolutely positioned panel stretching edge to edge below it. Inside, a four-column grid holds link groups with small uppercase headings, and a featured card spans two columns for the promo slot. The panel uses a soft shadow-xl so it lifts off the page, and the grid collapses to two columns on small screens.
Reserve the mega menu for nav items with genuinely deep content; using it for three links feels empty. Group links under clear headings and cap each column at six or seven items. On mobile, convert the panel into an accordion inside the hamburger menu instead of trying to fit four columns on a phone.
Deep catalogs cannot fit in a narrow dropdown. E-commerce categories, documentation sections, university departments: a single-column list forces visitors through hover mazes, one level at a time. The mega menu lays the whole map out at once, turning navigation into browsing. Visitors discover sections they were not looking for, which is exactly what a good menu should enable.
The header is relatively positioned and the panel is absolutely positioned with left-0 right-0 top-full, stretching edge to edge beneath it. Inside, a four-column grid holds link groups under small uppercase headings, with a featured card spanning two columns for the promo slot. The uppercase micro-headings act as signposts: they organize without competing with the links. A soft shadow lifts the panel off the page so it reads as an overlay.
Add a 150 to 200ms hover-intent delay before opening, so cursors merely passing over the nav don't flash the panel. Keep the panel open across a small mouse-travel gap between trigger and panel; the classic triangle tolerance from Amazon's menu is still the gold standard. For keyboard users, open on focus and let Escape close it, returning focus to the trigger. On touch devices, the first tap opens the panel and the second tap follows the link; document this behavior because it surprises.
Test the panel between 768 and 1024 pixels wide. An absolutely positioned full-width panel inside a relative container can overflow the viewport at medium widths, creating a horizontal scrollbar and a menu that extends past the screen edge. Constrain the inner content with a max width and check the panel at tablet sizes, not just desktop and phone. The breakpoints you skip are the ones your visitors use.
Where to use it
- ✓ E-commerce category navigation
- ✓ SaaS product and docs menus
- ✓ News and media section browsers
- ✓ University and enterprise sites
Customization tips
Widen the panel content with max-w-7xl or let it span full bleed for very wide catalogs. Add icons beside each link for scannability, or thumbnails in the featured card. Trigger it on hover for desktop with group/group-hover, but keep click support for touch devices.
Design notes
When to use
A mega menu fits large sites where a simple link list cannot hold the structure: e-commerce catalogs with many categories, documentation with deep sections, and universities with dozens of departments. Showing everything at once lets visitors scan and jump instead of drilling down level by level. The featured card adds room for a promo or a getting started guide.
What to avoid
Do not build a mega menu for a site with five pages, because a full-width panel for a handful of links is pure theater. Avoid hover-only triggers, since touch users and keyboard users get locked out. And do not let the panel cover your call to action or overlap awkwardly on medium screens.
Accessibility
Support keyboard open and close with Escape, arrow-key movement between columns, and proper focus management when the panel opens. Never rely on hover alone, and give the panel an accessible name tied to its trigger.
Frequently asked questions
How do I create a tailwind mega menu dropdown?
Make the header relative and the panel absolute left-0 right-0 top-full. Lay the panel content out as a grid of link columns with headings. Show and hide it with a click handler (plus hover on desktop), and close it on Escape or an outside click.
Should a mega menu open on hover or click?
Click is safer: hover menus misfire when the cursor crosses the trigger and they exclude touch users entirely. If you add hover for desktop, keep click as the real trigger and add a small open delay so passing cursors do not flash the panel.
How is a mega menu different from a regular dropdown?
A regular dropdown is a narrow single-column list under one trigger. A mega menu is a full-width, multi-column panel that can hold grouped links, images, and promo cards. Use a dropdown for a handful of links and a mega menu when you have categories to browse.
How do I make a mega menu full width in Tailwind?
Position the panel absolutely with left-0 and right-0 inside a relatively positioned nav container, then center the inner content with max-w-7xl mx-auto. Lay the links out in a 3 or 4 column grid with clear headings per column. Full-width panels need a max width on large screens or the columns stretch awkwardly.
How do I make a mega menu keyboard accessible?
Open it on focus as well as hover, move focus into the panel, and close it on Escape. Use aria-expanded on the trigger and keep tab order logical through the links. A short delay before closing on mouse leave also helps pointer users who move slowly.
How do I keep a mega menu open while moving the mouse to it?
Remove any gap between the trigger and the panel, or bridge it with padding-top on the panel so the hover never breaks. Alternatively add a short open delay and a close delay of about 150 to 300 milliseconds. The gap between trigger and panel is the number one cause of flickering mega menus.