navigation — wyrd.component.command

Command

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.

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.

Code target Applies to every example on component pages.
usage state: closed
Usage
import { useState } from "react";
import { WyrdButton, WyrdCommand } from "@wyrd-company/react";

export function CommandInteractionExample() {
  const [open, setOpen] = useState(false);
  const close = () => setOpen(false);
  return <>
    <WyrdButton onPress={() => setOpen(true)}>Open command palette</WyrdButton>
    <WyrdCommand label="Command palette" isOpen={open}
      items={[{ label: "Open file", value: "open-file", group: "File" }, { label: "Save file", value: "save-file", group: "File" }, { label: "Toggle sidebar", value: "toggle-sidebar", group: "View" }]}
      onOpenChange={(event) => !event.isOpen && close()} onSelect={close} />
  </>;
}
grouped state: open
Usage
import { WyrdCommand } from "@wyrd-company/react";

<WyrdCommand label="Command palette" defaultOpen items={[{"label":"Open file","value":"open-file","group":"File","shortcut":"Command O"},{"label":"Save file","value":"save-file","group":"File","shortcut":"Command S"},{"label":"Toggle sidebar","value":"toggle-sidebar","group":"View","shortcut":"Command B"}]} />

// events: onOpenChange, onSelect
disabled-item state: open
Usage
import { WyrdCommand } from "@wyrd-company/react";

<WyrdCommand label="Command palette" defaultOpen items={[{"label":"Copy","value":"copy","group":"Edit","shortcut":"Command C"},{"label":"Paste","value":"paste","group":"Edit","shortcut":"Command V","disabled":true}]} />

// events: onOpenChange, onSelect
empty state: empty
Usage
import { WyrdCommand } from "@wyrd-company/react";

<WyrdCommand label="Command palette" defaultOpen items={[]} />

// events: onOpenChange, onSelect
02

Properties

NameTypeDefaultSummary
label string undefined Accessible name for the command palette dialog.
items array 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

EventPayloadSummary
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.

BindingToken
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

StateSourceSummary
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.
  • Verified under: rtl, reduced-motion, cvd-deuteranopia, density-compact, text-expansion, keyboard-inset, safe-area.
07

SDUI

Status: serializable. Flat command data and open state serialize; query, modal route ownership, focus effects, and host global shortcuts remain target-local.

SerializableMembers
Propertieslabel, items, is-open, default-open, active-index
Slots
Eventsopen-change, select
The Wyrding Way — a contract-first design system. © Wyrd Company