Skip to content
All components
Navigation

Navigation menu

Present a website's or product's main sections as a named navigation landmark of real links, with optional panels that group related destinations under a trigger.

A site menu with an animated viewport.

Installation

tdpxl is not an npm dependency of your app. The @tdpxl/cli command (not published to npm yet) copies the source into your project, with the registry items and npm packages it imports.

npx @tdpxl/cli add navigation-menu

Then import it from @/components/ui/navigation-menu. New project? Start with the installation guide.

Examples

Each example is one branch of the official demo, rendered in its own frame. The code is that branch as you would write it, with imports pointing at the default install paths.

Inline content

Render each panel below its own trigger instead of in the shared viewport. Set viewport to false when panels differ in size or the menu sits near a container edge.

"use client"

import {
  NavigationMenu,
  NavigationMenuContent,
  NavigationMenuItem,
  NavigationMenuLink,
  NavigationMenuList,
  NavigationMenuTrigger,
  navigationMenuTriggerStyle,
} from "@/components/ui/navigation-menu"

export function NavigationMenuInlineContent() {
  return (
    <div className="flex w-full flex-col items-start gap-10">
      <NavigationMenu viewport={false} aria-label="Help center">
        <NavigationMenuList>
          <NavigationMenuItem>
            <NavigationMenuTrigger>Guides</NavigationMenuTrigger>
            <NavigationMenuContent>
              <ul className="grid w-64 max-w-[calc(100vw-2rem)] gap-1">
                <li>
                  <NavigationMenuLink href="/guides/getting-started">
                    <p className="text-label-sm text-strong-950">Getting started</p>
                    <p className="text-paragraph-sm text-sub-600">
                      Set up an account and invite your team.
                    </p>
                  </NavigationMenuLink>
                </li>
                <li>
                  <NavigationMenuLink href="/guides/billing">
                    <p className="text-label-sm text-strong-950">Billing</p>
                    <p className="text-paragraph-sm text-sub-600">
                      Plans, invoices and payment methods.
                    </p>
                  </NavigationMenuLink>
                </li>
              </ul>
            </NavigationMenuContent>
          </NavigationMenuItem>
          <NavigationMenuItem>
            <NavigationMenuLink href="/contact" className={navigationMenuTriggerStyle()}>
              Contact support
            </NavigationMenuLink>
          </NavigationMenuItem>
        </NavigationMenuList>
      </NavigationMenu>
    </div>
  )
}

Current page

Mark the link for the current page with active. Radix sets aria-current=page on that link, so the location is announced as well as shown.

"use client"

import {
  NavigationMenu,
  NavigationMenuItem,
  NavigationMenuLink,
  NavigationMenuList,
  navigationMenuTriggerStyle,
} from "@/components/ui/navigation-menu"

export function NavigationMenuCurrentPage() {
  return (
    <div className="flex w-full flex-col items-start gap-10">
      <NavigationMenu aria-label="Account sections">
        <NavigationMenuList className="flex-wrap justify-start">
          <NavigationMenuItem>
            <NavigationMenuLink href="/account" active className={navigationMenuTriggerStyle()}>
              Profile
            </NavigationMenuLink>
          </NavigationMenuItem>
          <NavigationMenuItem>
            <NavigationMenuLink href="/account/security" className={navigationMenuTriggerStyle()}>
              Security
            </NavigationMenuLink>
          </NavigationMenuItem>
          <NavigationMenuItem>
            <NavigationMenuLink href="/account/notifications" className={navigationMenuTriggerStyle()}>
              Notifications
            </NavigationMenuLink>
          </NavigationMenuItem>
        </NavigationMenuList>
      </NavigationMenu>
    </div>
  )
}

API reference

Generated from the component's TypeScript signatures. Inherited DOM and primitive props are listed separately.

NavigationMenu

Organize website or product section navigation.

NavigationMenu props
PropTypeDefaultDescription
delayDurationnumber | undefined—The duration from when the pointer enters the trigger until the tooltip gets opened. When activationMode is manual, this prop is ignored.
skipDelayDurationnumber | undefined—How much time a user has to enter another trigger without incurring a delay again. When activationMode is manual, this prop is ignored.
activationMode("manual" | "automatic") | undefined—Whether an item is activated automatically or manually. - "automatic": hovering or focusing a trigger opens its item, and moving away closes it after a short delay. - "manual": clicking a trigger toggles the item; hover and focus are ignored
inputMode"search" | "text" | "none" | "tel" | "url" | "email" | "numeric" | "decimal" | undefined—Hints at the type of data that might be entered by the user while editing the element or its contents
aria-describedbystring | undefined—Identifies the element (or elements) that describes the object.
aria-invalidboolean | "false" | "true" | "grammar" | "spelling" | undefined—Indicates the entered value does not conform to the format expected by the application.
aria-labelstring | undefined—Defines a string value that labels the current element.
aria-labelledbystring | undefined—Identifies the element (or elements) that labels the current element.
childrenReact.ReactNode—Represents all of the things React can render.
viewportboolean | undefinedtrueRender a shared viewport for navigation content. Keep the surrounding NavigationMenu composition intact.
Inherited props (18)
NavigationMenu inherited props
PropTypeDefaultDescription
valuestring | undefined—Current value in the shape defined by the source type. For controlled interactive inputs, apply updates from the change callback.
defaultValuestring | undefined—Initial value for a control supporting uncontrolled state. Inherited DOM typing alone does not give a layout wrapper input behavior.
onValueChange((value: string) => void) | undefined—Receive the next value in the source-defined shape. A controlled parent must apply it to value.
dir("ltr" | "rtl") | undefined—Reading direction used by the primitive. Keep it consistent with the surrounding content and Direction provider.
orientation("horizontal" | "vertical") | undefined—Horizontal or vertical layout/navigation axis as defined by this primitive.
classNamestring | undefined—Additional classes for this part. Preserve contrast, visible focus and responsive content when adapting styles.
defaultCheckedboolean | undefined—Initial checked state for a control supporting uncontrolled selection. Inherited DOM typing does not give a layout wrapper checkbox behavior.
autoFocusboolean | undefined—Request automatic focus when the element mounts or the primitive opens, according to its source behavior. Choose initial focus deliberately in context.
idstring | undefined—Stable DOM identifier used by labels, descriptions or other explicit associations.
roleReact.AriaRole | undefined—Semantic role appropriate to the rendered element. Preserve required relationships and keyboard behavior.
onFocusReact.FocusEventHandler<HTMLElement> | undefined—Receive the native focus event. Preserve the component's existing keyboard and focus behavior.
onBlurReact.FocusEventHandler<HTMLElement> | undefined—Receive the native blur event when focus leaves this control.
onChangeReact.ChangeEventHandler<HTMLElement, Element> | undefined—Receive the native change event; read the actual control value or checked state from its event target.
onKeyDownReact.KeyboardEventHandler<HTMLElement> | undefined—Receive keyboard events. Preserve built-in keyboard behavior unless deliberately implementing an accessible alternative.
onClickReact.MouseEventHandler<HTMLElement> | undefined—Receive activation events. The consumer owns the action performed and its result.
onSelectReact.ReactEventHandler<HTMLElement> | undefined—Handle the selection event defined by this part's source signature. DOM text-selection events differ from menu or command activation callbacks.
asChildboolean | undefined—Merge this part into one child instead of its default element. Preserve that child's semantics, ref support and accessibility attributes.
refReact.Ref<HTMLElement> | undefined—Allows getting a ref to the component instance. Once the component unmounts, React will set ref.current to null (or call the ref with null if you passed a callback ref).

NavigationMenuContent

Content region within the root composition. Keep required providers, labels and related controls from the complete example.

NavigationMenuContent props
PropTypeDefaultDescription
forceMounttrue | undefined—Used to force mounting when more control is needed. Useful when controlling animation with React animation libraries.
inputMode"search" | "text" | "none" | "tel" | "url" | "email" | "numeric" | "decimal" | undefined—Hints at the type of data that might be entered by the user while editing the element or its contents
aria-describedbystring | undefined—Identifies the element (or elements) that describes the object.
aria-invalidboolean | "false" | "true" | "grammar" | "spelling" | undefined—Indicates the entered value does not conform to the format expected by the application.
aria-labelstring | undefined—Defines a string value that labels the current element.
aria-labelledbystring | undefined—Identifies the element (or elements) that labels the current element.
childrenReact.ReactNode—Represents all of the things React can render.
deferPointerDownOutsideboolean | undefined—When true, a 'pointerdown' event outside of the layered element will wait for the interaction's click event before dispatching, allowing third-party code to stop propagation of later events and cancel dismissal.
onEscapeKeyDown((event: KeyboardEvent) => void) | undefined—Event handler called when the escape key is down. Can be prevented.
onPointerDownOutside((event: CustomEvent<{ originalEvent: PointerEvent; }>) => void) | undefined—Event handler called when the a pointerdown event happens outside of the DismissableLayer. Can be prevented.
onFocusOutside((event: CustomEvent<{ originalEvent: FocusEvent; }>) => void) | undefined—Event handler called when the focus moves outside of the DismissableLayer. Can be prevented.
onInteractOutside((event: CustomEvent<{ originalEvent: PointerEvent; }> | CustomEvent<{ originalEvent: FocusEvent; }>) => void) | undefined—Event handler called when an interaction happens outside the DismissableLayer. Specifically, when a pointerdown event happens outside or focus moves outside of it. Can be prevented.
Inherited props (14)
NavigationMenuContent inherited props
PropTypeDefaultDescription
classNamestring | undefined—Additional classes for this part. Preserve contrast, visible focus and responsive content when adapting styles.
defaultCheckedboolean | undefined—Initial checked state for a control supporting uncontrolled selection. Inherited DOM typing does not give a layout wrapper checkbox behavior.
defaultValuestring | number | readonly string[] | undefined—Initial value for a control supporting uncontrolled state. Inherited DOM typing alone does not give a layout wrapper input behavior.
autoFocusboolean | undefined—Request automatic focus when the element mounts or the primitive opens, according to its source behavior. Choose initial focus deliberately in context.
idstring | undefined—Stable DOM identifier used by labels, descriptions or other explicit associations.
roleReact.AriaRole | undefined—Semantic role appropriate to the rendered element. Preserve required relationships and keyboard behavior.
onFocusReact.FocusEventHandler<HTMLDivElement> | undefined—Receive the native focus event. Preserve the component's existing keyboard and focus behavior.
onBlurReact.FocusEventHandler<HTMLDivElement> | undefined—Receive the native blur event when focus leaves this control.
onChangeReact.ChangeEventHandler<HTMLDivElement, Element> | undefined—Receive the native change event; read the actual control value or checked state from its event target.
onKeyDownReact.KeyboardEventHandler<HTMLDivElement> | undefined—Receive keyboard events. Preserve built-in keyboard behavior unless deliberately implementing an accessible alternative.
onClickReact.MouseEventHandler<HTMLDivElement> | undefined—Receive activation events. The consumer owns the action performed and its result.
onSelectReact.ReactEventHandler<HTMLDivElement> | undefined—Handle the selection event defined by this part's source signature. DOM text-selection events differ from menu or command activation callbacks.
asChildboolean | undefined—Merge this part into one child instead of its default element. Preserve that child's semantics, ref support and accessibility attributes.
refReact.Ref<HTMLDivElement> | undefined—Allows getting a ref to the component instance. Once the component unmounts, React will set ref.current to null (or call the ref with null if you passed a callback ref).

NavigationMenuItem

One item within its parent composition. Keep parent context and the value, label or state required by the source API.

NavigationMenuItem props
PropTypeDefaultDescription
inputMode"search" | "text" | "none" | "tel" | "url" | "email" | "numeric" | "decimal" | undefined—Hints at the type of data that might be entered by the user while editing the element or its contents
aria-describedbystring | undefined—Identifies the element (or elements) that describes the object.
aria-invalidboolean | "false" | "true" | "grammar" | "spelling" | undefined—Indicates the entered value does not conform to the format expected by the application.
aria-labelstring | undefined—Defines a string value that labels the current element.
aria-labelledbystring | undefined—Identifies the element (or elements) that labels the current element.
childrenReact.ReactNode—Represents all of the things React can render.
Inherited props (15)
NavigationMenuItem inherited props
PropTypeDefaultDescription
valuestring | undefined—Current value in the shape defined by the source type. For controlled interactive inputs, apply updates from the change callback.
classNamestring | undefined—Additional classes for this part. Preserve contrast, visible focus and responsive content when adapting styles.
defaultCheckedboolean | undefined—Initial checked state for a control supporting uncontrolled selection. Inherited DOM typing does not give a layout wrapper checkbox behavior.
defaultValuestring | number | readonly string[] | undefined—Initial value for a control supporting uncontrolled state. Inherited DOM typing alone does not give a layout wrapper input behavior.
autoFocusboolean | undefined—Request automatic focus when the element mounts or the primitive opens, according to its source behavior. Choose initial focus deliberately in context.
idstring | undefined—Stable DOM identifier used by labels, descriptions or other explicit associations.
roleReact.AriaRole | undefined—Semantic role appropriate to the rendered element. Preserve required relationships and keyboard behavior.
onFocusReact.FocusEventHandler<HTMLLIElement> | undefined—Receive the native focus event. Preserve the component's existing keyboard and focus behavior.
onBlurReact.FocusEventHandler<HTMLLIElement> | undefined—Receive the native blur event when focus leaves this control.
onChangeReact.ChangeEventHandler<HTMLLIElement, Element> | undefined—Receive the native change event; read the actual control value or checked state from its event target.
onKeyDownReact.KeyboardEventHandler<HTMLLIElement> | undefined—Receive keyboard events. Preserve built-in keyboard behavior unless deliberately implementing an accessible alternative.
onClickReact.MouseEventHandler<HTMLLIElement> | undefined—Receive activation events. The consumer owns the action performed and its result.
onSelectReact.ReactEventHandler<HTMLLIElement> | undefined—Handle the selection event defined by this part's source signature. DOM text-selection events differ from menu or command activation callbacks.
asChildboolean | undefined—Merge this part into one child instead of its default element. Preserve that child's semantics, ref support and accessibility attributes.
refReact.Ref<HTMLLIElement> | undefined—Allows getting a ref to the component instance. Once the component unmounts, React will set ref.current to null (or call the ref with null if you passed a callback ref).

NavigationMenuLink

The NavigationMenuLink part of navigation-menu. Use it with the complete source composition and preserve its required parent context.

NavigationMenuLink props
PropTypeDefaultDescription
inputMode"search" | "text" | "none" | "tel" | "url" | "email" | "numeric" | "decimal" | undefined—Hints at the type of data that might be entered by the user while editing the element or its contents
aria-describedbystring | undefined—Identifies the element (or elements) that describes the object.
aria-invalidboolean | "false" | "true" | "grammar" | "spelling" | undefined—Indicates the entered value does not conform to the format expected by the application.
aria-labelstring | undefined—Defines a string value that labels the current element.
aria-labelledbystring | undefined—Identifies the element (or elements) that labels the current element.
childrenReact.ReactNode—Represents all of the things React can render.
Inherited props (16)
NavigationMenuLink inherited props
PropTypeDefaultDescription
activeboolean | undefined—Whether the navigation link represents the current destination. Keep this state consistent with the actual route.
onSelect((event: Event) => void) | undefined—Handle the selection event defined by this part's source signature. DOM text-selection events differ from menu or command activation callbacks.
classNamestring | undefined—Additional classes for this part. Preserve contrast, visible focus and responsive content when adapting styles.
defaultCheckedboolean | undefined—Initial checked state for a control supporting uncontrolled selection. Inherited DOM typing does not give a layout wrapper checkbox behavior.
defaultValuestring | number | readonly string[] | undefined—Initial value for a control supporting uncontrolled state. Inherited DOM typing alone does not give a layout wrapper input behavior.
autoFocusboolean | undefined—Request automatic focus when the element mounts or the primitive opens, according to its source behavior. Choose initial focus deliberately in context.
idstring | undefined—Stable DOM identifier used by labels, descriptions or other explicit associations.
roleReact.AriaRole | undefined—Semantic role appropriate to the rendered element. Preserve required relationships and keyboard behavior.
onFocusReact.FocusEventHandler<HTMLAnchorElement> | undefined—Receive the native focus event. Preserve the component's existing keyboard and focus behavior.
onBlurReact.FocusEventHandler<HTMLAnchorElement> | undefined—Receive the native blur event when focus leaves this control.
onChangeReact.ChangeEventHandler<HTMLAnchorElement, Element> | undefined—Receive the native change event; read the actual control value or checked state from its event target.
onKeyDownReact.KeyboardEventHandler<HTMLAnchorElement> | undefined—Receive keyboard events. Preserve built-in keyboard behavior unless deliberately implementing an accessible alternative.
onClickReact.MouseEventHandler<HTMLAnchorElement> | undefined—Receive activation events. The consumer owns the action performed and its result.
asChildboolean | undefined—Merge this part into one child instead of its default element. Preserve that child's semantics, ref support and accessibility attributes.
typestring | undefined—Native element or primitive mode defined by the source union. Choose a supported value; its meaning depends on the component.
refReact.Ref<HTMLAnchorElement> | undefined—Allows getting a ref to the component instance. Once the component unmounts, React will set ref.current to null (or call the ref with null if you passed a callback ref).

NavigationMenuList

The NavigationMenuList part of navigation-menu. Use it with the complete source composition and preserve its required parent context.

NavigationMenuList props
PropTypeDefaultDescription
inputMode"search" | "text" | "none" | "tel" | "url" | "email" | "numeric" | "decimal" | undefined—Hints at the type of data that might be entered by the user while editing the element or its contents
aria-describedbystring | undefined—Identifies the element (or elements) that describes the object.
aria-invalidboolean | "false" | "true" | "grammar" | "spelling" | undefined—Indicates the entered value does not conform to the format expected by the application.
aria-labelstring | undefined—Defines a string value that labels the current element.
aria-labelledbystring | undefined—Identifies the element (or elements) that labels the current element.
childrenReact.ReactNode—Represents all of the things React can render.
Inherited props (14)
NavigationMenuList inherited props
PropTypeDefaultDescription
classNamestring | undefined—Additional classes for this part. Preserve contrast, visible focus and responsive content when adapting styles.
defaultCheckedboolean | undefined—Initial checked state for a control supporting uncontrolled selection. Inherited DOM typing does not give a layout wrapper checkbox behavior.
defaultValuestring | number | readonly string[] | undefined—Initial value for a control supporting uncontrolled state. Inherited DOM typing alone does not give a layout wrapper input behavior.
autoFocusboolean | undefined—Request automatic focus when the element mounts or the primitive opens, according to its source behavior. Choose initial focus deliberately in context.
idstring | undefined—Stable DOM identifier used by labels, descriptions or other explicit associations.
roleReact.AriaRole | undefined—Semantic role appropriate to the rendered element. Preserve required relationships and keyboard behavior.
onFocusReact.FocusEventHandler<HTMLUListElement> | undefined—Receive the native focus event. Preserve the component's existing keyboard and focus behavior.
onBlurReact.FocusEventHandler<HTMLUListElement> | undefined—Receive the native blur event when focus leaves this control.
onChangeReact.ChangeEventHandler<HTMLUListElement, Element> | undefined—Receive the native change event; read the actual control value or checked state from its event target.
onKeyDownReact.KeyboardEventHandler<HTMLUListElement> | undefined—Receive keyboard events. Preserve built-in keyboard behavior unless deliberately implementing an accessible alternative.
onClickReact.MouseEventHandler<HTMLUListElement> | undefined—Receive activation events. The consumer owns the action performed and its result.
onSelectReact.ReactEventHandler<HTMLUListElement> | undefined—Handle the selection event defined by this part's source signature. DOM text-selection events differ from menu or command activation callbacks.
asChildboolean | undefined—Merge this part into one child instead of its default element. Preserve that child's semantics, ref support and accessibility attributes.
refReact.Ref<HTMLUListElement> | undefined—Allows getting a ref to the component instance. Once the component unmounts, React will set ref.current to null (or call the ref with null if you passed a callback ref).

NavigationMenuTrigger

Interactive control that opens or toggles the associated content. Preserve its accessible name and the required root context.

NavigationMenuTrigger props
PropTypeDefaultDescription
inputMode"search" | "text" | "none" | "tel" | "url" | "email" | "numeric" | "decimal" | undefined—Hints at the type of data that might be entered by the user while editing the element or its contents
aria-describedbystring | undefined—Identifies the element (or elements) that describes the object.
aria-invalidboolean | "false" | "true" | "grammar" | "spelling" | undefined—Indicates the entered value does not conform to the format expected by the application.
aria-labelstring | undefined—Defines a string value that labels the current element.
aria-labelledbystring | undefined—Identifies the element (or elements) that labels the current element.
childrenReact.ReactNode—Represents all of the things React can render.
Inherited props (19)
NavigationMenuTrigger inherited props
PropTypeDefaultDescription
formstring | undefined—ID of the form associated with this control, including when it is rendered outside that form element.
classNamestring | undefined—Additional classes for this part. Preserve contrast, visible focus and responsive content when adapting styles.
defaultCheckedboolean | undefined—Initial checked state for a control supporting uncontrolled selection. Inherited DOM typing does not give a layout wrapper checkbox behavior.
defaultValuestring | number | readonly string[] | undefined—Initial value for a control supporting uncontrolled state. Inherited DOM typing alone does not give a layout wrapper input behavior.
autoFocusboolean | undefined—Request automatic focus when the element mounts or the primitive opens, according to its source behavior. Choose initial focus deliberately in context.
idstring | undefined—Stable DOM identifier used by labels, descriptions or other explicit associations.
roleReact.AriaRole | undefined—Semantic role appropriate to the rendered element. Preserve required relationships and keyboard behavior.
onFocusReact.FocusEventHandler<HTMLButtonElement> | undefined—Receive the native focus event. Preserve the component's existing keyboard and focus behavior.
onBlurReact.FocusEventHandler<HTMLButtonElement> | undefined—Receive the native blur event when focus leaves this control.
onChangeReact.ChangeEventHandler<HTMLButtonElement, Element> | undefined—Receive the native change event; read the actual control value or checked state from its event target.
onKeyDownReact.KeyboardEventHandler<HTMLButtonElement> | undefined—Receive keyboard events. Preserve built-in keyboard behavior unless deliberately implementing an accessible alternative.
onClickReact.MouseEventHandler<HTMLButtonElement> | undefined—Receive activation events. The consumer owns the action performed and its result.
onSelectReact.ReactEventHandler<HTMLButtonElement> | undefined—Handle the selection event defined by this part's source signature. DOM text-selection events differ from menu or command activation callbacks.
asChildboolean | undefined—Merge this part into one child instead of its default element. Preserve that child's semantics, ref support and accessibility attributes.
disabledboolean | undefined—Make the supported control unavailable through its native or primitive disabled semantics. This does not disable arbitrary child links.
namestring | undefined—Name used by the control's form submission or primitive form integration.
type"button" | "submit" | "reset" | undefined—Native element or primitive mode defined by the source union. Choose a supported value; its meaning depends on the component.
valuestring | number | readonly string[] | undefined—Current value in the shape defined by the source type. For controlled interactive inputs, apply updates from the change callback.
refReact.Ref<HTMLButtonElement> | undefined—Allows getting a ref to the component instance. Once the component unmounts, React will set ref.current to null (or call the ref with null if you passed a callback ref).

NavigationMenuViewport

Viewport for the parent composition. Preserve its scrolling, focus and sizing responsibilities.

NavigationMenuViewport props
PropTypeDefaultDescription
forceMounttrue | undefined—Used to force mounting when more control is needed. Useful when controlling animation with React animation libraries.
inputMode"search" | "text" | "none" | "tel" | "url" | "email" | "numeric" | "decimal" | undefined—Hints at the type of data that might be entered by the user while editing the element or its contents
aria-describedbystring | undefined—Identifies the element (or elements) that describes the object.
aria-invalidboolean | "false" | "true" | "grammar" | "spelling" | undefined—Indicates the entered value does not conform to the format expected by the application.
aria-labelstring | undefined—Defines a string value that labels the current element.
aria-labelledbystring | undefined—Identifies the element (or elements) that labels the current element.
childrenReact.ReactNode—Represents all of the things React can render.
Inherited props (14)
NavigationMenuViewport inherited props
PropTypeDefaultDescription
classNamestring | undefined—Additional classes for this part. Preserve contrast, visible focus and responsive content when adapting styles.
defaultCheckedboolean | undefined—Initial checked state for a control supporting uncontrolled selection. Inherited DOM typing does not give a layout wrapper checkbox behavior.
defaultValuestring | number | readonly string[] | undefined—Initial value for a control supporting uncontrolled state. Inherited DOM typing alone does not give a layout wrapper input behavior.
autoFocusboolean | undefined—Request automatic focus when the element mounts or the primitive opens, according to its source behavior. Choose initial focus deliberately in context.
idstring | undefined—Stable DOM identifier used by labels, descriptions or other explicit associations.
roleReact.AriaRole | undefined—Semantic role appropriate to the rendered element. Preserve required relationships and keyboard behavior.
onFocusReact.FocusEventHandler<HTMLDivElement> | undefined—Receive the native focus event. Preserve the component's existing keyboard and focus behavior.
onBlurReact.FocusEventHandler<HTMLDivElement> | undefined—Receive the native blur event when focus leaves this control.
onChangeReact.ChangeEventHandler<HTMLDivElement, Element> | undefined—Receive the native change event; read the actual control value or checked state from its event target.
onKeyDownReact.KeyboardEventHandler<HTMLDivElement> | undefined—Receive keyboard events. Preserve built-in keyboard behavior unless deliberately implementing an accessible alternative.
onClickReact.MouseEventHandler<HTMLDivElement> | undefined—Receive activation events. The consumer owns the action performed and its result.
onSelectReact.ReactEventHandler<HTMLDivElement> | undefined—Handle the selection event defined by this part's source signature. DOM text-selection events differ from menu or command activation callbacks.
asChildboolean | undefined—Merge this part into one child instead of its default element. Preserve that child's semantics, ref support and accessibility attributes.
refReact.Ref<HTMLDivElement> | undefined—Allows getting a ref to the component instance. Once the component unmounts, React will set ref.current to null (or call the ref with null if you passed a callback ref).

Accessibility & usage

From registry/ui/navigation-menu.meta.json (authored guidance; human review may still be pending). Behavior is checked by Storybook tests, not certified here.

When to use

  • Top-level site or marketing navigation where a few sections each hold several destinations worth previewing with a short description.
  • A horizontal row of section links on wide screens, with one link marked as the current page through active.
  • Grouping secondary destinations (guides, resources, company pages) behind a trigger so the top row stays short.

When not to use

  • Application commands such as Save, Export or Undo; those are actions, not destinations. Use a menubar or a dropdown menu.
  • Persistent in-app navigation with many sections and nesting; a sidebar keeps it visible and scannable.
  • Switching panels inside one view without a URL change; that is tabs.
  • The only navigation on small screens: panels designed for a wide header do not fit a 320px viewport.

Anatomy

NavigationMenu
Root nav landmark (Radix names it 'Main' unless you pass aria-label). Owns value/onValueChange, orientation, dir, delayDuration and the viewport choice.
NavigationMenuList
The list of top-level items in reading order.
NavigationMenuItem
One top-level entry: either a trigger with content, or a direct link. Give it value when the parent controls which panel is open.
NavigationMenuTrigger
Button that opens its panel (aria-expanded, aria-controls); the chevron is decorative. disabled removes it from Tab order.
NavigationMenuContent
The panel of links for one trigger; rendered in the shared viewport or, with viewport={false}, directly below its trigger.
NavigationMenuLink
A real anchor. active sets aria-current='page' and the current appearance; onSelect runs before the menu dismisses.
NavigationMenuViewport
Shared animated container that sizes itself to the open panel; rendered by the root when viewport is true (default).
navigationMenuTriggerStyle
Class helper that gives a direct top-level link the same look as a trigger.

Keyboard & interaction

  • Tab moves through triggers and top-level links in order; with a panel open, Tab from the trigger enters the panel's links and continues to the next top-level item after the last one.
  • Enter or Space toggles a trigger. ArrowDown (horizontal) or the direction-aware entry key (vertical) moves into the open panel; Left/Right (or Up/Down when vertical) move between top-level items and respect dir='rtl'; Home and End jump to the first and last item.
  • Escape closes the panel and returns focus to its trigger. Disabled triggers are skipped.
  • Pointer hover opens a panel after delayDuration (200 ms by default) and moving between triggers switches quickly; panels also open on click, so touch and keyboard users are not excluded.
  • Known open finding: while a panel is open, the upstream Radix focus proxy is an aria-hidden element that can receive focus and redirect it. Real keyboard routing works, but the aria-hidden-focus audit stays blocking and a screen-reader pass is still pending; do not ship this as accessibility-approved.

Responsive behavior

  • Design this for wide screens. Below the width where the top row fits, replace it with a menu button that opens a Sheet (or Drawer) containing the same links as a simple list or disclosure groups.
  • Keep panels within the viewport: give content a max width such as calc(100vw - 2rem), and use viewport={false} when the menu sits near a container edge or panels differ greatly in size.
  • Do not rely on hover on touch devices; the trigger must stay a tappable target of at least 24x24 CSS px (WCAG 2.5.8).
  • Panel animations honor prefers-reduced-motion through motion-reduce classes; keep that if you change the animation.
  • An open panel must not hide the focused link under a sticky header or other layer (WCAG 2.4.11).

Content guidelines

  • Use short, distinct section names for triggers and top-level links: 'Products', 'Guides', 'Pricing'. Avoid vague labels like 'More' or 'Explore' when a specific word exists.
  • Inside panels, lead with the destination name and add a one-line description only when it helps people choose.
  • Name the landmark when a page has more than one navigation ('Main', 'Help center', 'Account sections').
  • Mark exactly one link as active, the page the person is on; do not mark the section of a child page as active in a way that suggests it is the current page.

Alternatives

  • Sidebar — Persistent application navigation with groups and nesting, collapsing into a sheet on mobile.
  • Menubar — Desktop-style menus of application commands rather than destinations.
  • Sheet — The small-screen version of the same navigation: a side panel opened from a menu button.
  • Tabs — Peer panels of one view switched in place.
  • Breadcrumb — Showing the current page's position in the hierarchy rather than the main sections.

Resources