Modal command palette composed from dialog overlay, combobox filtering, and flat collection navigation; hosts own global shortcuts such as Command-K.
Install @wyrd-company/react or the Flutter package and use it directly —
your DESIGN.md does the styling.
catalog/contracts/command.ymlsource of truth · verbatim
$schema: https://thewyrdingway.dev/schemas/component-contract.schema.ymlcontractVersion: 0.1.0identity:name: Commandtag: wyrd-commandpackage: wyrd.component.commandtitle: Commandsummary: Modal command palette composed from dialog overlay, combobox filtering, and flat collection navigation; hosts own global shortcuts such as Command-K.relationships:related-to: - collection-navigation - quality-parity-and-gatesclassification:category: navigationcomposition: collectioninteractive: truetarget-strategy:react: requiredflutter: requiredsurface:properties: - name: labeltype:kind: stringrequired: trueserializable: truesummary: Accessible name for the command palette dialog. - name: itemstype:kind: arrayitem:kind: objectfields:label:kind: stringvalue:kind: stringgroup:kind: stringshortcut:kind: stringdisabled:kind: booleanrequired: falsedefault: []serializable: truesummary: Flat ordered command data; group creates single-level labelled sections and shortcut is render-only text. - name: is-opentype:kind: booleanrequired: falsecontrolled: truereflects: trueserializable: truesummary: Controlled modal visibility. - name: default-opentype:kind: booleanrequired: falsedefault: falseserializable: truesummary: Initial uncontrolled modal visibility. - name: active-indextype:kind: integerminimum: 0required: falsedefault: 0serializable: truesummary: Initial active index in the filtered enabled command collection.slots: []events: - name: open-changepayload:is-open:kind: booleanreason:kind: enumvalues: - trigger - escape - backdrop - select - programmaticbubbles: truecomposed: truecancelable: falsesummary: Canonical modal visibility event. - name: selectpayload:value:kind: stringbubbles: truecomposed: truecancelable: truesummary: Canonical command activation event emitted once per accepted selection.states: - name: closedsource: propertysummary: Command palette is absent from the active overlay surface. - name: opensource: propertysummary: Command palette is modal and collection navigation is active. - name: filteringsource: platformsummary: Input contains a non-empty filter query. - name: emptysource: platformsummary: No command label matches the current query. - name: focus-visiblesource: platformsummary: Filter input has keyboard-visible focus.parts: - name: backdropsummary: Modal backdrop. - name: surfacesummary: Command palette dialog surface. - name: inputsummary: Editable command filter with combobox semantics. - name: listsummary: Filtered command listbox. - name: groupsummary: Single-level command group. - name: group-headingsummary: Visible and programmatically associated group heading. - name: itemsummary: Repeated command option. - name: labelsummary: Command item label. - name: shortcutsummary: Render-only keyboard shortcut display string. - name: empty-statesummary: Localized message shown when filtering has no matches.tokens:surface:background: color.surface-containerforeground: color.on-surfaceborder-color: color.outlineradius: rounded.lgshadow: shadow.lgmax-width: 40remscrim:color: color.on-backgroundopacity: opacity.mutedinput:background: color.surfaceforeground: color.on-surfaceplaceholder: color.on-surface-variantborder-color: color.outlineborder-color-focus: color.primaryborder-width: 1pxradius: rounded.mdpadding-x: spacing.mdpadding-y: spacing.smtext: typography.body-lglist:gap: spacing.xspadding-y: spacing.smgroup-heading:foreground: color.on-surface-variantpadding-x: spacing.mdpadding-y: spacing.xstext: typography.label-smitem:foreground: color.on-surfaceactive-background: color.secondarydisabled-foreground: color.on-surface-variantpadding-x: spacing.mdpadding-y: spacing.smshortcut:foreground: color.on-surface-varianttext: typography.label-smempty-state:foreground: color.on-surface-variantpadding-x: spacing.mdpadding-y: spacing.lgmessages: - key: command.placeholderdescription: Placeholder text for the command palette filter input. - key: command.no-resultsdescription: Empty-state text shown when no command label matches the filter query.obligations:accessibility:role: dialogname: Label property provides the accessible name for the modal dialog.description: The dialog contains a combobox input controlling a grouped listbox.keyboard: - Text input follows platform editing keys and receives focus when the palette opens. - ArrowDown and ArrowUp move the active enabled command, wrapping at collection boundaries. - Home and End move to the first and last enabled filtered commands. - Enter selects the active enabled command. - Escape requests modal dismissal and restores focus to the host return target. - Tab and Shift+Tab remain trapped inside the modal surface.semantics: - Web input exposes combobox, expanded, autocomplete=list, aria-controls, and aria-activedescendant semantics. - Web listbox, option, and active-descendant IDREF targets live in the same document root. - Single-level groups expose group semantics and labelled headings without changing flat keyboard order. - Disabled items remain visible but are skipped by navigation and cannot activate. - The empty state is announced through a polite status region and uses a localized component message. - Flutter exposes the modal route, text field, group headings, enabled state, and active item through platform semantics; aria-activedescendant has no native Flutter equivalent.behavior:model: collectioninteractions: - Dialog overlay machinery owns modality, backdrop dismissal, Escape dismissal, focus containment, and focus restoration. - Combobox input machinery owns the filter query, case-insensitive substring matching, aria-activedescendant, and input focus. - Collection navigation owns active item movement, disabled-item skipping, wrapping, Home, End, and activation. - Controlled is-open wins over default-open; selection requests close after emitting select. - Global shortcuts, including Command-K, are host responsibilities and are never bound by the component. - Fuzzy matching and nested pages or sub-menus are future capabilities outside v1.hostEffects: - Present and dismiss a modal overlay surface. - Trap focus while open and restore focus after close. - Focus the filter input when opened. - Dispatch open-change and select events.conditions: - rtl - reduced-motion - cvd-deuteranopia - density-compact - text-expansion - keyboard-inset - safe-areasdui:status: serializableserializableProperties: - label - items - is-open - default-open - active-indexserializableSlots: []eventBindings: - open-change - selectnotes: Flat command data and open state serialize; query, modal route ownership, focus effects, and host global shortcuts remain target-local.examples: - name: usagestate: closedproperties:label: Command paletteis-open: falseitems: - label: Open filevalue: open-filegroup: File - label: Save filevalue: save-filegroup: File - label: Toggle sidebarvalue: toggle-sidebargroup: Viewslots: {} - name: groupedstate: openproperties:label: Command palettedefault-open: trueitems: - label: Open filevalue: open-filegroup: Fileshortcut: Command O - label: Save filevalue: save-filegroup: Fileshortcut: Command S - label: Toggle sidebarvalue: toggle-sidebargroup: Viewshortcut: Command Bslots: {} - name: disabled-itemstate: openproperties:label: Command palettedefault-open: trueitems: - label: Copyvalue: copygroup: Editshortcut: Command C - label: Pastevalue: pastegroup: Editshortcut: Command Vdisabled: trueslots: {} - name: emptystate: emptyproperties:label: Command palettedefault-open: trueitems: []slots: {}
01
Examples
Generated from the contract's examples block.
Previews are the published @wyrd-company/react component, themed by the
brand's role tokens — flip the site's light/dark toggle and they follow.
Flat ordered command data; group creates single-level labelled sections and shortcut is render-only text.
is-open
boolean
undefined
Controlled modal visibility.
default-open
boolean
false
Initial uncontrolled modal visibility.
active-index
integer
0
Initial active index in the filtered enabled command collection.
03
Slots & events
Event
Payload
Summary
open-change
is-open, reason
Canonical modal visibility event.
select
value
Canonical command activation event emitted once per accepted selection.
04
Tokens
The contract's token bindings. Open the shared contextual sidebar from any example;
primary swatches reflect the color you pick there. Error swatches show the active
preset's values; editing any knob switches to custom and resets error to TWW · Ink.
Binding
Token
surface.background
color.surface-container
surface.foreground
color.on-surface
surface.border-color
color.outline
surface.radius
rounded.lg
surface.shadow
shadow.lg
surface.max-width
40rem
scrim.color
color.on-background
scrim.opacity
opacity.muted
input.background
color.surface
input.foreground
color.on-surface
input.placeholder
color.on-surface-variant
input.border-color
color.outline
input.border-color-focus
color.primary
input.border-width
1px
input.radius
rounded.md
input.padding-x
spacing.md
input.padding-y
spacing.sm
input.text
typography.body-lg
list.gap
spacing.xs
list.padding-y
spacing.sm
group-heading.foreground
color.on-surface-variant
group-heading.padding-x
spacing.md
group-heading.padding-y
spacing.xs
group-heading.text
typography.label-sm
item.foreground
color.on-surface
item.active-background
color.secondary
item.disabled-foreground
color.on-surface-variant
item.padding-x
spacing.md
item.padding-y
spacing.sm
shortcut.foreground
color.on-surface-variant
shortcut.text
typography.label-sm
empty-state.foreground
color.on-surface-variant
empty-state.padding-x
spacing.md
empty-state.padding-y
spacing.lg
05
States
State
Source
Summary
closed
property
Command palette is absent from the active overlay surface.
open
property
Command palette is modal and collection navigation is active.
filtering
platform
Input contains a non-empty filter query.
empty
platform
No command label matches the current query.
focus-visible
platform
Filter input has keyboard-visible focus.
06
Accessibility
From the contract's accessibility obligations. Role dialog; Label property provides the accessible name for the modal dialog.
Text input follows platform editing keys and receives focus when the palette opens.
ArrowDown and ArrowUp move the active enabled command, wrapping at collection boundaries.
Home and End move to the first and last enabled filtered commands.
Enter selects the active enabled command.
Escape requests modal dismissal and restores focus to the host return target.
Tab and Shift+Tab remain trapped inside the modal surface.
Web input exposes combobox, expanded, autocomplete=list, aria-controls, and aria-activedescendant semantics.
Web listbox, option, and active-descendant IDREF targets live in the same document root.
Single-level groups expose group semantics and labelled headings without changing flat keyboard order.
Disabled items remain visible but are skipped by navigation and cannot activate.
The empty state is announced through a polite status region and uses a localized component message.
Flutter exposes the modal route, text field, group headings, enabled state, and active item through platform semantics; aria-activedescendant has no native Flutter equivalent.
Status: serializable. Flat command data and open state serialize; query, modal route ownership, focus effects, and host global shortcuts remain target-local.