Menu
A list of options that appears when a user interacts with a button.
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.
Links
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.
Menu in Dialog
Inside a dialog, set lazyMount and unmountOnExit so the menu cleans up when the dialog closes.
Menu Item Dialog
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>
Links
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
| Prop | Default | Type |
|---|---|---|
anchorPoint | PointThe positioning point for the menu. Can be set by the context menu trigger or the button trigger. | |
aria-label | stringThe accessibility label for the menu | |
autoHighlight | false | 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 |
closeOnSelect | true | booleanWhether 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 | stringThe 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 | booleanThe initial open state of the menu when rendered. Use when you don't need to control the open state of the menu. | |
defaultTriggerValue | stringThe initial trigger value when rendered. Use when you don't need to control the trigger value. | |
finalFocusEl | () => MaybeElementThe 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' | HideModeHow 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 | stringThe controlled highlighted value of the menu item. | |
id | stringThe unique identifier of the machine. | |
ids | ElementIdsThe ids of the elements in the menu. Useful for composition. | |
immediate | booleanWhether to synchronize the present change immediately or defer it to the next frame | |
initialFocusEl | () => false | MaybeElementThe element to focus when the menu opens. Return `false` to skip moving focus, or `null` to use the default. | |
lazyMount | false | booleanWhether to enable lazy mounting |
loopFocus | false | booleanWhether to loop the keyboard navigation. |
navigate | (details: NavigateDetails) => voidFunction to navigate to the selected item if it's an anchor element | |
onEnterComplete | VoidFunctionFunction called when the animation ends in the open state | |
onEscapeKeyDown | (event: KeyboardEvent) => voidFunction called when the escape key is pressed | |
onExitComplete | VoidFunctionFunction called when the animation ends in the closed state | |
onFocusOutside | (event: FocusOutsideEvent) => voidFunction called when the focus is moved outside the component | |
onHighlightChange | (details: HighlightChangeDetails) => voidFunction called when the highlighted menu item changes. | |
onInteractOutside | (event: InteractOutsideEvent) => voidFunction called when an interaction happens outside the component | |
onOpenChange | (details: OpenChangeDetails) => voidFunction called when the menu opens or closes | |
onPointerDownOutside | (event: PointerDownOutsideEvent) => voidFunction called when the pointer is pressed down outside the component | |
onRequestDismiss | (event: LayerDismissEvent) => voidFunction called when this layer is closed due to a parent layer being closed | |
onSelect | (details: SelectionDetails) => voidFunction called when a menu item is selected. | |
onTriggerValueChange | (details: TriggerValueChangeDetails) => voidFunction called when the trigger value changes. | |
open | booleanThe 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 | PositioningOptionsThe options used to dynamically position the menu | |
present | booleanWhether the node is present (controlled by the user) | |
scrollToIndexFn | (details: ScrollToIndexDetails) => voidScrolls the item at an index into view, for virtualized items. Used with `collection`. | |
skipAnimationOnMount | false | booleanWhether to allow the initial presence animation. |
triggerValue | stringThe controlled trigger value | |
typeahead | true | booleanWhether the pressing printable characters should trigger typeahead navigation |
unmountOnExit | false | booleanWhether to unmount on exit. |
Arrow
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse 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. |
| Attribute | Description |
|---|---|
[data-menu-arrow] | <uid> |
[data-state] | "open" | "closed" |
| CSS Variable | Description |
|---|---|
--arrow-size | The size of the arrow |
--arrow-size-half | Half the size of the arrow |
--arrow-background | Use this variable to style the arrow background |
--arrow-offset | The offset position of the arrow |
ArrowTip
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse 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.
| Attribute | Default | Type |
|---|---|---|
checked | booleanWhether the option is checked | |
value | stringThe value of the option | |
asChild | booleanUse 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 | booleanWhether the menu should be closed when the option is selected. | |
disabled | booleanWhether the menu item is disabled | |
onCheckedChange | (checked: boolean) => voidFunction 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 | stringThe 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.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse 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. |
| Attribute | Description |
|---|---|
[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 Variable | Description |
|---|---|
--layer-index | The index of the dismissable in the layer stack |
--nested-layer-count | The number of nested menus |
ContextTrigger
Defines the <button> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse 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 | stringThe value that identifies this specific trigger |
| Attribute | Description |
|---|---|
[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.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse 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. |
| Attribute | Description |
|---|---|
[data-menu-indicator] | <uid> |
[data-state] | "open" | "closed" |
Input
Defines the <input> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse 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. |
| Attribute | Description |
|---|---|
[data-menu-input] | <uid> |
[data-highlighted] | Present when highlighted |
ItemGroupLabel
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse 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.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse 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.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse 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. |
| Attribute | Description |
|---|---|
[data-menu-item-indicator] | <uid> |
[data-disabled] | Present when disabled |
[data-highlighted] | Present when highlighted |
[data-state] | "checked" |
Item
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
value | stringThe unique value of the menu item option. | |
asChild | booleanUse 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 | booleanWhether the menu should be closed when the option is selected. | |
disabled | booleanWhether the menu item is disabled | |
onSelect | VoidFunctionThe 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 | stringThe 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. |
| Attribute | Description |
|---|---|
[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.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse 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. |
| Attribute | Description |
|---|---|
[data-menu-item-text] | <uid> |
[data-disabled] | Present when disabled |
[data-highlighted] | Present when highlighted |
[data-state] | "checked" |
List
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse 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.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse 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. |
| Attribute | Description |
|---|---|
[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 Variable | Description |
|---|---|
--reference-width | The width of the reference element |
--reference-height | The height of the root |
--available-width | The available width in viewport |
--available-height | The available height in viewport |
--x | The x position for transform |
--y | The y position for transform |
--transform-origin | The transform origin for animations |
RadioItemGroup
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse 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.
| Attribute | Default | Type |
|---|---|---|
value | stringThe value of the option | |
asChild | booleanUse 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 | booleanWhether the menu should be closed when the option is selected. | |
disabled | booleanWhether 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 | stringThe 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
| Prop | Default | Type |
|---|---|---|
value | UseMenuReturn | |
hideMode | 'display-none' | HideModeHow 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 | booleanWhether to synchronize the present change immediately or defer it to the next frame | |
lazyMount | false | booleanWhether to enable lazy mounting |
onEnterComplete | VoidFunctionFunction called when the animation ends in the open state | |
onExitComplete | VoidFunctionFunction called when the animation ends in the closed state | |
present | booleanWhether the node is present (controlled by the user) | |
skipAnimationOnMount | false | booleanWhether to allow the initial presence animation. |
unmountOnExit | false | booleanWhether to unmount on exit. |
Separator
Defines the <hr> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse 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.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse 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.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse 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 | stringThe value that identifies this specific trigger |
| Attribute | Description |
|---|---|
[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
| Property | Type |
|---|---|
open | booleanWhether the menu is open |
setOpen | (open: boolean, reason?: OpenChangeReason) => voidFunction to open or close the menu |
triggerValue | string | nullThe trigger value |
setTriggerValue | (value: string | null) => voidFunction to set the trigger value |
activationDirection | PopupActivationDirection | nullWhere 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 | nullThe id of the currently highlighted menuitem |
setHighlightedValue | (value: string | null) => voidFunction to set the highlighted menuitem |
setParent | (parent: MenuService) => voidFunction to register a parent menu. This is used for submenus |
setChild | (child: MenuService) => voidFunction to register a child menu. This is used for submenus |
reposition | (options?: Partial<PositioningOptions>) => voidFunction to reposition the popover |
getOptionItemState | (props: OptionItemProps) => OptionItemStateReturns the state of the option item |
getItemState | (props: ItemProps) => ItemStateReturns the state of the menu item |
addItemListener | (props: ItemListenerProps) => VoidFunction | undefinedSetup the custom event listener for item selection event |
getTriggerState | (props?: TriggerProps) => TriggerStateReturns the state of a specific trigger, including whether it's the currently active one |
getPositionerState | () => PositionerStateReturns the state of the positioner |
getContentState | (props?: ContentProps) => ContentStateReturns the state of the content |
getViewportState | () => ViewportStateReturns the state of the viewport |
Accessibility
Complies with the Menu WAI-ARIA design pattern.
Keyboard Support
| Key | Description |
|---|---|
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). |