Navigation Menu

A collection of links and menus for website navigation.

Loading...

Anatomy

ProductsCompanyPricingAnalyticsMarketingrootlisttriggerlinkviewportcontent
<NavigationMenu.Root>
  <NavigationMenu.List>
    <NavigationMenu.Item>
      <NavigationMenu.Trigger />
      <NavigationMenu.ItemIndicator />
      <NavigationMenu.Content>
        <NavigationMenu.Link />
      </NavigationMenu.Content>
    </NavigationMenu.Item>
    <NavigationMenu.Indicator>
      <NavigationMenu.Arrow />
    </NavigationMenu.Indicator>
  </NavigationMenu.List>
  <NavigationMenu.ViewportPositioner>
    <NavigationMenu.Viewport />
  </NavigationMenu.ViewportPositioner>
</NavigationMenu.Root>

Examples

Viewport

Use NavigationMenu.Viewport for one shared panel. Add NavigationMenu.Indicator so the arrow tracks the open trigger.

Set current on the link for the current page. It renders aria-current="page" and a data-current attribute for styling.

Vertical

Set orientation="vertical" for sidebar navigation. Panels open to the side. ArrowUp and ArrowDown move between triggers, and ArrowRight enters the open panel.

Indicator

Render NavigationMenu.Indicator inside the list to highlight the active trigger, tab-style. It slides between triggers with a CSS transition on --trigger-x and --trigger-width. For a static per-item marker, use NavigationMenu.ItemIndicator.

Controlled

Use value and onValueChange to control the active item.

Root Provider

Use RootProvider with the useNavigationMenu hook to access the state and methods from outside the component.

RootProvider replaces Root. Don't use both.

Context

Read state with NavigationMenu.Context or the useNavigationMenuContext hook.

Guides

Use asChild to render NavigationMenu.Link as your router's link component.

import { Link as RouterLink } from 'react-router-dom'
import { NavigationMenu } from '@ark-ui/<framework>/navigation-menu'

export const MenuLink = (props: NavigationMenu.LinkProps) => {
  return (
    <NavigationMenu.Link {...props} asChild>
      <RouterLink to={props.href ?? '#'}>{props.children}</RouterLink>
    </NavigationMenu.Link>
  )
}

Viewport size

NavigationMenu.Root and NavigationMenu.Viewport expose these CSS variables:

/* size and position of the active trigger */
--trigger-width: <pixel-value>;
--trigger-height: <pixel-value>;
--trigger-x: <pixel-value>;
--trigger-y: <pixel-value>;

/* size and position of the active content */
--viewport-width: <pixel-value>;
--viewport-height: <pixel-value>;
--viewport-x: <pixel-value>;
--viewport-y: <pixel-value>;

Animate the shared panel between items with --viewport-width and --viewport-height:

[data-navigation-menu-viewport] {
  width: var(--viewport-width);
  height: var(--viewport-height);
  transition:
    width 250ms ease,
    height 250ms ease;
}

Large menus

For content taller than the viewport, cap the panel and scroll the content:

[data-navigation-menu-viewport] {
  max-height: min(var(--viewport-height), 70vh);
}

[data-navigation-menu-content] {
  max-height: 70vh;
  overflow-y: auto;
}

API Reference

Props

Root

Defines the <nav> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
closeDelay300
number

The delay before the menu closes

defaultValue
string

The default value of the navigation menu. Use when you don't want to control the value of the menu.

disableClickTrigger
boolean

Whether to disable the click trigger

disableHoverTrigger
boolean

Whether to disable the hover trigger

disablePointerLeaveClose
boolean

Whether to disable the pointer leave close

hideMode'display-none'
HideMode

How to hide content when mounted but not present. - `'display-none'`: HTML `hidden` attribute. Effects stay alive. - `'activity'`: React 19 `<Activity mode="hidden">`. Effects pause. Requires React 19+.

id
string

The unique identifier of the machine.

ids
ElementIds

The ids of the elements in the machine.

lazyMountfalse
boolean

Whether to enable lazy mounting

onValueChange
(details: ValueChangeDetails) => void

Function called when the value of the menu changes

openDelay200
number

The delay before the menu opens

orientation'horizontal'
'horizontal' | 'vertical'

The orientation of the element.

render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

translations
IntlTranslations

Specifies the localized strings that identifies the accessibility elements and their states

unmountOnExitfalse
boolean

Whether to unmount on exit.

value
string

The controlled value of the navigation menu

AttributeDescription
[data-navigation-menu-root]<uid>
[data-orientation]The orientation of the navigation-menu
CSS VariableDescription
--trigger-widthThe width of the Root
--trigger-heightThe height of the Root
--trigger-xThe trigger x value for the Root
--trigger-yThe trigger y value for the Root
--viewport-widthThe width of the Root
--viewport-heightThe height of the Root
--viewport-xThe viewport x value for the Root
--viewport-yThe viewport y value for the Root

Arrow

Defines the <div> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

AttributeDescription
[data-navigation-menu-arrow]<uid>
[data-orientation]The orientation of the arrow

Content

Defines the <div> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<NavigationMenuContentState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

value
string

The value of the item this content belongs to

AttributeDescription
[data-navigation-menu-content]<uid>
[data-state]"open" | "closed"
[data-orientation]The orientation of the content
[data-activation-direction]
[data-motion]
[data-value]The value of the item
[data-nested]Present when the content is nested within another {{widget}}
[data-has-nested]Present when the content has nested {{widget}}s
CSS VariableDescription
--layer-indexThe index of the dismissable in the layer stack
--nested-layer-countThe number of nested navigation-menus

Indicator

Defines the <div> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

AttributeDescription
[data-navigation-menu-indicator]<uid>
[data-state]"open" | "closed"
[data-orientation]The orientation of the indicator

ItemIndicator

Defines the <span> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

AttributeDescription
[data-navigation-menu-item-indicator]<uid>
[data-state]"open" | "closed"
[data-orientation]The orientation of the item
[data-value]The value of the item

Item

Defines the <div> element.

AttributeDefaultType
value
string

The value of the item

asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
disabled
boolean

Whether the item is disabled

render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<NavigationMenuItemState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

AttributeDescription
[data-navigation-menu-item]<uid>
[data-value]The value of the item
[data-state]"open" | "closed"
[data-orientation]The orientation of the item
[data-disabled]Present when disabled

Link

Defines the <a> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
closeOnClicktrue
boolean

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

current
boolean

Whether the link is the current link

onSelect
(event: CustomEvent<any>) => void

Function called when the link is selected

render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

value
string

The value of the item this link belongs to

AttributeDescription
[data-navigation-menu-link]<uid>
[data-value]The value of the item
[data-current]Present when current

List

Defines the <div> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

AttributeDescription
[data-navigation-menu-list]<uid>
[data-orientation]The orientation of the list

RootProvider

Defines the <nav> element.

AttributeDefaultType
value
UseNavigationMenuReturn

asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
hideMode'display-none'
HideMode

How to hide content when mounted but not present. - `'display-none'`: HTML `hidden` attribute. Effects stay alive. - `'activity'`: React 19 `<Activity mode="hidden">`. Effects pause. Requires React 19+.

lazyMountfalse
boolean

Whether to enable lazy mounting

render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

unmountOnExitfalse
boolean

Whether to unmount on exit.

Trigger

Defines the <button> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
disabled
boolean

Whether the item is disabled

render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<NavigationMenuTriggerState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

AttributeDescription
[data-navigation-menu-trigger]<uid>
[data-uid]
[data-trigger-proxy-id]
[data-value]The value of the item
[data-state]"open" | "closed"
[data-disabled]Present when disabled

ViewportPositioner

Defines the <div> element.

AttributeDefaultType
align
'center' | 'start' | 'end'

Placement of the viewport for css variables `(--viewport-x, --viewport-y)`.

asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

AttributeDescription
[data-navigation-menu-viewport-positioner]<uid>
[data-orientation]The orientation of the viewportpositioner
[data-align]

Viewport

Defines the <div> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

AttributeDescription
[data-navigation-menu-viewport]<uid>
[data-state]"open" | "closed"
[data-orientation]The orientation of the viewport
[data-activation-direction]
[data-align]
[data-nested]Present when the viewport is nested within another {{widget}}
[data-has-nested]Present when the viewport has nested {{widget}}s
CSS VariableDescription
--viewport-widthThe width of the Viewport
--viewport-heightThe height of the Viewport
--viewport-xThe viewport x value for the Viewport
--viewport-yThe viewport y value for the Viewport

Context

API

PropertyType
value
string | null

The current value of the menu

setValue
(value: string, reason?: ValueChangeReason) => void

Sets the value of the menu

open
boolean

Whether the menu is open

isViewportRendered
boolean

Whether the viewport is rendered

activationDirection
Exclude<ActivationDirection, "none"> | null

Where the open item's trigger sits relative to the previous one: `left`, `right`, `up` or `down`. `null` when opened from closed.

getViewportNode
() => HTMLElement | null

Gets the viewport node element

orientation
Orientation

The orientation of the menu

reposition
VoidFunction

Function to reposition the viewport

getRootState
() => RootState

Returns the state of the root. The list, indicator, arrow and viewport positioner share it.

getTriggerState
(props: ItemProps) => TriggerState

Returns the state of a specific trigger

getContentState
(props: ContentProps) => ContentState

Returns the state of a specific content

getViewportState
() => ViewportState

Returns the state of the viewport

getItemState
(props: ItemProps) => ItemState

Returns the state of a specific item

Accessibility

Complies with the Navigation Menubar WAI-ARIA design pattern.

Keyboard Support

KeyDescription
ArrowDown
When focus is on trigger (vertical orientation), moves focus to the next trigger.
ArrowUp
When focus is on trigger (vertical orientation), moves focus to the previous trigger.
ArrowRight
When focus is on trigger (horizontal orientation), moves focus to the next trigger.
When focus is on content, moves focus to the next link.
ArrowLeft
When focus is on trigger (horizontal orientation), moves focus to the previous trigger.
When focus is on content, moves focus to the previous link.
Home
When focus is on trigger, moves focus to the first trigger.
When focus is on content, moves focus to the first link.
End
When focus is on trigger, moves focus to the last trigger.
When focus is on content, moves focus to the last link.