Menu
A menu is a small overlay that uses the popover component to display actionable menu items. The indexing order appears over all other elements on a page and can be triggered by a button or an icon button.
Import
import { Menu } from "@cfa/react-core";Live Editor
Examples
Icon Button Trigger
You may use any button or clickable element as a trigger, but the IconButton is the most common use case.
Avatar Trigger
You can use the Avatar component as a trigger for the menu. This is useful for user profile menus.
Pressable Trigger
Alternatively to an IconButton or Avatar, you can use the Pressable component to create a trigger that can be styled to your needs.
Should Focus Wrap
The focus of the menu items will wrap back to the beginning by default, or when shouldFocusWrap is true. Set shouldFocusWrap on the <Menu.Container /> to false to disable the circular keyboard navigation.
Menu Item Events
You can add events to Menu.Item components to handle user interactions like onAction, onHoverStart, onHoverEnd, and onHoverChange.
Menu Item Href
You can use the href prop on Menu.Item to create links.
Menu Item Disabled
You can disable a Menu.Item by setting the isDisabled prop to true.
Divider
You can use the Menu.Divider component to visually separate menu items.
Section Header
The Menu.Section component allows you to group menu items under a header. Use the Menu.Header component to define the section title.
Props
Visit the Documentation Site for the full list of props.
| Name | Type | Default | Description |
|---|---|---|---|
| defaultOpen | boolean | - | Whether the overlay is open by default (uncontrolled). |
| isOpen | boolean | - | Whether the overlay is open by default (controlled). |
| onOpenChange | (isOpen: boolean) => void | - | Handler that is called when the overlay's open state changes. |
| Name | Type | Default | Description |
|---|---|---|---|
| aria-describedby | string | - | Identifies the element (or elements) that describes the object. |
| aria-details | string | - | Identifies the element (or elements) that provide a detailed, extended description for the object. |
| aria-label | string | - | Defines a string value that labels the current element. |
| aria-labelledby | string | - | Identifies the element (or elements) that labels the current element. |
| autoFocus | boolean | FocusStrategy | - | Where the focus should be set. |
| children | ReactNode | ((item: T) => ReactNode) | - | The contents of the collection. |
| className | ClassNameOrFunction<MenuRenderProps> | 'react-aria-Menu' | The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. A function may be provided to compute the class based on component state. |
| dir | string | - | - |
| escapeKeyBehavior | "clearSelection" | "none" | 'clearSelection' | Whether pressing the escape key should clear selection in the menu or not. Most experiences should not modify this option as it eliminates a keyboard user's ability to easily clear selection. Only use if the escape key is being handled externally or should not trigger selection clearing contextually. |
| hidden | boolean | - | - |
| id | string | - | The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id). |
| inert | boolean | - | - |
| items | Iterable<T> | - | Item objects in the collection. |
| lang | string | - | - |
| onAction | (key: Key) => void | - | Handler that is called when an item is selected. |
| onAnimationEnd | AnimationEventHandler<HTMLDivElement> | - | - |
| onAnimationEndCapture | AnimationEventHandler<HTMLDivElement> | - | - |
| onAnimationIteration | AnimationEventHandler<HTMLDivElement> | - | - |
| onAnimationIterationCapture | AnimationEventHandler<HTMLDivElement> | - | - |
| onAnimationStart | AnimationEventHandler<HTMLDivElement> | - | - |
| onAnimationStartCapture | AnimationEventHandler<HTMLDivElement> | - | - |
| onAuxClick | MouseEventHandler<HTMLDivElement> | - | - |
| onAuxClickCapture | MouseEventHandler<HTMLDivElement> | - | - |
| onClick | MouseEventHandler<HTMLDivElement> | - | - |
| onClickCapture | MouseEventHandler<HTMLDivElement> | - | - |
| onClose | () => void | - | Handler that is called when the menu should close after selecting an item. |
| onContextMenu | MouseEventHandler<HTMLDivElement> | - | - |
| onContextMenuCapture | MouseEventHandler<HTMLDivElement> | - | - |
| onDoubleClick | MouseEventHandler<HTMLDivElement> | - | - |
| onDoubleClickCapture | MouseEventHandler<HTMLDivElement> | - | - |
| onGotPointerCapture | PointerEventHandler<HTMLDivElement> | - | - |
| onGotPointerCaptureCapture | PointerEventHandler<HTMLDivElement> | - | - |
| onLostPointerCapture | PointerEventHandler<HTMLDivElement> | - | - |
| onLostPointerCaptureCapture | PointerEventHandler<HTMLDivElement> | - | - |
| onMouseDown | MouseEventHandler<HTMLDivElement> | - | - |
| onMouseDownCapture | MouseEventHandler<HTMLDivElement> | - | - |
| onMouseEnter | MouseEventHandler<HTMLDivElement> | - | - |
| onMouseLeave | MouseEventHandler<HTMLDivElement> | - | - |
| onMouseMove | MouseEventHandler<HTMLDivElement> | - | - |
| onMouseMoveCapture | MouseEventHandler<HTMLDivElement> | - | - |
| onMouseOut | MouseEventHandler<HTMLDivElement> | - | - |
| onMouseOutCapture | MouseEventHandler<HTMLDivElement> | - | - |
| onMouseOver | MouseEventHandler<HTMLDivElement> | - | - |
| onMouseOverCapture | MouseEventHandler<HTMLDivElement> | - | - |
| onMouseUp | MouseEventHandler<HTMLDivElement> | - | - |
| onMouseUpCapture | MouseEventHandler<HTMLDivElement> | - | - |
| onPointerCancel | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerCancelCapture | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerDown | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerDownCapture | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerEnter | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerLeave | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerMove | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerMoveCapture | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerOut | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerOutCapture | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerOver | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerOverCapture | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerUp | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerUpCapture | PointerEventHandler<HTMLDivElement> | - | - |
| onScroll | UIEventHandler<HTMLDivElement> | - | - |
| onScrollCapture | UIEventHandler<HTMLDivElement> | - | - |
| onTouchCancel | TouchEventHandler<HTMLDivElement> | - | - |
| onTouchCancelCapture | TouchEventHandler<HTMLDivElement> | - | - |
| onTouchEnd | TouchEventHandler<HTMLDivElement> | - | - |
| onTouchEndCapture | TouchEventHandler<HTMLDivElement> | - | - |
| onTouchMove | TouchEventHandler<HTMLDivElement> | - | - |
| onTouchMoveCapture | TouchEventHandler<HTMLDivElement> | - | - |
| onTouchStart | TouchEventHandler<HTMLDivElement> | - | - |
| onTouchStartCapture | TouchEventHandler<HTMLDivElement> | - | - |
| onTransitionCancel | TransitionEventHandler<HTMLDivElement> | - | - |
| onTransitionCancelCapture | TransitionEventHandler<HTMLDivElement> | - | - |
| onTransitionEnd | TransitionEventHandler<HTMLDivElement> | - | - |
| onTransitionEndCapture | TransitionEventHandler<HTMLDivElement> | - | - |
| onTransitionRun | TransitionEventHandler<HTMLDivElement> | - | - |
| onTransitionRunCapture | TransitionEventHandler<HTMLDivElement> | - | - |
| onTransitionStart | TransitionEventHandler<HTMLDivElement> | - | - |
| onTransitionStartCapture | TransitionEventHandler<HTMLDivElement> | - | - |
| onWheel | WheelEventHandler<HTMLDivElement> | - | - |
| onWheelCapture | WheelEventHandler<HTMLDivElement> | - | - |
| render | DOMRenderFunction<"div", MenuRenderProps> | - | Overrides the default DOM element with a custom render function. This allows rendering existing components with built-in styles and behaviors such as router links, animation libraries, and pre-styled components. Requirements: * You must render the expected element type (e.g. if `<button>` is expected, you cannot render an `<a>`). * Only a single root DOM element can be rendered (no fragments). * You must pass through props and ref to the underlying DOM element, merging with your own prop as appropriate. |
| renderEmptyState | () => ReactNode | - | Provides content to display when there are no items in the list. |
| shouldCloseOnSelect | boolean | - | Whether the menu should close when the menu item is selected. |
| shouldFocusWrap | boolean | - | Whether keyboard navigation is circular. |
| slot | string | - | A slot name for the component. Slots allow the component to receive props from a parent component. An explicit `null` value indicates that the local props completely override all props received from a parent. |
| style | StyleOrFunction<MenuRenderProps> | - | The inline [style](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style) for the element. A function may be provided to compute the style based on component state. |
| translate | "yes" | "no" | - | - |
| Name | Type | Default | Description |
|---|---|---|---|
| aria-describedby | string | - | Identifies the element (or elements) that describes the object. |
| aria-details | string | - | Identifies the element (or elements) that provide a detailed, extended description for the object. |
| aria-label | string | - | Defines a string value that labels the current element. |
| aria-labelledby | string | - | Identifies the element (or elements) that labels the current element. |
| className | string | 'react-aria-Separator' | The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. |
| dir | string | - | - |
| elementType | string | - | The HTML element type that will be used to render the separator. |
| hidden | boolean | - | - |
| id | string | - | The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id). |
| inert | boolean | - | - |
| lang | string | - | - |
| onAnimationEnd | AnimationEventHandler<HTMLElement> | - | - |
| onAnimationEndCapture | AnimationEventHandler<HTMLElement> | - | - |
| onAnimationIteration | AnimationEventHandler<HTMLElement> | - | - |
| onAnimationIterationCapture | AnimationEventHandler<HTMLElement> | - | - |
| onAnimationStart | AnimationEventHandler<HTMLElement> | - | - |
| onAnimationStartCapture | AnimationEventHandler<HTMLElement> | - | - |
| onAuxClick | MouseEventHandler<HTMLElement> | - | - |
| onAuxClickCapture | MouseEventHandler<HTMLElement> | - | - |
| onClick | MouseEventHandler<HTMLElement> | - | - |
| onClickCapture | MouseEventHandler<HTMLElement> | - | - |
| onContextMenu | MouseEventHandler<HTMLElement> | - | - |
| onContextMenuCapture | MouseEventHandler<HTMLElement> | - | - |
| onDoubleClick | MouseEventHandler<HTMLElement> | - | - |
| onDoubleClickCapture | MouseEventHandler<HTMLElement> | - | - |
| onGotPointerCapture | PointerEventHandler<HTMLElement> | - | - |
| onGotPointerCaptureCapture | PointerEventHandler<HTMLElement> | - | - |
| onLostPointerCapture | PointerEventHandler<HTMLElement> | - | - |
| onLostPointerCaptureCapture | PointerEventHandler<HTMLElement> | - | - |
| onMouseDown | MouseEventHandler<HTMLElement> | - | - |
| onMouseDownCapture | MouseEventHandler<HTMLElement> | - | - |
| onMouseEnter | MouseEventHandler<HTMLElement> | - | - |
| onMouseLeave | MouseEventHandler<HTMLElement> | - | - |
| onMouseMove | MouseEventHandler<HTMLElement> | - | - |
| onMouseMoveCapture | MouseEventHandler<HTMLElement> | - | - |
| onMouseOut | MouseEventHandler<HTMLElement> | - | - |
| onMouseOutCapture | MouseEventHandler<HTMLElement> | - | - |
| onMouseOver | MouseEventHandler<HTMLElement> | - | - |
| onMouseOverCapture | MouseEventHandler<HTMLElement> | - | - |
| onMouseUp | MouseEventHandler<HTMLElement> | - | - |
| onMouseUpCapture | MouseEventHandler<HTMLElement> | - | - |
| onPointerCancel | PointerEventHandler<HTMLElement> | - | - |
| onPointerCancelCapture | PointerEventHandler<HTMLElement> | - | - |
| onPointerDown | PointerEventHandler<HTMLElement> | - | - |
| onPointerDownCapture | PointerEventHandler<HTMLElement> | - | - |
| onPointerEnter | PointerEventHandler<HTMLElement> | - | - |
| onPointerLeave | PointerEventHandler<HTMLElement> | - | - |
| onPointerMove | PointerEventHandler<HTMLElement> | - | - |
| onPointerMoveCapture | PointerEventHandler<HTMLElement> | - | - |
| onPointerOut | PointerEventHandler<HTMLElement> | - | - |
| onPointerOutCapture | PointerEventHandler<HTMLElement> | - | - |
| onPointerOver | PointerEventHandler<HTMLElement> | - | - |
| onPointerOverCapture | PointerEventHandler<HTMLElement> | - | - |
| onPointerUp | PointerEventHandler<HTMLElement> | - | - |
| onPointerUpCapture | PointerEventHandler<HTMLElement> | - | - |
| onScroll | UIEventHandler<HTMLElement> | - | - |
| onScrollCapture | UIEventHandler<HTMLElement> | - | - |
| onTouchCancel | TouchEventHandler<HTMLElement> | - | - |
| onTouchCancelCapture | TouchEventHandler<HTMLElement> | - | - |
| onTouchEnd | TouchEventHandler<HTMLElement> | - | - |
| onTouchEndCapture | TouchEventHandler<HTMLElement> | - | - |
| onTouchMove | TouchEventHandler<HTMLElement> | - | - |
| onTouchMoveCapture | TouchEventHandler<HTMLElement> | - | - |
| onTouchStart | TouchEventHandler<HTMLElement> | - | - |
| onTouchStartCapture | TouchEventHandler<HTMLElement> | - | - |
| onTransitionCancel | TransitionEventHandler<HTMLElement> | - | - |
| onTransitionCancelCapture | TransitionEventHandler<HTMLElement> | - | - |
| onTransitionEnd | TransitionEventHandler<HTMLElement> | - | - |
| onTransitionEndCapture | TransitionEventHandler<HTMLElement> | - | - |
| onTransitionRun | TransitionEventHandler<HTMLElement> | - | - |
| onTransitionRunCapture | TransitionEventHandler<HTMLElement> | - | - |
| onTransitionStart | TransitionEventHandler<HTMLElement> | - | - |
| onTransitionStartCapture | TransitionEventHandler<HTMLElement> | - | - |
| onWheel | WheelEventHandler<HTMLElement> | - | - |
| onWheelCapture | WheelEventHandler<HTMLElement> | - | - |
| orientation | Orientation | 'horizontal' | The orientation of the separator. |
| render | DOMRenderFunction<"div" | "hr", undefined> | - | Overrides the default DOM element with a custom render function. This allows rendering existing components with built-in styles and behaviors such as router links, animation libraries, and pre-styled components. Requirements: * You must render the expected element type (e.g. if `<button>` is expected, you cannot render an `<a>`). * Only a single root DOM element can be rendered (no fragments). * You must pass through props and ref to the underlying DOM element, merging with your own prop as appropriate. |
| slot | string | - | A slot name for the component. Slots allow the component to receive props from a parent component. An explicit `null` value indicates that the local props completely override all props received from a parent. |
| style | CSSProperties | - | The inline [style](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style) for the element. |
| translate | "yes" | "no" | - | - |
| Name | Type | Default | Description |
|---|---|---|---|
| className | string | - | - |
| style | CSSProperties | - | - |
| Name | Type | Default | Description |
|---|---|---|---|
| aria-label | string | - | An accessibility label for this item. |
| children | ChildrenOrFunction<MenuItemRenderProps> & ReactNode | - | The children of the component. A function may be provided to alter the children based on component state. |
| className | ClassNameOrFunction<MenuItemRenderProps> | 'react-aria-MenuItem' | The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. A function may be provided to compute the class based on component state. |
| dir | string | - | - |
| download | string | boolean | - | Causes the browser to download the linked URL. A string may be provided to suggest a file name. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#download). |
| hidden | boolean | - | - |
| href | string | - | A URL to link to. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#href). |
| hrefLang | string | - | Hints at the human language of the linked URL. See[MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#hreflang). |
| id | Key | - | The unique id of the item. |
| inert | boolean | - | - |
| isDisabled | boolean | - | Whether the item is disabled. |
| lang | string | - | - |
| onAction | () => void | - | Handler that is called when the item is selected. |
| onAnimationEnd | AnimationEventHandler<HTMLDivElement> | - | - |
| onAnimationEndCapture | AnimationEventHandler<HTMLDivElement> | - | - |
| onAnimationIteration | AnimationEventHandler<HTMLDivElement> | - | - |
| onAnimationIterationCapture | AnimationEventHandler<HTMLDivElement> | - | - |
| onAnimationStart | AnimationEventHandler<HTMLDivElement> | - | - |
| onAnimationStartCapture | AnimationEventHandler<HTMLDivElement> | - | - |
| onAuxClick | MouseEventHandler<HTMLDivElement> | - | - |
| onAuxClickCapture | MouseEventHandler<HTMLDivElement> | - | - |
| onBlur | (e: FocusEvent<Element, Element>) => void | - | Handler that is called when the element loses focus. |
| onClick | (e: MouseEvent<FocusableElement, MouseEvent>) => void | - | **Not recommended – use `onPress` instead.** `onClick` is an alias for `onPress` provided for compatibility with other libraries. `onPress` provides additional event details for non-mouse interactions. |
| onClickCapture | MouseEventHandler<HTMLDivElement> | - | - |
| onContextMenu | MouseEventHandler<HTMLDivElement> | - | - |
| onContextMenuCapture | MouseEventHandler<HTMLDivElement> | - | - |
| onDoubleClick | MouseEventHandler<HTMLDivElement> | - | - |
| onDoubleClickCapture | MouseEventHandler<HTMLDivElement> | - | - |
| onFocus | (e: FocusEvent<Element, Element>) => void | - | Handler that is called when the element receives focus. |
| onFocusChange | (isFocused: boolean) => void | - | Handler that is called when the element's focus status changes. |
| onGotPointerCapture | PointerEventHandler<HTMLDivElement> | - | - |
| onGotPointerCaptureCapture | PointerEventHandler<HTMLDivElement> | - | - |
| onHoverChange | (isHovering: boolean) => void | - | Handler that is called when the hover state changes. |
| onHoverEnd | (e: HoverEvent) => void | - | Handler that is called when a hover interaction ends. |
| onHoverStart | (e: HoverEvent) => void | - | Handler that is called when a hover interaction starts. |
| onLostPointerCapture | PointerEventHandler<HTMLDivElement> | - | - |
| onLostPointerCaptureCapture | PointerEventHandler<HTMLDivElement> | - | - |
| onMouseDown | MouseEventHandler<HTMLDivElement> | - | - |
| onMouseDownCapture | MouseEventHandler<HTMLDivElement> | - | - |
| onMouseEnter | MouseEventHandler<HTMLDivElement> | - | - |
| onMouseLeave | MouseEventHandler<HTMLDivElement> | - | - |
| onMouseMove | MouseEventHandler<HTMLDivElement> | - | - |
| onMouseMoveCapture | MouseEventHandler<HTMLDivElement> | - | - |
| onMouseOut | MouseEventHandler<HTMLDivElement> | - | - |
| onMouseOutCapture | MouseEventHandler<HTMLDivElement> | - | - |
| onMouseOver | MouseEventHandler<HTMLDivElement> | - | - |
| onMouseOverCapture | MouseEventHandler<HTMLDivElement> | - | - |
| onMouseUp | MouseEventHandler<HTMLDivElement> | - | - |
| onMouseUpCapture | MouseEventHandler<HTMLDivElement> | - | - |
| onPointerCancel | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerCancelCapture | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerDown | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerDownCapture | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerEnter | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerLeave | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerMove | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerMoveCapture | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerOut | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerOutCapture | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerOver | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerOverCapture | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerUp | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerUpCapture | PointerEventHandler<HTMLDivElement> | - | - |
| onPress | (e: PressEvent) => void | - | Handler that is called when the press is released over the target. |
| onPressChange | (isPressed: boolean) => void | - | Handler that is called when the press state changes. |
| onPressEnd | (e: PressEvent) => void | - | Handler that is called when a press interaction ends, either over the target or when the pointer leaves the target. |
| onPressStart | (e: PressEvent) => void | - | Handler that is called when a press interaction starts. |
| onPressUp | (e: PressEvent) => void | - | Handler that is called when a press is released over the target, regardless of whether it started on the target or not. |
| onScroll | UIEventHandler<HTMLDivElement> | - | - |
| onScrollCapture | UIEventHandler<HTMLDivElement> | - | - |
| onTouchCancel | TouchEventHandler<HTMLDivElement> | - | - |
| onTouchCancelCapture | TouchEventHandler<HTMLDivElement> | - | - |
| onTouchEnd | TouchEventHandler<HTMLDivElement> | - | - |
| onTouchEndCapture | TouchEventHandler<HTMLDivElement> | - | - |
| onTouchMove | TouchEventHandler<HTMLDivElement> | - | - |
| onTouchMoveCapture | TouchEventHandler<HTMLDivElement> | - | - |
| onTouchStart | TouchEventHandler<HTMLDivElement> | - | - |
| onTouchStartCapture | TouchEventHandler<HTMLDivElement> | - | - |
| onTransitionCancel | TransitionEventHandler<HTMLDivElement> | - | - |
| onTransitionCancelCapture | TransitionEventHandler<HTMLDivElement> | - | - |
| onTransitionEnd | TransitionEventHandler<HTMLDivElement> | - | - |
| onTransitionEndCapture | TransitionEventHandler<HTMLDivElement> | - | - |
| onTransitionRun | TransitionEventHandler<HTMLDivElement> | - | - |
| onTransitionRunCapture | TransitionEventHandler<HTMLDivElement> | - | - |
| onTransitionStart | TransitionEventHandler<HTMLDivElement> | - | - |
| onTransitionStartCapture | TransitionEventHandler<HTMLDivElement> | - | - |
| onWheel | WheelEventHandler<HTMLDivElement> | - | - |
| onWheelCapture | WheelEventHandler<HTMLDivElement> | - | - |
| ping | string | - | A space-separated list of URLs to ping when the link is followed. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#ping). |
| referrerPolicy | HTMLAttributeReferrerPolicy | - | How much of the referrer to send when following the link. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#referrerpolicy). |
| rel | string | - | The relationship between the linked resource and the current page. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel). |
| render | (props: any, renderProps: MenuItemRenderProps) => ReactElement<unknown, string | JSXElementConstructor<any>> | - | Overrides the default DOM element with a custom render function. This allows rendering existing components with built-in styles and behaviors such as router links, animation libraries, and pre-styled components. Note: You can check if `'href' in props` in order to tell whether to render an `<a>` element. Requirements: * You must render the expected element type (e.g. if `<a>` is expected, you cannot render a `<button>`). * Only a single root DOM element can be rendered (no fragments). * You must pass through props and ref to the underlying DOM element, merging with your own prop as appropriate. |
| routerOptions | never | - | Options for the configured client side router. |
| shouldCloseOnSelect | boolean | - | Whether the menu should close when the menu item is selected. |
| style | StyleOrFunction<MenuItemRenderProps> | - | The inline [style](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style) for the element. A function may be provided to compute the style based on component state. |
| target | HTMLAttributeAnchorTarget | - | The target window for the link. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#target). |
| textValue | string | - | A string representation of the item's contents, used for features like typeahead. |
| translate | "yes" | "no" | - | - |
| value | object | - | The object value that this item represents. When using dynamic collections, this is set automatically. |
| Name | Type | Default | Description |
|---|---|---|---|
| aria-describedby | string | - | Identifies the element (or elements) that describes the object. |
| aria-details | string | - | Identifies the element (or elements) that provide a detailed, extended description for the object. |
| aria-label | string | - | Defines a string value that labels the current element. |
| aria-labelledby | string | - | Identifies the element (or elements) that labels the current element. |
| children | ChildrenOrFunction<PopoverRenderProps> | - | The children of the component. A function may be provided to alter the children based on component state. |
| className | ClassNameOrFunction<PopoverRenderProps> | 'react-aria-Popover' | The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. A function may be provided to compute the class based on component state. |
| crossOffset | number | 0 | The additional offset applied along the cross axis between the element and its anchor element. |
| defaultOpen | boolean | - | Whether the overlay is open by default (uncontrolled). |
| dir | string | - | - |
| hidden | boolean | - | - |
| inert | boolean | - | - |
| isEntering | boolean | - | Whether the popover is currently performing an entry animation. |
| isExiting | boolean | - | Whether the popover is currently performing an exit animation. |
| isKeyboardDismissDisabled | boolean | false | Whether pressing the escape key to close the popover should be disabled. Most popovers should not use this option. When set to true, an alternative way to close the popover with a keyboard must be provided. |
| isOpen | boolean | - | Whether the overlay is open by default (controlled). |
| lang | string | - | - |
| maxHeight | number | - | The maxHeight specified for the overlay element. By default, it will take all space up to the current viewport height. |
| offset | number | 8 | The additional offset applied along the main axis between the element and its anchor element. |
| onAnimationEnd | AnimationEventHandler<HTMLDivElement> | - | - |
| onAnimationEndCapture | AnimationEventHandler<HTMLDivElement> | - | - |
| onAnimationIteration | AnimationEventHandler<HTMLDivElement> | - | - |
| onAnimationIterationCapture | AnimationEventHandler<HTMLDivElement> | - | - |
| onAnimationStart | AnimationEventHandler<HTMLDivElement> | - | - |
| onAnimationStartCapture | AnimationEventHandler<HTMLDivElement> | - | - |
| onAuxClick | MouseEventHandler<HTMLDivElement> | - | - |
| onAuxClickCapture | MouseEventHandler<HTMLDivElement> | - | - |
| onClick | MouseEventHandler<HTMLDivElement> | - | - |
| onClickCapture | MouseEventHandler<HTMLDivElement> | - | - |
| onContextMenu | MouseEventHandler<HTMLDivElement> | - | - |
| onContextMenuCapture | MouseEventHandler<HTMLDivElement> | - | - |
| onDoubleClick | MouseEventHandler<HTMLDivElement> | - | - |
| onDoubleClickCapture | MouseEventHandler<HTMLDivElement> | - | - |
| onGotPointerCapture | PointerEventHandler<HTMLDivElement> | - | - |
| onGotPointerCaptureCapture | PointerEventHandler<HTMLDivElement> | - | - |
| onLostPointerCapture | PointerEventHandler<HTMLDivElement> | - | - |
| onLostPointerCaptureCapture | PointerEventHandler<HTMLDivElement> | - | - |
| onMouseDown | MouseEventHandler<HTMLDivElement> | - | - |
| onMouseDownCapture | MouseEventHandler<HTMLDivElement> | - | - |
| onMouseEnter | MouseEventHandler<HTMLDivElement> | - | - |
| onMouseLeave | MouseEventHandler<HTMLDivElement> | - | - |
| onMouseMove | MouseEventHandler<HTMLDivElement> | - | - |
| onMouseMoveCapture | MouseEventHandler<HTMLDivElement> | - | - |
| onMouseOut | MouseEventHandler<HTMLDivElement> | - | - |
| onMouseOutCapture | MouseEventHandler<HTMLDivElement> | - | - |
| onMouseOver | MouseEventHandler<HTMLDivElement> | - | - |
| onMouseOverCapture | MouseEventHandler<HTMLDivElement> | - | - |
| onMouseUp | MouseEventHandler<HTMLDivElement> | - | - |
| onMouseUpCapture | MouseEventHandler<HTMLDivElement> | - | - |
| onOpenChange | (isOpen: boolean) => void | - | Handler that is called when the overlay's open state changes. |
| onPointerCancel | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerCancelCapture | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerDown | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerDownCapture | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerEnter | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerLeave | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerMove | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerMoveCapture | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerOut | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerOutCapture | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerOver | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerOverCapture | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerUp | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerUpCapture | PointerEventHandler<HTMLDivElement> | - | - |
| onScroll | UIEventHandler<HTMLDivElement> | - | - |
| onScrollCapture | UIEventHandler<HTMLDivElement> | - | - |
| onTouchCancel | TouchEventHandler<HTMLDivElement> | - | - |
| onTouchCancelCapture | TouchEventHandler<HTMLDivElement> | - | - |
| onTouchEnd | TouchEventHandler<HTMLDivElement> | - | - |
| onTouchEndCapture | TouchEventHandler<HTMLDivElement> | - | - |
| onTouchMove | TouchEventHandler<HTMLDivElement> | - | - |
| onTouchMoveCapture | TouchEventHandler<HTMLDivElement> | - | - |
| onTouchStart | TouchEventHandler<HTMLDivElement> | - | - |
| onTouchStartCapture | TouchEventHandler<HTMLDivElement> | - | - |
| onTransitionCancel | TransitionEventHandler<HTMLDivElement> | - | - |
| onTransitionCancelCapture | TransitionEventHandler<HTMLDivElement> | - | - |
| onTransitionEnd | TransitionEventHandler<HTMLDivElement> | - | - |
| onTransitionEndCapture | TransitionEventHandler<HTMLDivElement> | - | - |
| onTransitionRun | TransitionEventHandler<HTMLDivElement> | - | - |
| onTransitionRunCapture | TransitionEventHandler<HTMLDivElement> | - | - |
| onTransitionStart | TransitionEventHandler<HTMLDivElement> | - | - |
| onTransitionStartCapture | TransitionEventHandler<HTMLDivElement> | - | - |
| onWheel | WheelEventHandler<HTMLDivElement> | - | - |
| onWheelCapture | WheelEventHandler<HTMLDivElement> | - | - |
| placement | Placement | 'bottom' | The placement of the element with respect to its anchor element. |
| render | DOMRenderFunction<"div", PopoverRenderProps> | - | Overrides the default DOM element with a custom render function. This allows rendering existing components with built-in styles and behaviors such as router links, animation libraries, and pre-styled components. Requirements: * You must render the expected element type (e.g. if `<button>` is expected, you cannot render an `<a>`). * Only a single root DOM element can be rendered (no fragments). * You must pass through props and ref to the underlying DOM element, merging with your own prop as appropriate. |
| shouldFlip | boolean | true | Whether the element should flip its orientation (e.g. top to bottom or left to right) when there is insufficient room for it to render completely. |
| slot | string | - | A slot name for the component. Slots allow the component to receive props from a parent component. An explicit `null` value indicates that the local props completely override all props received from a parent. |
| style | StyleOrFunction<PopoverRenderProps> | - | The inline [style](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style) for the element. A function may be provided to compute the style based on component state. |
| translate | "yes" | "no" | - | - |
| Name | Type | Default | Description |
|---|---|---|---|
| aria-label | string | - | An accessibility label for the section. |
| children | ReactNode | ((item: T) => ReactElement<unknown, string | JSXElementConstructor<any>>) | - | Static child items or a function to render children. |
| className | string | 'react-aria-MenuSection' | The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. |
| dir | string | - | - |
| hidden | boolean | - | - |
| id | Key | - | The unique id of the section. |
| inert | boolean | - | - |
| items | Iterable<T> | - | Item objects in the section. |
| lang | string | - | - |
| onAnimationEnd | AnimationEventHandler<HTMLElement> | - | - |
| onAnimationEndCapture | AnimationEventHandler<HTMLElement> | - | - |
| onAnimationIteration | AnimationEventHandler<HTMLElement> | - | - |
| onAnimationIterationCapture | AnimationEventHandler<HTMLElement> | - | - |
| onAnimationStart | AnimationEventHandler<HTMLElement> | - | - |
| onAnimationStartCapture | AnimationEventHandler<HTMLElement> | - | - |
| onAuxClick | MouseEventHandler<HTMLElement> | - | - |
| onAuxClickCapture | MouseEventHandler<HTMLElement> | - | - |
| onClick | MouseEventHandler<HTMLElement> | - | - |
| onClickCapture | MouseEventHandler<HTMLElement> | - | - |
| onContextMenu | MouseEventHandler<HTMLElement> | - | - |
| onContextMenuCapture | MouseEventHandler<HTMLElement> | - | - |
| onDoubleClick | MouseEventHandler<HTMLElement> | - | - |
| onDoubleClickCapture | MouseEventHandler<HTMLElement> | - | - |
| onGotPointerCapture | PointerEventHandler<HTMLElement> | - | - |
| onGotPointerCaptureCapture | PointerEventHandler<HTMLElement> | - | - |
| onLostPointerCapture | PointerEventHandler<HTMLElement> | - | - |
| onLostPointerCaptureCapture | PointerEventHandler<HTMLElement> | - | - |
| onMouseDown | MouseEventHandler<HTMLElement> | - | - |
| onMouseDownCapture | MouseEventHandler<HTMLElement> | - | - |
| onMouseEnter | MouseEventHandler<HTMLElement> | - | - |
| onMouseLeave | MouseEventHandler<HTMLElement> | - | - |
| onMouseMove | MouseEventHandler<HTMLElement> | - | - |
| onMouseMoveCapture | MouseEventHandler<HTMLElement> | - | - |
| onMouseOut | MouseEventHandler<HTMLElement> | - | - |
| onMouseOutCapture | MouseEventHandler<HTMLElement> | - | - |
| onMouseOver | MouseEventHandler<HTMLElement> | - | - |
| onMouseOverCapture | MouseEventHandler<HTMLElement> | - | - |
| onMouseUp | MouseEventHandler<HTMLElement> | - | - |
| onMouseUpCapture | MouseEventHandler<HTMLElement> | - | - |
| onPointerCancel | PointerEventHandler<HTMLElement> | - | - |
| onPointerCancelCapture | PointerEventHandler<HTMLElement> | - | - |
| onPointerDown | PointerEventHandler<HTMLElement> | - | - |
| onPointerDownCapture | PointerEventHandler<HTMLElement> | - | - |
| onPointerEnter | PointerEventHandler<HTMLElement> | - | - |
| onPointerLeave | PointerEventHandler<HTMLElement> | - | - |
| onPointerMove | PointerEventHandler<HTMLElement> | - | - |
| onPointerMoveCapture | PointerEventHandler<HTMLElement> | - | - |
| onPointerOut | PointerEventHandler<HTMLElement> | - | - |
| onPointerOutCapture | PointerEventHandler<HTMLElement> | - | - |
| onPointerOver | PointerEventHandler<HTMLElement> | - | - |
| onPointerOverCapture | PointerEventHandler<HTMLElement> | - | - |
| onPointerUp | PointerEventHandler<HTMLElement> | - | - |
| onPointerUpCapture | PointerEventHandler<HTMLElement> | - | - |
| onScroll | UIEventHandler<HTMLElement> | - | - |
| onScrollCapture | UIEventHandler<HTMLElement> | - | - |
| onTouchCancel | TouchEventHandler<HTMLElement> | - | - |
| onTouchCancelCapture | TouchEventHandler<HTMLElement> | - | - |
| onTouchEnd | TouchEventHandler<HTMLElement> | - | - |
| onTouchEndCapture | TouchEventHandler<HTMLElement> | - | - |
| onTouchMove | TouchEventHandler<HTMLElement> | - | - |
| onTouchMoveCapture | TouchEventHandler<HTMLElement> | - | - |
| onTouchStart | TouchEventHandler<HTMLElement> | - | - |
| onTouchStartCapture | TouchEventHandler<HTMLElement> | - | - |
| onTransitionCancel | TransitionEventHandler<HTMLElement> | - | - |
| onTransitionCancelCapture | TransitionEventHandler<HTMLElement> | - | - |
| onTransitionEnd | TransitionEventHandler<HTMLElement> | - | - |
| onTransitionEndCapture | TransitionEventHandler<HTMLElement> | - | - |
| onTransitionRun | TransitionEventHandler<HTMLElement> | - | - |
| onTransitionRunCapture | TransitionEventHandler<HTMLElement> | - | - |
| onTransitionStart | TransitionEventHandler<HTMLElement> | - | - |
| onTransitionStartCapture | TransitionEventHandler<HTMLElement> | - | - |
| onWheel | WheelEventHandler<HTMLElement> | - | - |
| onWheelCapture | WheelEventHandler<HTMLElement> | - | - |
| render | DOMRenderFunction<"section", undefined> | - | Overrides the default DOM element with a custom render function. This allows rendering existing components with built-in styles and behaviors such as router links, animation libraries, and pre-styled components. Requirements: * You must render the expected element type (e.g. if `<button>` is expected, you cannot render an `<a>`). * Only a single root DOM element can be rendered (no fragments). * You must pass through props and ref to the underlying DOM element, merging with your own prop as appropriate. |
| shouldCloseOnSelect | boolean | - | Whether the menu should close when the menu item is selected. |
| style | CSSProperties | - | The inline [style](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style) for the element. |
| translate | "yes" | "no" | - | - |
| value | object | - | The object value that this section represents. When using dynamic collections, this is set automatically. |
| Name | Type | Default | Description |
|---|---|---|---|
| children | ReactElement<unknown, string | JSXElementConstructor<any>>[] | - | The contents of the SubmenuTrigger. The first child should be an Item (the trigger) and the second child should be the Popover (for the submenu). |