Components
MenuProvider

MenuProvider

Menu state provider

Optional props

setValues

A callback that gets called when the values state changes.

Live examples:

type
BivariantCallback<(values: T) => void>
default
null

combobox

A reference to a combobox store. It's automatically set when composing Menu with Combobox.

type
ComboboxStore<ComboboxStoreSelectedValue>
null
default
null

parent

A reference to a parent menu store. It's automatically set when nesting menus in the React tree. You should manually set this if menus aren't nested in the React tree.

Live examples:

type
MenuStore<MenuStoreValues>
null
default
null

menubar

A reference to a menubar store. It's automatically set when rendering menus inside a Menubar in the React tree.

Live examples:

type
MenubarStore
null
default
null

orientation

Defines the orientation of the composite widget. If the composite has a single row or column (one-dimensional), the orientation value determines which arrow keys can be used to move focus:

  • both: all arrow keys work.
  • horizontal: only left and right arrow keys work.
  • vertical: only up and down arrow keys work.

It doesn't have any effect on two-dimensional composites.

type
Orientation
default
"vertical"

placement

type
Placement
default
"bottom-start"

hideTimeout

The amount of time in milliseconds to wait before hiding the popup. It defaults to the value passed to timeout.

Live examples:

type
number
default
0

values

A map of names and values that will be used by the MenuItemCheckbox and MenuItemRadio components.

Live examples:

type
T
default
null

items

Lists all items along with their metadata. This state is automatically updated when an item is registered or unregistered using the registerItem function.

type
T[]
default
null

virtualFocus

If enabled, the composite element will act as an aria-activedescendant container instead of roving tabindex. DOM focus will remain on the composite element while its items receive virtual focus.

In both scenarios, the item in focus will carry the data-active-item attribute.

Live examples:

type
boolean
default
false

rtl

Determines how the next and previous functions will behave. If rtl is set to true, they will be inverted.

This only affects the composite widget behavior. You still need to set dir="rtl" on HTML/CSS.

type
boolean
default
false

focusLoop

Determines how the focus behaves when the user reaches the end of the composite widget.

On one-dimensional composite widgets:

  • true loops from the last item to the first item and vice-versa.
  • horizontal loops only if orientation is horizontal or not set.
  • vertical loops only if orientation is vertical or not set.
  • If includesBaseElement is set to true (or activeId is initially set to null), the composite element will be focused in between the last and first items.

On two-dimensional composite widgets (when using CompositeRow or explicitly passing a rowId prop to composite items):

  • true loops from the last row/column item to the first item in the same row/column and vice-versa. If it's the last item in the last row, it moves to the first item in the first row and vice-versa.
  • horizontal loops only from the last row item to the first item in the same row.
  • vertical loops only from the last column item to the first item in the column row.
  • If includesBaseElement is set to true (or activeId is initially set to null), vertical loop will have no effect as moving down from the last row or up from the first row will focus on the composite element.
  • If focusWrap matches the value of focusLoop, it'll wrap between the last item in the last row or column and the first item in the first row or column and vice-versa.

Live examples:

type
boolean
Orientation
default
false

focusWrap

Works only on two-dimensional composite widgets.

If enabled, moving to the next item from the last one in a row or column will focus on the first item in the next row or column and vice-versa.

  • true wraps between rows and columns.
  • horizontal wraps only between rows.
  • vertical wraps only between columns.
  • If focusLoop matches the value of focusWrap, it'll wrap between the last item in the last row or column and the first item in the first row or column and vice-versa.
type
boolean
Orientation
default
false

focusShift

Works only on two-dimensional composite widgets.

If enabled, moving up or down when there's no next item or when the next item is disabled will shift to the item right before it.

type
boolean
default
false

includesBaseElement

Indicates if the composite base element (the one with a composite role) should be part of the focus order when navigating with arrow keys. In other words, moving to the previous element when the first item is in focus will focus on the composite element itself. The same applies to the last item when moving to the next element.

Live examples:

type
boolean
default
false

activeId

The current active item id. The active item is the element within the composite widget that has either DOM or virtual focus (in case virtualFocus is enabled).

  • null represents the base composite element (the one with a composite role). Users will be able to navigate out of it using arrow keys.
  • If activeId is initially set to null, the includesBaseElement prop will also default to true, which means the base composite element itself will have focus and users will be able to navigate to it using arrow keys.

Live examples:

type
string
null
default
null

timeout

The amount of time in milliseconds to wait before showing and hiding the popup. To control the delay for showing and hiding separately, use showTimeout and hideTimeout.

type
number
default
500

showTimeout

The amount of time in milliseconds to wait before showing the popup. It defaults to the value passed to timeout.

Live examples:

type
number
default
null

open

type
boolean
default
false

animated

Determines whether the content should animate when it is shown or hidden.

  • If true, the animating state will be true when the content is shown or hidden and it will wait for a CSS animation/transition to end before becoming false.
  • If it's set to a number, the animating state will be true when the content is shown or hidden and it will wait for the number of milliseconds to pass before becoming false.
type
number
boolean
default
null

defaultValues

The default values for the values state.

Live examples:

type
T
default
{}

defaultActiveId

The composite item id that should be active by default when the composite widget is rendered. If null, the composite element itself will have focus and users will be able to navigate to it using arrow keys. If undefined, the first enabled item will be focused.

type
string
null
default
null

defaultItems

The defaut value for the items state.

type
T[]
default
[]

popover

A reference to another popover store that's controlling another popover to keep them in sync.

type
PopoverStore
null
default
null

defaultOpen

Whether the content should be visible by default.

type
boolean
default
false

setActiveId

A callback that gets called when the activeId state changes.

type
((activeId: string
null
undefined) => void)
default
null

setItems

A callback that gets called when the items state changes.

type
BivariantCallback<(items: T[]) => void>
default
null

setOpen

A callback that gets called when the open state changes.

type
((open: boolean) => void)
default
null

setMounted

A callback that gets called when the mounted state changes.

type
((mounted: boolean) => void)
default
null

disclosure

A reference to another disclosure store that controls another disclosure component to keep them in sync. Element states like contentElement and disclosureElement won't be synced. For that, use the store prop instead.

Live examples:

type
DisclosureStore
null
default
null

store

Another store object that will be kept in sync with the original store.

Live examples:

type
Store<Partial<S>>
default
null