Menubar

A persistent horizontal bar of menus, like a desktop application.

<Menubar.Root>
	<Menubar.Menu>
		<Menubar.Trigger>Projects</Menubar.Trigger>
		<Menubar.Content>
			<Menubar.Item>New project <Menubar.Shortcut>⌘N</Menubar.Shortcut></Menubar.Item>
			<Menubar.Separator />
			<Menubar.Item variant="destructive">Cancel project</Menubar.Item>
		</Menubar.Content>
	</Menubar.Menu>
</Menubar.Root>

Once one menu is open, moving across the bar opens the others on hover.

API

PropTypeDefault
classNamestring | ((state: MenubarState) => string | undefined)CSS class applied to the element, or a function that returns a class based on the component's state.
disabledbooleanWhether the whole menubar is disabled.
loopFocusbooleanWhether to loop keyboard focus back to the first item when the end of the list is reached while using the arrow keys.
modalbooleanWhether the menubar is modal.
orientationMenuRootOrientationThe orientation of the menubar.
renderComponentRenderFn<HTMLProps, MenubarState> | 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: MenubarState) => 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: menubar/components/menubar-root.tsx.

PropTypeDefault
insetbooleanIndents the item to line up with siblings that have an icon or a checkmark.
checkedbooleanWhether the checkbox item is currently ticked. To render an uncontrolled checkbox item, use the defaultChecked prop instead.
classNamestring | ((state: MenuCheckboxItemState) => 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 menu when the item is clicked.
defaultCheckedbooleanWhether the checkbox item is initially ticked. To render a controlled checkbox item, use the checked prop instead.
disabledbooleanWhether the component should ignore user interaction.
idstring
labelstringOverrides the text label to use when the item is matched during keyboard text navigation.
nativeButtonbooleanWhether the component renders a native <button> element when replacing it via the render prop. Set to true if the rendered element is a native button.
onCheckedChange((checked: boolean, eventDetails: MenuRootChangeEventDetails) => void)Event handler called when the checkbox item is ticked or unticked.
onClick((event: BaseUIEvent<MouseEvent<HTMLDivElement, MouseEvent>>) => void)The click handler for the menu item.
renderComponentRenderFn<HTMLProps, MenuCheckboxItemState> | 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: MenuCheckboxItemState) => 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: menubar/components/menubar-checkbox-item.tsx.

PropTypeDefault
alignAlign"start"How to align the popup relative to the specified side.
alignOffsetnumber | OffsetFunction-4Additional 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:
childrenReactNode
classNamestring | ((state: MenuPopupState) => string | undefined)CSS class applied to the element, or a function that returns a class based on the component's state.
finalFocusboolean | RefObject<HTMLElement | null> | ((closeType: InteractionType) => void | boolean | HTMLElement | null)Determines the element to focus when the menu is closed.
idstring
renderComponentRenderFn<HTMLProps, MenuPopupState> | 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.
sideSideWhich 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: MenuPopupState) => 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: menubar/components/menubar-content.tsx.

PropTypeDefault
childrenReactNodeThe content of the component.
classNamestring | ((state: MenuGroupState) => string | undefined)CSS class applied to the element, or a function that returns a class based on the component's state.
renderComponentRenderFn<HTMLProps, MenuGroupState> | 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: MenuGroupState) => 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: menubar/components/menubar-group.tsx.

PropTypeDefault
insetbooleanIndents the item to line up with siblings that have an icon or a checkmark.
variant"default" | "destructive"destructive tints the item red, for the one action that deletes something.
classNamestring | ((state: MenuItemState) => 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 menu when the item is clicked.
disabledbooleanWhether the component should ignore user interaction.
idstring
labelstringOverrides the text label to use when the item is matched during keyboard text navigation.
nativeButtonbooleanWhether the component renders a native <button> element when replacing it via the render prop. Set to true if the rendered element is a native button.
onClick((event: BaseUIEvent<MouseEvent<HTMLDivElement, MouseEvent>>) => void)The click handler for the menu item.
renderComponentRenderFn<HTMLProps, MenuItemState> | 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: MenuItemState) => 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: menubar/components/menubar-item.tsx.

PropTypeDefault
insetbooleanIndents the item to line up with siblings that have an icon or a checkmark.

Plus the DOM props of the element it renders. Source: menubar/components/menubar-label.tsx.

PropTypeDefault
actionsRefRefObject<MenuRootActions | null>A ref to imperative actions.
childrenPayloadChildRenderFunction<unknown> | ReactNodeThe content of the popover. This can be a regular React node or a render function that receives the payload of the active trigger.
closeParentOnEscbooleanWhen in a submenu, determines whether pressing the Escape key closes the entire menu, or only the current child menu.
defaultOpenbooleanWhether the menu is initially open. To render a controlled menu, use the open prop instead.
defaultTriggerIdstring | nullID of the trigger that the popover is associated with. This is useful in conjunction with the defaultOpen prop to create an initially open popover.
disabledbooleanWhether the component should ignore user interaction.
handleMenuHandle<unknown>A handle to associate the menu with a trigger. If specified, allows external triggers to control the menu's open state.
highlightItemOnHoverbooleanWhether moving the pointer over items should highlight them. Disabling this prop allows CSS :hover to be differentiated from the :focus (data-highlighted) state.
loopFocusbooleanWhether to loop keyboard focus back to the first item when the end of the list is reached while using the arrow keys.
modalbooleanDetermines if the menu enters a modal state when open.
onOpenChange((open: boolean, eventDetails: MenuRootChangeEventDetails) => void)Event handler called when the menu is opened or closed.
onOpenChangeComplete((open: boolean) => void)Event handler called after any animations complete when the menu is closed.
openbooleanWhether the menu is currently open.
orientationMenuRootOrientationThe visual orientation of the menu. Controls whether roving focus uses up/down or left/right arrow keys.
triggerIdstring | nullID of the trigger that the popover is associated with. This is useful in conjunction with the open prop to create a controlled popover. There's no need to specify this prop when the popover is uncontrolled (that is, when the open prop is not set).

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

PropTypeDefault
classNamestring | ((state: MenuPortalState) => string | undefined)CSS class applied to the element, or a function that returns a class based on the component's state.
containerHTMLElement | RefObject<HTMLElement | ShadowRoot | null> | ShadowRoot | nullA parent element to render the portal element into.
keepMountedbooleanWhether to keep the portal mounted in the DOM while the popup is hidden.
renderComponentRenderFn<HTMLProps, MenuPortalState> | 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: MenuPortalState) => 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: menubar/components/menubar-portal.tsx.

PropTypeDefault
childrenReactNodeThe content of the component.
classNamestring | ((state: MenuRadioGroupState) => string | undefined)CSS class applied to the element, or a function that returns a class based on the component's state.
defaultValueanyThe uncontrolled value of the radio item that should be initially selected. To render a controlled radio group, use the value prop instead.
disabledbooleanWhether the component should ignore user interaction.
onValueChange((value: any, eventDetails: MenuRootChangeEventDetails) => void)Function called when the selected value changes.
renderComponentRenderFn<HTMLProps, MenuRadioGroupState> | 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: MenuRadioGroupState) => 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 radio item that should be currently selected. To render an uncontrolled radio group, use the defaultValue prop instead.

Plus the DOM props of the element it renders. Source: menubar/components/menubar-radio-group.tsx.

PropTypeDefault
insetbooleanIndents the item to line up with siblings that have an icon or a checkmark.
valueanyrequiredValue of the radio item. This is the value that will be set in the MenuRadioGroup when the item is selected.
classNamestring | ((state: MenuRadioItemState) => 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 menu when the item is clicked.
disabledbooleanWhether the component should ignore user interaction.
idstring
labelstringOverrides the text label to use when the item is matched during keyboard text navigation.
nativeButtonbooleanWhether the component renders a native <button> element when replacing it via the render prop. Set to true if the rendered element is a native button.
onClick((event: BaseUIEvent<MouseEvent<HTMLDivElement, MouseEvent>>) => void)The click handler for the menu item.
renderComponentRenderFn<HTMLProps, MenuRadioItemState> | 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: MenuRadioItemState) => 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: menubar/components/menubar-radio-item.tsx.

PropTypeDefault
classNamestring | ((state: SeparatorState) => string | undefined)CSS class applied to the element, or a function that returns a class based on the component's state.
orientationOrientationThe orientation of the separator.
renderComponentRenderFn<HTMLProps, SeparatorState> | 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: SeparatorState) => 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: menubar/components/menubar-separator.tsx.

PropTypeDefault
keysreadonly string[]Render each key as a small Kbd chip. Omit it and children are shown as plain text.

Plus the DOM props of the element it renders. Source: menubar/components/menubar-shortcut.tsx.

PropTypeDefault
actionsRefRefObject<MenuRootActions | null>A ref to imperative actions.
childrenReactNodeThe content of the submenu.
closeParentOnEscbooleanWhen in a submenu, determines whether pressing the Escape key closes the entire menu, or only the current child menu.
defaultOpenbooleanWhether the menu is initially open. To render a controlled menu, use the open prop instead.
disabledbooleanWhether the component should ignore user interaction.
highlightItemOnHoverbooleanWhether moving the pointer over items should highlight them. Disabling this prop allows CSS :hover to be differentiated from the :focus (data-highlighted) state.
loopFocusbooleanWhether to loop keyboard focus back to the first item when the end of the list is reached while using the arrow keys.
onOpenChange((open: boolean, eventDetails: MenuRootChangeEventDetails) => void)Event handler called when the menu is opened or closed.
onOpenChangeComplete((open: boolean) => void)Event handler called after any animations complete when the menu is closed.
openbooleanWhether the menu is currently open.
orientationMenuRootOrientationThe visual orientation of the menu. Controls whether roving focus uses up/down or left/right arrow keys.

Plus the DOM props of the element it renders. Source: menubar/components/menubar-sub.tsx.

PropTypeDefault
alignAlignHow to align the popup relative to the specified side.
alignOffsetnumber | OffsetFunctionAdditional 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:
childrenReactNode
classNamestring | ((state: MenuPopupState) => string | undefined)CSS class applied to the element, or a function that returns a class based on the component's state.
finalFocusboolean | RefObject<HTMLElement | null> | ((closeType: InteractionType) => void | boolean | HTMLElement | null)Determines the element to focus when the menu is closed.
idstring
renderComponentRenderFn<HTMLProps, MenuPopupState> | 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.
sideSideWhich side of the anchor element to align the popup against. May automatically change to avoid collisions.
sideOffsetnumber | OffsetFunctionDistance 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: MenuPopupState) => 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: menubar/components/menubar-sub-content.tsx.

PropTypeDefault
insetbooleanIndents the item to line up with siblings that have an icon or a checkmark.
classNamestring | ((state: MenuSubmenuTriggerState) => 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 menu that was opened on hover. Specified in milliseconds. Requires the openOnHover prop.
delaynumberHow long to wait before the menu may be opened on hover. Specified in milliseconds. Requires the openOnHover prop.
disabledbooleanWhether the component should ignore user interaction.
idstring
labelstringOverrides the text label to use when the item is matched during keyboard text navigation.
nativeButtonbooleanWhether the component renders a native <button> element when replacing it via the render prop. Set to true if the rendered element is a native button.
onClick((event: BaseUIEvent<MouseEvent<HTMLDivElement, MouseEvent>>) => void)
openOnHoverbooleanWhether the menu should also open when the trigger is hovered.
renderComponentRenderFn<HTMLProps, MenuSubmenuTriggerState> | 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: MenuSubmenuTriggerState) => 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: menubar/components/menubar-sub-trigger.tsx.

PropTypeDefault
childrenReactNode
classNamestring | ((state: MenuTriggerState) => 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 menu that was opened on hover. Specified in milliseconds. Requires the openOnHover prop.
delaynumberHow long to wait before the menu may be opened on hover. Specified in milliseconds. Requires the openOnHover prop.
disabledbooleanWhether the component should ignore user interaction.
handleMenuHandle<unknown>A handle to associate the trigger with a menu.
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>).
openOnHoverbooleanWhether the menu should also open when the trigger is hovered.
payloadunknownA payload to pass to the menu when it is opened.
renderComponentRenderFn<HTMLProps, MenuTriggerState> | 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: MenuTriggerState) => 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: menubar/components/menubar-trigger.tsx.