menuKeys
Why JS.
import { menuKeys } from "@sdxc/ui/mixins";Usage
Adapts the WAI-ARIA menu keyboard pattern — roving tabindex, arrow-key
navigation, Home/End, and typeahead — onto a Menu surface's
[role^="menuitem"] descendants; only manages focus, leaving activation to native semantics.
Signature
menuKeys(options?: MenuKeys.Options): MixinDescriptor<HTMLElement>Returns a mixin descriptor for the Menu surface's mix prop.
Parameters
| Parameter | Type | Default | Required | Description |
|---|---|---|---|---|
options | MenuKeys.Options | — | No | Item-selector override for non-standard markup. |
Examples
<Menu.List mix={menuKeys()}>
<Menu.Item>Rename</Menu.Item>
<Menu.Item>Delete</Menu.Item>
</Menu.List>Used with it
The events, constants and types its module publishes, each imported from @sdxc/ui/mixins too.
Function
installMenuKeys
Runs the WAI-ARIA menu keyboard pattern on host until signal aborts: roving tabindex,
arrow keys, Home/End and typeahead across its items. Script that owns server-rendered
markup calls it directly; components reach it through menuKeys.
installMenuKeys(host: HTMLElement, signal: AbortSignal, options?: MenuKeys.Options): void| Parameter | Type | Default | Required | Description |
|---|---|---|---|---|
host | HTMLElement | — | Yes | The Menu surface, usually a role="menu" element. |
signal | AbortSignal | — | Yes | Ends the listeners when it aborts. |
options | MenuKeys.Options | — | No | Item-selector override for non-standard markup. |
installMenuKeys(panel, controller.signal, { itemSelector: "[data-item]" });Interface
MenuKeys.Options
Configuration accepted by menuKeys.
| Member | Type | Default | Required | Description |
|---|---|---|---|---|
itemSelector | string | — | No | Selector, evaluated against the Menu surface's descendants, that identifies its menu items. Defaults to [role^="menuitem"], matching the menuitem, menuitemcheckbox, and menuitemradio roles. |