Introducing PrimeReact v11-alpha 🎉Discover Now

NavigationMenu

An unstyled, accessible horizontal menu bar that coordinates multiple Menu instances with keyboard navigation between them.

Compose a horizontal navigation bar from multiple Menu primitives — NavigationMenu tracks which menu is open, switches between them on hover, and routes arrow-key navigation across triggers.

basic-demo

Pre-styled Versions

Choose a pre-styled library to use NavigationMenu with ready-made designs.
For hook-based usage without components, see the Headless API.

Features#

  • Coordinates multiple Menu.Root children, allowing only one menu to be open at a time
  • Hover-to-switch: hovering another trigger while a menu is open transfers the open state to it
  • Arrow-key navigation between sibling triggers
  • Horizontal or vertical orientation
  • WAI-ARIA menubar role with proper aria-orientation

Usage#

import { Menu } from 'primereact/menu';
import { NavigationMenu } from 'primereact/navigationmenu';
<NavigationMenu>
    <Menu.Root>
        <Menu.Trigger>File</Menu.Trigger>
        <Menu.Portal>
            <Menu.Positioner>
                <Menu.Popup>
                    <Menu.List>
                        <Menu.Item>New</Menu.Item>
                        <Menu.Item>Open</Menu.Item>
                    </Menu.List>
                </Menu.Popup>
            </Menu.Positioner>
        </Menu.Portal>
    </Menu.Root>
    <Menu.Root>
        <Menu.Trigger>Edit</Menu.Trigger>
        {/* ... */}
    </Menu.Root>
</NavigationMenu>

API#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: NavigationMenuInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: NavigationMenuInstance) => string)—
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceNavigationMenuInstance—
The instance to pass to the component.
ptSafeRecord<NavigationMenuPassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: NavigationMenuInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
orientationNavigationMenuOrientation'horizontal'
The orientation of the navigationmenu. Determines which arrow keys move between triggers.
loopFocusbooleantrue
Whether keyboard focus loops back to the first/last item at the end of the list.
modalbooleantrue
Whether the navigationmenu is modal. When true, opening one menu prevents page interaction outside that menu.
disabledbooleanfalse
Whether all menus in the navigationmenu are disabled.
[key: string]any—
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.
AttributeValue
role"menubar"
data-scope"navigationmenu"
data-part"root"
data-orientation"horizontal" or "vertical"
data-has-open-menuPresent when any child menu is open
data-modalPresent when modal mode is enabled
data-disabledPresent when disabled

Defines passthrough(pt) options of NavigationMenu component.

labeltypedescription
rootNavigationMenuPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

Accessibility#

Screen Reader#

NavigationMenu uses the menubar role with aria-orientation reflecting the current orientation. Each child Menu.Trigger is treated as a menuitem within the bar.

Keyboard Support#

KeyFunction
left arrow / right arrowMoves focus to the previous / next trigger (horizontal orientation).
up arrow / down arrowMoves focus to the previous / next trigger (vertical orientation).
enter / spaceOpens the focused menu.
home / endMoves focus to the first / last trigger.
escapeCloses the open menu and returns focus to its trigger.