NavigationMenu

A horizontal menu whose items open panels of links.

<NavigationMenu.Root>
	<NavigationMenu.List>
		<NavigationMenu.Item>
			<NavigationMenu.Trigger>Projects</NavigationMenu.Trigger>
			<NavigationMenu.Content>
				<ul className="grid w-64 gap-1">
					<li><NavigationMenu.Link href="/projects">Open projects</NavigationMenu.Link></li>
				</ul>
			</NavigationMenu.Content>
		</NavigationMenu.Item>
	</NavigationMenu.List>
</NavigationMenu.Root>

This is for navigation; DropdownMenu is for actions. The difference is real to a screen reader, which announces one as a list of links and the other as a menu of commands.

A top-level item that goes straight somewhere needs no trigger — use a NavigationMenu.Link with navigationMenuTriggerStyle().

API

PropTypeDefault
actionsRefRefObject<NavigationMenuRootActions | null>A ref to imperative actions.
alignAlign"start"How to align the popup relative to the specified side.
alignOffsetnumber | OffsetFunction0Additional 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:
classNamestring | ((state: NavigationMenuRootState) => string | undefined)CSS class applied to the element, or a function that returns a class based on the component's state.
closeDelaynumberHow long to wait before closing the navigation popup. Specified in milliseconds.
collisionPaddingPaddingAdditional space to maintain from the edge of the collision boundary.
defaultValueanyThe uncontrolled value of the item that should be initially selected. To render a controlled navigation menu, use the value prop instead.
delaynumberHow long to wait before opening the navigation popup. Specified in milliseconds.
onOpenChangeComplete((open: boolean) => void)Event handler called after any animations complete when the navigation menu is closed.
onValueChange((value: any, eventDetails: NavigationMenuRootChangeEventDetails) => void)Callback fired when the value changes.
orientation"horizontal" | "vertical"The orientation of the navigation menu.
renderComponentRenderFn<HTMLProps, NavigationMenuRootState> | ReactElement<unknown, string | JSXElementConstructor<any>>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.
sideSide"bottom"Which side of the anchor element to align the popup against. May automatically change to avoid collisions.
sideOffsetnumber | OffsetFunction8Distance 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:
styleCSSProperties | ((state: NavigationMenuRootState) => CSSProperties | undefined)Style applied to the element, or a function that returns a style object based on the component's state.
valueanyThe 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.

Plus the DOM props of the element it renders. Source: navigation-menu/components/navigation-menu-root.tsx.

PropTypeDefault
classNamestring | ((state: NavigationMenuContentState) => string | undefined)CSS class applied to the element, or a function that returns a class based on the component's state.
keepMountedbooleanWhether 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.
renderComponentRenderFn<HTMLProps, NavigationMenuContentState> | ReactElement<unknown, string | JSXElementConstructor<any>>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.
styleCSSProperties | ((state: NavigationMenuContentState) => CSSProperties | undefined)Style applied to the element, or a function that returns a style object based on the component's state.

Plus the DOM props of the element it renders. Source: navigation-menu/components/navigation-menu-content.tsx.

PropTypeDefault
classNamestring | ((state: NavigationMenuIconState) => string | undefined)CSS class applied to the element, or a function that returns a class based on the component's state.
renderComponentRenderFn<HTMLProps, NavigationMenuIconState> | ReactElement<unknown, string | JSXElementConstructor<any>>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.
styleCSSProperties | ((state: NavigationMenuIconState) => CSSProperties | undefined)Style applied to the element, or a function that returns a style object based on the component's state.

Plus the DOM props of the element it renders. Source: navigation-menu/components/navigation-menu-indicator.tsx.

PropTypeDefault
classNamestring | ((state: NavigationMenuItemState) => string | undefined)CSS class applied to the element, or a function that returns a class based on the component's state.
renderComponentRenderFn<HTMLProps, NavigationMenuItemState> | ReactElement<unknown, string | JSXElementConstructor<any>>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.
styleCSSProperties | ((state: NavigationMenuItemState) => CSSProperties | undefined)Style applied to the element, or a function that returns a style object based on the component's state.
valueanyA 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.

Plus the DOM props of the element it renders. Source: navigation-menu/components/navigation-menu-item.tsx.

PropTypeDefault
activebooleanWhether the link is the currently active page.
classNamestring | ((state: NavigationMenuLinkState) => string | undefined)CSS class applied to the element, or a function that returns a class based on the component's state.
closeOnClickbooleanWhether to close the navigation menu when the link is clicked.
renderComponentRenderFn<HTMLProps, NavigationMenuLinkState> | ReactElement<unknown, string | JSXElementConstructor<any>>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.
styleCSSProperties | ((state: NavigationMenuLinkState) => CSSProperties | undefined)Style applied to the element, or a function that returns a style object based on the component's state.

Plus the DOM props of the element it renders. Source: navigation-menu/components/navigation-menu-link.tsx.

PropTypeDefault
classNamestring | ((state: NavigationMenuListState) => string | undefined)CSS class applied to the element, or a function that returns a class based on the component's state.
renderComponentRenderFn<HTMLProps, NavigationMenuListState> | ReactElement<unknown, string | JSXElementConstructor<any>>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.
styleCSSProperties | ((state: NavigationMenuListState) => CSSProperties | undefined)Style applied to the element, or a function that returns a style object based on the component's state.

Plus the DOM props of the element it renders. Source: navigation-menu/components/navigation-menu-list.tsx.

PropTypeDefault
alignAlign"start"How to align the popup relative to the specified side.
alignOffsetnumber | OffsetFunction0Additional 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:
anchorElement | RefObject<Element | null> | VirtualElement | (() => Element | VirtualElement | null) | nullAn element to position the popup against. By default, the popup will be positioned against the trigger.
arrowPaddingnumberMinimum 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.
classNamestring | ((state: NavigationMenuPositionerState) => string | undefined)CSS class applied to the element, or a function that returns a class based on the component's state.
collisionAvoidanceCollisionAvoidanceDetermines how to handle collisions when positioning the popup. side controls overflow on the preferred placement axis (top/bottom or left/right): align controls overflow on the alignment axis (start/center/end): fallbackAxisSide controls fallback behavior on the perpendicular axis when the preferred axis cannot fit: When side is 'shift', explicitly setting align only supports 'shift' or 'none'. If align is omitted, it defaults to 'flip'.
collisionBoundaryBoundaryAn element or a rectangle that delimits the area that the popup is confined to.
collisionPaddingPaddingAdditional space to maintain from the edge of the collision boundary.
disableAnchorTrackingbooleanWhether to disable the popup from tracking any layout shift of its positioning anchor.
positionMethod"absolute" | "fixed"Determines which CSS position property to use.
renderComponentRenderFn<HTMLProps, NavigationMenuPositionerState> | ReactElement<unknown, string | JSXElementConstructor<any>>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.
sideSide"bottom"Which side of the anchor element to align the popup against. May automatically change to avoid collisions.
sideOffsetnumber | OffsetFunction8Distance 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:
stickybooleanWhether to maintain the popup in the viewport after the anchor element was scrolled out of view.
styleCSSProperties | ((state: NavigationMenuPositionerState) => CSSProperties | undefined)Style applied to the element, or a function that returns a style object based on the component's state.

Plus the DOM props of the element it renders. Source: navigation-menu/components/navigation-menu-positioner.tsx.

PropTypeDefault
classNamestring | ((state: NavigationMenuTriggerState) => string | undefined)CSS class applied to the element, or a function that returns a class based on the component's state.
nativeButtonbooleanWhether 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>).
renderComponentRenderFn<HTMLProps, NavigationMenuTriggerState> | ReactElement<unknown, string | JSXElementConstructor<any>>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.
styleCSSProperties | ((state: NavigationMenuTriggerState) => CSSProperties | undefined)Style applied to the element, or a function that returns a style object based on the component's state.

Plus the DOM props of the element it renders. Source: navigation-menu/components/navigation-menu-trigger.tsx.