React Mega Menu Navbar with Animated Icon Dropdowns
ProA left aligned header where the brand and the link rail sit together and the actions sit far right. Hover Features, Templates or Docs and one panel slides in under the rail, listing each destination as an icon, a bold label and a line of description.
A compact mega menu rather than a wall of columns
Navbar with Mega Menu Dropdown is a React and Tailwind CSS navbar whose top level links open a mega menu panel of described links, each with its own icon, instead of a bare list of words. It is one client component for Next.js or any React project and includes a responsive drawer for phones.
Big multi column mega menus suit stores and enterprise sites with dozens of destinations. Most software products have eight to twelve, and for those a single 340px panel with an icon and a sentence per row reads faster, because the eye moves down one column instead of across four. That is the shape this block commits to.
The panel is one shared shell. Moving the pointer from Features to Docs does not close one dropdown and open another; the contents spring sideways by 30px from the direction you came from while the shell stays put, which makes the menu feel like one surface.
How the dropdown is built
Left aligned rail
The logo and the links share the left cluster, with a 24px gap after the brand. The actions are pushed to the right edge. This is the common SaaS header layout rather than a centred one.
Shared panel
A 340px white card with a 2xl radius and a long soft shadow, anchored to the left edge of the rail. In dark mode it turns deep navy with a faint white ring.
Direction aware switch
The block remembers the index of the previous menu. Moving right slides new content in from the right, moving left from the left, using a spring with stiffness 350 and damping 30.
Described rows
Each row is an icon tile, a label, a description and a small chevron. Rows spring in 40ms apart and the tile inverts on hover.
Grace period
Leaving the rail starts a 120ms timer instead of closing at once, so a diagonal move from a link into the panel does not drop the menu.
Accordion drawer
On phones every group becomes an expandable row showing labels and descriptions, followed by Sign in and the main button.
Is a compact mega menu enough
Use it when
- You have two or three groups of three to five destinations and each one benefits from a short explanation.
- You want the familiar left aligned header that most software sites use.
- Your menu labels can map to icons you supply, or you are happy with the two letter fallback.
- You need a mobile drawer that keeps the same grouping as desktop.
Skip it when
- You need multiple columns, promo images or a full width panel. Look at the centred navbar with featured cards or build a wider shell.
- Keyboard navigation into the menus is a launch requirement. The panels open on hover only until you add the handlers below.
- Your brand cannot live with an amber button, or you do not want to edit its classes in the file.
- The header must be a drop in with no file edits, since a demo headline renders under it.
Set up the groups, then remove the demo
Every group is a link with an items array, and every item takes a label, a description and an href. Icons are looked up from a FEATURE_ICONS map keyed by label, so add your own SVGs to that map using your new labels, or leave it and accept the two letter tiles. A link without items is a plain entry.
Delete the demo hero below the header, the Clarity at every click headline, which is part of the component. The main button is amber with white text, and white on that amber is low contrast, so change bg-[#eab308] and hover:bg-[#f59e0b] to your brand colour or switch the text to near black.
npx wensity@latest add navbar-with-mega-menu-dropdown --type block
import { PrismNavbar } from "@/components/wensity/blocks/navbar-with-mega-menu-dropdown";export function Header() {return (<PrismNavbarbrandName="Ledgerly"links={[{label: "Product",href: "/product",items: [{ label: "Invoices", description: "Send and track in one place", href: "/invoices" },{ label: "Expenses", description: "Snap receipts, auto categorise", href: "/expenses" },{ label: "Reports", description: "Monthly close without spreadsheets", href: "/reports" },],},{label: "Developers",href: "/developers",items: [{ label: "API reference", description: "REST endpoints and webhooks", href: "/api" },{ label: "SDKs", description: "TypeScript, Python and Go", href: "/sdks" },],},{ label: "Pricing", href: "/pricing" },]}primaryCta={{ label: "Open an account", href: "/signup" }}/>);}
Props
| Prop | Type | Default | Description |
|---|---|---|---|
links | PrismNavbarLink[] | Features, Templates, Docs, Pricing | Groups with items open the panel. Every item is a row with a label and an optional description. |
logo | ReactNode | - | Replaces the geometric sample mark next to the brand name. |
brandName | string | "Prism" | Wordmark text and the label of the home link. |
primaryCta | { label: string; href: string } | Get started free | The amber button at the far right and at the end of the drawer. |
secondaryCta | { label: string; href: string } | Sign in | Text link beside the button, hidden on the narrowest phones. |
Known limits of this mega menu
Hover is the only trigger
Rail entries are buttons with onMouseEnter, so a keyboard user can focus them but never open a panel. Add click and focus handlers, aria-expanded on the trigger, and an Escape handler that clears activeMenu.
Plain entries need anchors
Pricing and any other entry without items render as buttons on desktop and ignore their href. They link correctly in the drawer only. Swap them for anchors in the rail.
Panel position
The panel always opens under the start of the rail, not under the hovered word. With four short links this reads well; with long labels the panel can sit far from the link that opened it.
Springs ignore reduced motion
The sideways switch and the row stagger are springs with no prefers-reduced-motion check. MotionConfig with reducedMotion set to user removes the movement and keeps the fades.
Light on resources
One passive scroll listener and a close timer. Nothing runs between interactions.
Block details
- Category
- Navbars
- Renders
- JavaScript animation. Paints first, then animates
- Theme
- Follows the site theme in light and dark
- Dependencies
clsxframer-motiontailwind-merge- Source
- 519 lines, 25 KB in one file
- Install
wensity add navbar-with-mega-menu-dropdown --type block- Tags
- light, dark, floating-card, product, staggered, premium
- Last updated


