Menu

A list of options that appears when a user interacts with a button.

Loading...

Anatomy

<Menu.Root>
  <Menu.Trigger>
    <Menu.Indicator />
  </Menu.Trigger>
  <Menu.Positioner>
    <Menu.Content>
      <Menu.Arrow>
        <Menu.ArrowTip />
      </Menu.Arrow>
      <Menu.Item />
      <Menu.ItemGroup>
        <Menu.ItemGroupLabel />
        <Menu.Item />
      </Menu.ItemGroup>
      <Menu.Separator />
    </Menu.Content>
  </Menu.Positioner>
</Menu.Root>

Examples

Item Selection

onSelect receives the selected item's id.

Root Provider

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

Grouping

Use Menu.ItemGroup and Menu.ItemGroupLabel to group related items.

Use asChild to render a menu item as an anchor.

Checkbox

Use Menu.Checkbox for checkbox items.

Radio Group

Use Menu.RadioGroup to group radio items.

Collection

Pass a collection to Menu.Root to render plain, checkbox and radio items from one data list. Set groupSort so groups render in keyboard navigation order.

Context Menu

Use Menu.ContextTrigger to open the menu on right-click. With pen or touch, a long-press of about 700ms also opens it.

Pass a value to each Menu.ContextTrigger to share one menu across targets. Right-clicking another trigger while open moves the menu there. onTriggerValueChange reports the active trigger.

Nested

Render another Menu and open it with Menu.TriggerItem.

Inside a dialog, set lazyMount and unmountOnExit so the menu cleans up when the dialog closes.

Open a confirmation dialog from a menu item, e.g. before a destructive delete.

Multiple Triggers

Pass a value to each Menu.Trigger to share one menu. It repositions to the activated trigger.

Async Filtering

Use Menu.Input with useAsyncList to load matching items as the user types.

Guides

Custom IDs

Ark UI generates menu item ids. A custom id breaks the component's internal getElementById lookups.

// ❌ Don't do this
<Menu.Item id="custom-id" value="custom-value">
  Custom Item
</Menu.Item>

// ✅ Do this
<Menu.Item value="custom-value">
  Custom Item
</Menu.Item>

Render the link as the menu item itself with asChild, not as its child.

This gives the link the menu item's ARIA attributes and keyboard interactions.

A reusable MenuItemLink:

interface MenuItemLinkProps extends Menu.ItemProps {
  href?: string
  target?: string
}

export const MenuItemLink = (props: MenuItemLinkProps) => {
  const { href, target, children, ...rest } = props
  return (
    <Menu.Item {...rest} asChild>
      <a href={href} target={target}>
        {children}
      </a>
    </Menu.Item>
  )
}

API Reference

Props

Root

PropDefaultType
anchorPoint
Point

The positioning point for the menu. Can be set by the context menu trigger or the button trigger.

aria-label
string

The accessibility label for the menu

autoHighlightfalse
boolean | 'always'

Whether a filter input highlights the first item when its query changes. - `true`: highlight it while the query is not empty - `"always"`: highlight it even when the query is empty, and keep a highlight when the pointer leaves

closeOnSelecttrue
boolean

Whether to close the menu when an option is selected

collection
ListCollection<any, never>

The menu's items, in order. Set it when the items are virtualized, so the keyboard and typeahead can reach items that aren't rendered.

defaultHighlightedValue
string

The initial highlighted value of the menu item when rendered. Use when you don't need to control the highlighted value of the menu item.

defaultOpen
boolean

The initial open state of the menu when rendered. Use when you don't need to control the open state of the menu.

defaultTriggerValue
string

The initial trigger value when rendered. Use when you don't need to control the trigger value.

finalFocusEl
() => MaybeElement

The element to focus when the menu closes. Return `null` to use the default (the trigger, or the element focused before a context menu opened).

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+.

highlightedValue
string

The controlled highlighted value of the menu item.

id
string

The unique identifier of the machine.

ids
ElementIds

The ids of the elements in the menu. Useful for composition.

immediate
boolean

Whether to synchronize the present change immediately or defer it to the next frame

initialFocusEl
() => false | MaybeElement

The element to focus when the menu opens. Return `false` to skip moving focus, or `null` to use the default.

lazyMountfalse
boolean

Whether to enable lazy mounting

loopFocusfalse
boolean

Whether to loop the keyboard navigation.

navigate
(details: NavigateDetails) => void

Function to navigate to the selected item if it's an anchor element

onEnterComplete
VoidFunction

Function called when the animation ends in the open state

onEscapeKeyDown
(event: KeyboardEvent) => void

Function called when the escape key is pressed

onExitComplete
VoidFunction

Function called when the animation ends in the closed state

onFocusOutside
(event: FocusOutsideEvent) => void

Function called when the focus is moved outside the component

onHighlightChange
(details: HighlightChangeDetails) => void

Function called when the highlighted menu item changes.

onInteractOutside
(event: InteractOutsideEvent) => void

Function called when an interaction happens outside the component

onOpenChange
(details: OpenChangeDetails) => void

Function called when the menu opens or closes

onPointerDownOutside
(event: PointerDownOutsideEvent) => void

Function called when the pointer is pressed down outside the component

onRequestDismiss
(event: LayerDismissEvent) => void

Function called when this layer is closed due to a parent layer being closed

onSelect
(details: SelectionDetails) => void

Function called when a menu item is selected.

onTriggerValueChange
(details: TriggerValueChangeDetails) => void

Function called when the trigger value changes.

open
boolean

The controlled open state of the menu

popupType'menu'
'dialog' | 'menu'

The type of popup the trigger opens. - `"menu"`: the content is the menu and manages keyboard focus across its items. - `"dialog"`: the content is a dialog holding the menu list, for widgets that keep focus such as a filter input.

positioning
PositioningOptions

The options used to dynamically position the menu

present
boolean

Whether the node is present (controlled by the user)

scrollToIndexFn
(details: ScrollToIndexDetails) => void

Scrolls the item at an index into view, for virtualized items. Used with `collection`.

skipAnimationOnMountfalse
boolean

Whether to allow the initial presence animation.

triggerValue
string

The controlled trigger value

typeaheadtrue
boolean

Whether the pressing printable characters should trigger typeahead navigation

unmountOnExitfalse
boolean

Whether to unmount on exit.

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-menu-arrow]<uid>
[data-state]"open" | "closed"
CSS VariableDescription
--arrow-sizeThe size of the arrow
--arrow-size-halfHalf the size of the arrow
--arrow-backgroundUse this variable to style the arrow background
--arrow-offsetThe offset position of the arrow

ArrowTip

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.

CheckboxItem

Defines the <div> element.

AttributeDefaultType
checked
boolean

Whether the option is checked

value
string

The value of the option

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.
closeOnSelect
boolean

Whether the menu should be closed when the option is selected.

disabled
boolean

Whether the menu item is disabled

onCheckedChange
(checked: boolean) => void

Function called when the option state is changed

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

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.

valueText
string

The textual value of the option. Used in typeahead navigation of the menu. If not provided, the text content of the menu item will be used.

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<MenuContentState>

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-menu-content]<uid>
[data-value]The value of the item
[data-state]"open" | "closed"
[data-instant]
[data-placement]The placement of the content
[data-side]The side of the trigger that the content is positioned on
[data-activation-direction]
[data-nested]menu
[data-has-nested]menu
CSS VariableDescription
--layer-indexThe index of the dismissable in the layer stack
--nested-layer-countThe number of nested menus

ContextTrigger

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.
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 that identifies this specific trigger

AttributeDescription
[data-menu-context-trigger]<uid>
[data-value]The value of the item
[data-current]Present when current
[data-state]"open" | "closed"

Indicator

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-menu-indicator]<uid>
[data-state]"open" | "closed"

Input

Defines the <input> 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-menu-input]<uid>
[data-highlighted]Present when highlighted

ItemGroupLabel

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.

ItemGroup

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.

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-menu-item-indicator]<uid>
[data-disabled]Present when disabled
[data-highlighted]Present when highlighted
[data-state]"checked"

Item

Defines the <div> element.

AttributeDefaultType
value
string

The unique value of the menu item option.

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.
closeOnSelect
boolean

Whether the menu should be closed when the option is selected.

disabled
boolean

Whether the menu item is disabled

onSelect
VoidFunction

The function to call when the item is selected

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

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.

valueText
string

The textual value of the option. Used in typeahead navigation of the menu. If not provided, the text content of the menu item will be used.

AttributeDescription
[data-menu-item]<uid>
[data-disabled]Present when disabled
[data-highlighted]Present when highlighted
[data-value]The value of the item
[data-valuetext]The human-readable value
[data-close-on-select]

ItemText

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-menu-item-text]<uid>
[data-disabled]Present when disabled
[data-highlighted]Present when highlighted
[data-state]"checked"

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.

Positioner

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<MenuPositionerState>

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-menu-positioner]<uid>
[data-instant]
[data-transitioning]
[data-nested]Present when the positioner is nested within another {{widget}}
[data-has-nested]Present when the positioner has nested {{widget}}s
CSS VariableDescription
--reference-widthThe width of the reference element
--reference-heightThe height of the root
--available-widthThe available width in viewport
--available-heightThe available height in viewport
--xThe x position for transform
--yThe y position for transform
--transform-originThe transform origin for animations

RadioItemGroup

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.
onValueChange
(e: ValueChangeDetails) => void

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

RadioItem

Defines the <div> element.

AttributeDefaultType
value
string

The value of the option

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.
closeOnSelect
boolean

Whether the menu should be closed when the option is selected.

disabled
boolean

Whether the menu item is disabled

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

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.

valueText
string

The textual value of the option. Used in typeahead navigation of the menu. If not provided, the text content of the menu item will be used.

RootProvider

PropDefaultType
value
UseMenuReturn

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+.

immediate
boolean

Whether to synchronize the present change immediately or defer it to the next frame

lazyMountfalse
boolean

Whether to enable lazy mounting

onEnterComplete
VoidFunction

Function called when the animation ends in the open state

onExitComplete
VoidFunction

Function called when the animation ends in the closed state

present
boolean

Whether the node is present (controlled by the user)

skipAnimationOnMountfalse
boolean

Whether to allow the initial presence animation.

unmountOnExitfalse
boolean

Whether to unmount on exit.

Separator

Defines the <hr> 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.

TriggerItem

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.

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.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<MenuTriggerState>

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 that identifies this specific trigger

AttributeDescription
[data-menu-trigger]<uid>
[data-disabled]Present when disabled
[data-placement]The placement of the trigger
[data-side]The side of the trigger that the trigger is positioned on
[data-value]The value of the item
[data-current]Present when current
[data-controls]
[data-state]"open" | "closed"

Context

API

PropertyType
open
boolean

Whether the menu is open

setOpen
(open: boolean, reason?: OpenChangeReason) => void

Function to open or close the menu

triggerValue
string | null

The trigger value

setTriggerValue
(value: string | null) => void

Function to set the trigger value

activationDirection
PopupActivationDirection | null

Where the current trigger sits relative to the previous one, after switching triggers while open

getContentValues
() => string[]

Returns the trigger values whose content to render: the current one, plus the previous one while it animates out after a switch. Oldest first.

highlightedValue
string | null

The id of the currently highlighted menuitem

setHighlightedValue
(value: string | null) => void

Function to set the highlighted menuitem

setParent
(parent: MenuService) => void

Function to register a parent menu. This is used for submenus

setChild
(child: MenuService) => void

Function to register a child menu. This is used for submenus

reposition
(options?: Partial<PositioningOptions>) => void

Function to reposition the popover

getOptionItemState
(props: OptionItemProps) => OptionItemState

Returns the state of the option item

getItemState
(props: ItemProps) => ItemState

Returns the state of the menu item

addItemListener
(props: ItemListenerProps) => VoidFunction | undefined

Setup the custom event listener for item selection event

getTriggerState
(props?: TriggerProps) => TriggerState

Returns the state of a specific trigger, including whether it's the currently active one

getPositionerState
() => PositionerState

Returns the state of the positioner

getContentState
(props?: ContentProps) => ContentState

Returns the state of the content

getViewportState
() => ViewportState

Returns the state of the viewport

Accessibility

Complies with the Menu WAI-ARIA design pattern.

Keyboard Support

KeyDescription
Space
Activates/Selects the highlighted item
Enter
Activates/Selects the highlighted item
ArrowDown
Highlights the next item in the menu
ArrowUp
Highlights the previous item in the menu
ArrowRightArrowLeft
When focus is on trigger, opens or closes the submenu depending on reading direction.
Esc
Closes the menu and moves focus to the trigger
Tab
Closes the menu and moves focus to the next element after the trigger (Shift+Tab: the one before it).