Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Navigation Menu examples · Standard

Simple Navigation Navigation Menu for React

A navigation menu with Products and Solutions dropdowns and a Pricing link.

Framework
UI library

The smallest site header menu: Products and Solutions open a short list of links each, and Pricing goes straight to its page. Start here and grow the panels as your site does.

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.

FAQ

Which parts make up the menu?

NavigationMenu and NavigationMenuList hold one NavigationMenuItem per entry. A dropdown is a NavigationMenuTrigger with a NavigationMenuContent of NavigationMenuLinks; Pricing is a NavigationMenuLink on its own.

Why does Pricing look like the triggers?

It takes navigationMenuTriggerStyle() as its class, so a plain link lines up with the dropdown triggers beside it.

Where do the links come from?

Two sections at the top of the file, each a trigger label and its links, mapped to one item each. Edit that list to change the menu.

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.