Interface: UseMenuResult
Returned by useMenu(): the controller state as fields, plus actions and prop getters.
Extends
Properties
| Property | Modifier | Type | Description | Inherited from |
|---|---|---|---|---|
enabled | readonly | Readonly<Record<string, boolean>> | Whether each item (by id) can run now. The checked item is always enabled. | MenuState.enabled |
items | readonly | readonly MenuItem[] | The items passed in options. | - |
open | readonly | boolean | The menu is open. | MenuState.open |
selected | readonly | MenuItem | null | The checked item (e.g. the current block type), or null. | MenuState.selected |
Methods
close()
close(options?): void;Close and move focus to the trigger (default), the editor, or nowhere.
Parameters
| Parameter | Type |
|---|---|
options? | { focus?: "editor" | "trigger" | "none"; } |
options.focus? | "editor" | "trigger" | "none" |
Returns
void
getItemProps()
getItemProps(id): ReactProps;Props for an item: role menuitemradio with aria-checked for choices, menuitem for actions; aria-disabled when it cannot run. Click selects it. Throws for an unknown id.
Parameters
| Parameter | Type |
|---|---|
id | string |
Returns
getMenuProps()
getMenuProps(): ReactProps;Props for the menu: role="menu", aria-labelledby. Arrow keys, Home and End move focus, letters jump by label, Enter and Space choose, Escape closes to the trigger, Tab closes.
Returns
getTriggerProps()
getTriggerProps(): ReactProps;Props for the menu button: id, aria-label (menu label plus the checked item), aria-haspopup, aria-expanded, aria-controls. Click toggles; ArrowDown, Enter and Space open the menu, ArrowUp opens it on the last item.
Returns
openMenu()
openMenu(focus?): void;Open and focus an enabled item: the checked one (default; else the first), the first or the last.
Parameters
| Parameter | Type |
|---|---|
focus? | "selected" | "first" | "last" |
Returns
void