Skip to contents

Navigation Menu

A collection of links and menus for website navigation.

View as Markdown

Anatomy

Import the component and assemble its parts:

Anatomy

Examples

Nested submenus

<NavigationMenu.Root> component can be nested within a higher-level <NavigationMenu.Content> part to create a multi-level navigation menu.

Nested inline submenus

For second-level navigation that should stay in the same panel, omit the nested <NavigationMenu.Portal> and render only List + Viewport with a defaultValue.

The <NavigationMenu.Link> part can be customized to render the link from your framework using the render prop to enable client-side routing.

Next.js example

Large menus

When you have large menu content that doesn’t fit in the viewport in some cases, you usually have two choices:

  1. Compress the navigation menu content

You can change the layout of the navigation menu to render less content or be more compact by reducing the space it takes up. If your content is flexible, you can use the max-height property on .Popup to limit the height of the navigation menu to let it compress itself while preventing overflow.

Compact layout
  1. Make the navigation menu scrollable
Scrollable layout

Native scrollbars are visible while transitioning content, so we recommend using the Scroll Area component instead of native scrollbars to keep them hidden, which also allows the Arrow to be centered correctly.

API reference

Root

Groups all parts of the navigation menu. Renders a <nav> element at the root, or <div> element when nested.

defaultValueValue | nullnull
Description

The uncontrolled value of the item that should be initially selected.

To render a controlled navigation menu, use the value prop instead.

Type
Default
null
valueValue | nullnull
Name
Description

The controlled value of the navigation menu item that should be currently open. When non-nullish, the menu will be open. When nullish, the menu will be closed.

To render an uncontrolled navigation menu, use the defaultValue prop instead.

Type
Default
null
onValueChangefunction
Description

Callback fired when the value changes.

Type
actionsRefReact.RefObject<NavigationMenu.Root.Actions | null>
Description

A ref to imperative actions.

Type
onOpenChangeCompletefunction
Description

Event handler called after any animations complete when the navigation menu is closed.

Type
delaynumber50
Name
Description

How long to wait before opening the navigation popup. Specified in milliseconds.

Type
Default
50
closeDelaynumber50
Description

How long to wait before closing the navigation popup. Specified in milliseconds.

Type
Default
50
orientation'horizontal' | 'vertical''horizontal'
Description

The orientation of the navigation menu.

Type
Default
'horizontal'
classNamestring | function
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function
Name
Type
renderReactElement | function
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type

NavigationMenu.Root.PropsHide

Re-Export of Root props as NavigationMenuRootProps

NavigationMenu.Root.StateHide

NavigationMenu.Root.ActionsHide

NavigationMenu.Root.ChangeEventReasonHide

NavigationMenu.Root.ChangeEventDetailsHide

NavigationMenu.Root.ValueHide

List

Contains a list of navigation menu items. Renders a <ul> element.

classNamestring | function
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function
Name
Type
renderReactElement | function
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type

NavigationMenu.List.PropsHide

Re-Export of List props as NavigationMenuListProps

NavigationMenu.List.StateHide

Item

An individual navigation menu item. Renders a <li> element.

valueany
Name
Description

A unique value that identifies this navigation menu item. If no value is provided, a unique ID will be generated automatically. Use when controlling the navigation menu programmatically.

Type
classNamestring | function
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function
Name
Type
renderReactElement | function
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type

NavigationMenu.Item.PropsHide

Re-Export of Item props as NavigationMenuItemProps

NavigationMenu.Item.StateHide

Trigger

Opens the navigation menu popup when hovered or clicked, revealing the associated content. Renders a <button> element.

nativeButtonbooleantrue
Description

Whether the component renders a native <button> element when replacing it via the render prop. Set to false if the rendered element is not a button (for example, <div>).

Type
Default
true
classNamestring | function
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function
Name
Type
renderReactElement | function
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type
data-popup-open

Present when the corresponding navigation menu is open.

data-pressed

Present when the trigger is pressed.

AttributeDescription
data-popup-open

Present when the corresponding navigation menu is open.

data-pressed

Present when the trigger is pressed.

NavigationMenu.Trigger.PropsHide

Re-Export of Trigger props as NavigationMenuTriggerProps

NavigationMenu.Trigger.StateHide

Icon

An icon that indicates that the trigger button opens a menu.

classNamestring | function
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function
Name
Type
renderReactElement | function
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type

NavigationMenu.Icon.PropsHide

Re-Export of Icon props as NavigationMenuIconProps

NavigationMenu.Icon.StateHide

Content

A container for the content of the navigation menu item that is moved into the popup when the item is active. Renders a <div> element.

classNamestring | function
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function
Name
Type
keepMountedbooleanfalse
Description

Whether to keep the content mounted in the DOM while the popup is closed. Ensures the content is present during server-side rendering for web crawlers.

Type
Default
false
renderReactElement | function
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type
data-open

Present when the popup is open.

data-closed

Present when the popup is closed.

data-activation-direction

Which direction another trigger was activated from.

data-starting-style

Present when the content is animating in.

data-ending-style

Present when the content is animating out.

AttributeDescription
data-open

Present when the popup is open.

data-closed

Present when the popup is closed.

data-activation-direction

Which direction another trigger was activated from.

data-starting-style

Present when the content is animating in.

data-ending-style

Present when the content is animating out.

NavigationMenu.Content.PropsHide

Re-Export of Content props as NavigationMenuContentProps

NavigationMenu.Content.StateHide

A link in the navigation menu that can be used to navigate to a different page or section. Renders an <a> element.

closeOnClickbooleanfalse
Description

Whether to close the navigation menu when the link is clicked.

Type
Default
false
activebooleanfalse
Name
Description

Whether the link is the currently active page.

Type
Default
false
classNamestring | function
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function
Name
Type
renderReactElement | function
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type
data-active

Present when the link is the currently active page.

AttributeDescription
data-active

Present when the link is the currently active page.

NavigationMenu.Link.PropsHide

Re-Export of Link props as NavigationMenuLinkProps

NavigationMenu.Link.StateHide

Backdrop

A backdrop for the navigation menu popup. Renders a <div> element.

classNamestring | function
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function
Name
Type
renderReactElement | function
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type
data-open

Present when the popup is open.

data-closed

Present when the popup is closed.

data-starting-style

Present when the popup is animating in.

data-ending-style

Present when the popup is animating out.

AttributeDescription
data-open

Present when the popup is open.

data-closed

Present when the popup is closed.

data-starting-style

Present when the popup is animating in.

data-ending-style

Present when the popup is animating out.

NavigationMenu.Backdrop.PropsHide

Re-Export of Backdrop props as NavigationMenuBackdropProps

NavigationMenu.Backdrop.StateHide

Portal

A portal element that moves the popup to a different part of the DOM. By default, the portal element is appended to <body>. Renders a <div> element.

containerUnion
Description

A parent element to render the portal element into.

Type
classNamestring | function
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function
Name
Type
keepMountedbooleanfalse
Description

Whether to keep the portal mounted in the DOM while the popup is hidden.

Type
Default
false
renderReactElement | function
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type

NavigationMenu.Portal.PropsHide

Re-Export of Portal props as NavigationMenuPortalProps

NavigationMenu.Portal.StateHide

Positioner

Positions the navigation menu against the currently active trigger. Renders a <div> element.

disableAnchorTrackingbooleanfalse
Description

Whether to disable the popup from tracking any layout shift of its positioning anchor.

Type
Default
false
alignAlign'center'
Name
Description

How to align the popup relative to the specified side.

Type
Default
'center'
alignOffsetnumber | OffsetFunction0
Description

Additional offset along the alignment axis in pixels. Also accepts a function that returns the offset to read the dimensions of the anchor and positioner elements, along with its side and alignment.

The function takes a data object parameter with the following properties:

  • data.anchor: the dimensions of the anchor element with properties width and height.
  • data.positioner: the dimensions of the positioner element with properties width and height.
  • data.side: which side of the anchor element the positioner is aligned against.
  • data.align: how the positioner is aligned relative to the specified side.
Type
Default
0
Example
sideSide'bottom'
Name
Description

Which side of the anchor element to align the popup against. May automatically change to avoid collisions.

Type
Default
'bottom'
sideOffsetnumber | OffsetFunction0
Description

Distance between the anchor and the popup in pixels. Also accepts a function that returns the distance to read the dimensions of the anchor and positioner elements, along with its side and alignment.

The function takes a data object parameter with the following properties:

  • data.anchor: the dimensions of the anchor element with properties width and height.
  • data.positioner: the dimensions of the positioner element with properties width and height.
  • data.side: which side of the anchor element the positioner is aligned against.
  • data.align: how the positioner is aligned relative to the specified side.
Type
Default
0
Example
arrowPaddingnumber5
Description

Minimum distance to maintain between the arrow and the edges of the popup.

Use it to prevent the arrow element from hanging out of the rounded corners of a popup.

Type
Default
5
anchorUnion
Name
Description

An element to position the popup against. By default, the popup will be positioned against the trigger.

Type
collisionAvoidanceCollisionAvoidance
Description

Determines how to handle collisions when positioning the popup.

side controls overflow on the preferred placement axis (top/bottom or left/right):

  • 'flip': keep the requested side when it fits; otherwise try the opposite side (top and bottom, or left and right).
  • 'shift': never change side; keep the requested side and move the popup within the clipping boundary so it stays visible.
  • 'none': do not correct side-axis overflow.

align controls overflow on the alignment axis (start/center/end):

  • 'flip': keep side, but swap start and end when the requested alignment overflows.
  • 'shift': keep side and requested alignment, then nudge the popup along the alignment axis to fit.
  • 'none': do not correct alignment-axis overflow.

fallbackAxisSide controls fallback behavior on the perpendicular axis when the preferred axis cannot fit:

  • 'start': allow perpendicular fallback and try the logical start side first (top before bottom, or left before right in LTR).
  • 'end': allow perpendicular fallback and try the logical end side first (bottom before top, or right before left in LTR).
  • 'none': do not fallback to the perpendicular axis.

When side is 'shift', explicitly setting align only supports 'shift' or 'none'. If align is omitted, it defaults to 'flip'.

Type
Example
collisionBoundaryBoundary'clipping-ancestors'
Description

An element or a rectangle that delimits the area that the popup is confined to.

Type
Default
'clipping-ancestors'
collisionPaddingPadding5
Description

Additional space to maintain from the edge of the collision boundary.

Type
Default
5
stickybooleanfalse
Name
Description

Whether to maintain the popup in the viewport after the anchor element was scrolled out of view.

Type
Default
false
positionMethod'absolute' | 'fixed''absolute'
Description

Determines which CSS position property to use.

Type
Default
'absolute'
classNamestring | function
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function
Name
Type
renderReactElement | function
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type
data-open

Present when the popup is open.

data-closed

Present when the popup is closed.

data-anchor-hidden

Present when the anchor is hidden.

data-align

Indicates how the popup is aligned relative to the specified side.

data-instant

Present if animations should be instant.

data-side

Indicates which side the popup is positioned relative to the trigger.

AttributeDescription
data-open

Present when the popup is open.

data-closed

Present when the popup is closed.

data-anchor-hidden

Present when the anchor is hidden.

data-align

Indicates how the popup is aligned relative to the specified side.

data-instant

Present if animations should be instant.

data-side

Indicates which side the popup is positioned relative to the trigger.

--anchor-height

The anchor’s height.

--anchor-width

The anchor’s width.

--available-height

The available height between the trigger and the edge of the viewport.

--available-width

The available width between the trigger and the edge of the viewport.

--positioner-height

The fixed height of the positioner element.

--positioner-width

The fixed width of the positioner element.

--transform-origin

The coordinates that this element is anchored to. Used for animations and transitions.

CSS VariableDescription
--anchor-height

The anchor’s height.

--anchor-width

The anchor’s width.

--available-height

The available height between the trigger and the edge of the viewport.

--available-width

The available width between the trigger and the edge of the viewport.

--positioner-height

The fixed height of the positioner element.

--positioner-width

The fixed width of the positioner element.

--transform-origin

The coordinates that this element is anchored to. Used for animations and transitions.

NavigationMenu.Positioner.PropsHide

Re-Export of Positioner props as NavigationMenuPositionerProps

NavigationMenu.Positioner.StateHide

A container for the navigation menu contents. Renders a <nav> element.

classNamestring | function
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function
Name
Type
renderReactElement | function
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type
data-open

Present when the popup is open.

data-closed

Present when the popup is closed.

data-align

Indicates how the popup is aligned relative to the specified side.

data-side

Indicates which side the popup is positioned relative to the trigger.

data-starting-style

Present when the popup is animating in.

data-ending-style

Present when the popup is animating out.

AttributeDescription
data-open

Present when the popup is open.

data-closed

Present when the popup is closed.

data-align

Indicates how the popup is aligned relative to the specified side.

data-side

Indicates which side the popup is positioned relative to the trigger.

data-starting-style

Present when the popup is animating in.

data-ending-style

Present when the popup is animating out.

--popup-height

The fixed height of the popup element.

--popup-width

The fixed width of the popup element.

CSS VariableDescription
--popup-height

The fixed height of the popup element.

--popup-width

The fixed width of the popup element.

NavigationMenu.Popup.PropsHide

Re-Export of Popup props as NavigationMenuPopupProps

NavigationMenu.Popup.StateHide

Viewport

The clipping viewport of the navigation menu’s current content. Renders a <div> element.

classNamestring | function
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function
Name
Type
renderReactElement | function
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type

NavigationMenu.Viewport.PropsHide

Re-Export of Viewport props as NavigationMenuViewportProps

NavigationMenu.Viewport.StateHide

Arrow

Displays an element pointing toward the navigation menu’s current anchor. Renders a <div> element.

classNamestring | function
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function
Name
Type
renderReactElement | function
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type
data-open

Present when the popup is open.

data-closed

Present when the popup is closed.

data-uncentered

Present when the popup arrow is uncentered.

data-align

Indicates how the popup is aligned relative to specified side.

data-side

Indicates which side the popup is positioned relative to the trigger.

AttributeDescription
data-open

Present when the popup is open.

data-closed

Present when the popup is closed.

data-uncentered

Present when the popup arrow is uncentered.

data-align

Indicates how the popup is aligned relative to specified side.

data-side

Indicates which side the popup is positioned relative to the trigger.

NavigationMenu.Arrow.PropsHide

Re-Export of Arrow props as NavigationMenuArrowProps

NavigationMenu.Arrow.StateHide