NavigationMenu

NavigationMenu is a navigation component for moving between sections of a site or app — supports both horizontal bars and sidebars, with submenus and collapse mode.

4
Sizes
9
Parts
2
Orientations
Radix
Base

Playground

Preview
H
Menu
Direction
Size
Options
Sub Menus
Radius
<NavigationMenu>
  <NavigationMenuList>
    <NavigationMenuItem>
      <NavigationMenuLink href="#" active icon={<Home className="icon-sm" />}>Home</NavigationMenuLink>
    </NavigationMenuItem>
    <NavigationMenuItem value="products">
      <NavigationMenuTrigger icon={<Package className="icon-sm" />}>Products</NavigationMenuTrigger>
      <NavigationMenuContent>
        <NavigationMenuLink href="#">All Products</NavigationMenuLink>
        <NavigationMenuLink href="#">Featured</NavigationMenuLink>
        <NavigationMenuLink href="#">New Arrivals</NavigationMenuLink>
      </NavigationMenuContent>
    </NavigationMenuItem>
    <NavigationMenuItem value="resources">
      <NavigationMenuTrigger icon={<BookOpen className="icon-sm" />}>Resources</NavigationMenuTrigger>
      <NavigationMenuContent>
        <NavigationMenuLink href="#">Documentation</NavigationMenuLink>
        <NavigationMenuLink href="#">Blog</NavigationMenuLink>
        <NavigationMenuLink href="#">Support</NavigationMenuLink>
      </NavigationMenuContent>
    </NavigationMenuItem>
    <NavigationMenuItem>
      <NavigationMenuLink href="#" icon={<Tag className="icon-sm" />}>Pricing</NavigationMenuLink>
    </NavigationMenuItem>
    <NavigationMenuItem>
      <NavigationMenuLink href="#" icon={<Users className="icon-sm" />}>About</NavigationMenuLink>
    </NavigationMenuItem>
    <NavigationMenuItem>
      <NavigationMenuLink href="#" icon={<Mail className="icon-sm" />}>Contact</NavigationMenuLink>
    </NavigationMenuItem>
  </NavigationMenuList>
</NavigationMenu>

Variants

Horizontal (Default)
Horizontal navigation bar for placement below a header or at the top of a page — dropdowns open on hover.
Top bar
Vertical
Sidebar for dashboards and admin panels — click to expand or collapse submenus.
Sidebar

Sizes

sm
Height32px
Padding12px
Gap8px
Font13px
Icon14px
md
Height36px
Padding14px
Gap8px
Font14px
Icon16px
default
Height40px
Padding16px
Gap8px
Font14px
Icon16px
lg
Height48px
Padding24px
Gap8px
Font16px
Icon16px

Features

Sub Menus

In horizontal mode, dropdowns open on hover. In vertical mode, items expand accordion-style on click.

Horizontal
Vertical
<NavigationMenuItem value="products">
  <NavigationMenuTrigger>Products</NavigationMenuTrigger>
  <NavigationMenuContent>
    <NavigationMenuLink href="#">All Products</NavigationMenuLink>
    <NavigationMenuLink href="#">Featured</NavigationMenuLink>
  </NavigationMenuContent>
</NavigationMenuItem>

Collapsed Mode

The collapsed prop shows icons only. Use collapsedWidth to customize the width (default: 64px).

<NavigationMenu orientation="vertical" collapsed>
  <NavigationMenuList>
    <NavigationMenuItem>
      <NavigationMenuLink href="#"
        icon={<Home className="icon-sm" />}>
        Home
      </NavigationMenuLink>
    </NavigationMenuItem>
  </NavigationMenuList>
</NavigationMenu>

Active State

The active prop visually highlights the current page and automatically sets aria-current="page".

<NavigationMenuLink href="#" active
  icon={<Home className="icon-sm" />}>
  Home
</NavigationMenuLink>

Group Label

Use NavigationMenuGroup to divide items into sections and the label prop to display a group header.

<NavigationMenu orientation="vertical">
  <NavigationMenuList>
    <NavigationMenuGroup label="Main">
      <NavigationMenuItem>
        <NavigationMenuLink href="#">Home</NavigationMenuLink>
      </NavigationMenuItem>
    </NavigationMenuGroup>
    <NavigationMenuGroup label="Settings">
      <NavigationMenuItem>
        <NavigationMenuLink href="#">General</NavigationMenuLink>
      </NavigationMenuItem>
    </NavigationMenuGroup>
  </NavigationMenuList>
</NavigationMenu>

Custom Link (asChild)

Use the asChild prop to compose with custom link components such as Next.js Link.

import Link from 'next/link'

<NavigationMenuLink asChild active>
  <Link href="/dashboard">Dashboard</Link>
</NavigationMenuLink>

API

Component Structure

NavigationMenu— Radix NavigationMenu + Collapsible
.List.ItemProps.TriggerProps.Content.LinkProps.GroupProps.Indicator.Viewport

Props

NavigationMenu

orientation"horizontal"
"horizontal" | "vertical"

Layout direction

size"default"
"sm" | "md" | "default" | "lg"

Menu item size

collapsedfalse
boolean

Vertical only: show icons only (collapsed sidebar)

width256
number | string

Vertical only: sidebar width (px number or CSS string)

collapsedWidthsm:56 / md:60 / default:64 / lg:72
number | string

Vertical only: width when collapsed (auto-calculated by size, overridable with px or CSS string)

radius"lg"
"sm" | "md" | "lg" | "xl"

Border radius (horizontal: container/item concentric, vertical: applied directly)

fontWeight"normal"
"normal" | "semibold"

Menu item font weight (active state is always semibold)

delayDuration200
number

Horizontal only: delay before opening on hover (ms)

skipDelayDuration300
number

Horizontal only: skip delay when moving between triggers (ms)

valueundefined
string

Active menu item value (controlled mode)

defaultValueundefined
string

Default active value (uncontrolled mode)

onValueChangeundefined
(value: string) => void

Callback when active item changes

NavigationMenuItem

valueundefined
string

Radix identifier (for horizontal mode)

defaultOpenfalse
boolean

Vertical only: initial open state of submenu

NavigationMenuTrigger

iconundefined
ReactNode

Icon displayed before the label

chevronIcon内蔵SVG
ReactNode

Customize the chevron icon (horizontal: ▼, vertical: ▶)

NavigationMenuLink

activefalse
boolean

Represents the current page (aria-current="page")

asChildfalse
boolean

Compose with custom link components (Radix Slot)

iconundefined
ReactNode

Icon displayed before the label

hrefundefined
string

Link URL

NavigationMenuGroup

labelundefined
string

Group header label

Customization

NavigationMenuContent Place any JSX inside to create mega menus, card layouts, and more.

Mega Menu

<NavigationMenuContent> <div className="grid grid-cols-3 gap-4 p-4 w-[480px]"> <div> <h4 className="text-xs font-semibold uppercase mb-2"> Electronics </h4> <NavigationMenuLink href="#"> Smartphones </NavigationMenuLink> <NavigationMenuLink href="#"> Laptops </NavigationMenuLink> </div> {/* ...more columns */} </div> </NavigationMenuContent>

Card Layout

<NavigationMenuContent> <div className="grid grid-cols-2 gap-2 p-3 w-[400px]"> <a href="#" className="block p-3 rounded-lg hover:bg-background-muted"> <div className="text-sm font-semibold"> Documentation </div> <div className="text-xs text-text-muted"> Getting started guides and API references. </div> </a> {/* ...more cards */} </div> </NavigationMenuContent>

Tip:NavigationMenuContent content layout is completely free — grids, flex, cards, customize to fit your project.chevronIcon prop lets you swap the chevron icon as well.

Anatomy

1
2
3
6
Home
3
4
Products
3
6
Docs
7
5
Heighth-10 (40px)
Paddingpx-4 (16px)
Gapgap-2 (8px)
1
Root
Navigation root
2
List
Item list
3
Item
Nav item
4
Trigger
Dropdown trigger
5
Content
Dropdown content
6
Link
Nav link
7
Viewport
Content viewport

Best Practices

Do

  • Use for the site's primary navigation sections
  • Use active to clearly indicate the current page
  • Pair icons with labels in sidebars
  • Group related links using Group

Don't

  • Avoid nesting more than 3 levels deep
  • Don't crowd too many items into horizontal mode
  • Don't use icon-only in collapsed mode without tooltips
  • Don't use for triggering actions — use Dropdown instead

Accessibility

Keyboard

TabFocus into the menu
Arrow KeysMove between triggers and links
Enter / SpaceActivate a link / open content
EscapeClose content and return to trigger

ARIA / WCAG

  • aria-label="navigation" set on the nav element
  • aria-current="page" automatically set on active links
  • Full keyboard support via Radix NavigationMenu + Collapsible
  • Follows WAI-ARIA Disclosure Navigation Pattern