Skip to content

shadcn.io is an independent project built on shadcn/ui

Mixed Links and Dropdowns Navigation Menu for React

A site menu that mixes Products and Support dropdowns with Pricing and About as plain links.

The bar shows Products, Pricing, About, and Support. Products lists Analytics, Marketing, and Commerce. Support lists Help Center, Contact Us, and Status. Pricing and About are links.

Mix links and dropdowns when only some items have children. If every item is one action, use a Menubar. In React, Base UI closes the open panel when you press Escape.

Preview

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.
Use email insteadNo credit card

Anatomy

Navigation Menu anatomy: list, trigger, indicator, content, link

Usage

<div className="w-full max-w-md rounded-md border bg-background p-px">
  <NavigationMenu>
    <NavigationMenuList>
      <NavigationMenuItem>
        <NavigationMenuTrigger>Products</NavigationMenuTrigger>
        <NavigationMenuContent>
          <div className="flex w-48 flex-col">
            {products.map((item) => (
              <NavigationMenuLink
                key={item.label}
                render={<Link href={item.href} />}
              >
                {item.label}
              </NavigationMenuLink>
            ))}
          </div>
        </NavigationMenuContent>
      </NavigationMenuItem>
      <NavigationMenuItem>
        <NavigationMenuLink
          className={navigationMenuTriggerStyle()}
          render={<Link href="#" />}
        >
          Pricing
        </NavigationMenuLink>
      </NavigationMenuItem>
      <NavigationMenuItem>
        <NavigationMenuLink
          className={navigationMenuTriggerStyle()}
          render={<Link href="#" />}
        >
{/* The rest of the file is under Installation. */}

FAQ

How do plain links match the triggers?

Pricing and About take navigationMenuTriggerStyle() as their class, the same height, padding and hover as the triggers, so the row reads as one menu.

What is in each dropdown?

A w-48 column of NavigationMenuLinks: Analytics, Marketing and Commerce under Products; Help Center, Contact Us and Status under Support.

Can links and dropdowns go in any order?

Yes. Each is its own NavigationMenuItem, and the list keeps the order you write them in.

How do the links use my router?

Each link is your router's link rendered through NavigationMenuLink, so it keeps the menu's styles and focus handling. NavigationMenuLink takes the Next.js Link through render, as in render={<Link href="#" />}.

How does the menu work from the keyboard?

Tab moves between the triggers and the links, Enter or Space opens a trigger's panel, and Escape closes it and returns focus to the trigger. The root is a nav, so screen readers list it as a navigation landmark.

How do I mark the current page?

Set aria-current="page" on the NavigationMenuLink that matches the route, and style it with the aria-[current=page]: variant. active on NavigationMenuLink sets it for you.

API Reference

Navigation Menu

No extra props in this demo. The rest is on the Navigation Menu page.