SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

menuKeys

Why JS.

tsx
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

typescript
menuKeys(options?: MenuKeys.Options): MixinDescriptor<HTMLElement>

Returns a mixin descriptor for the Menu surface's mix prop.

Parameters

ParameterTypeDefaultRequiredDescription
optionsMenuKeys.Options—NoItem-selector override for non-standard markup.

Examples

tsx
<Menu.List mix={menuKeys()}>
	<Menu.Item>Rename</Menu.Item>
	<Menu.Item>Delete</Menu.Item>
</Menu.List>

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.

typescript
installMenuKeys(host: HTMLElement, signal: AbortSignal, options?: MenuKeys.Options): void
ParameterTypeDefaultRequiredDescription
hostHTMLElement—YesThe Menu surface, usually a role="menu" element.
signalAbortSignal—YesEnds the listeners when it aborts.
optionsMenuKeys.Options—NoItem-selector override for non-standard markup.
tsx
installMenuKeys(panel, controller.signal, { itemSelector: "[data-item]" });
Interface

MenuKeys.Options

Configuration accepted by menuKeys.

MemberTypeDefaultRequiredDescription
itemSelectorstring—NoSelector, evaluated against the Menu surface's descendants, that identifies its menu items. Defaults to [role^="menuitem"], matching the menuitem, menuitemcheckbox, and menuitemradio roles.
@sdxc/ui

Can’t find it? Contact us