Command API
View componentThe full prop reference for the Command component. A command palette with fuzzy search, cmdk-style.
Import
import { Command } from '@structyl/styled';Props
Root
Root command container that manages state and provides context for all command subcomponents
| Prop | Type | Default |
|---|---|---|
| value# | stringControlled selected item value | — |
| defaultValue# | stringDefault selected item value when uncontrolled | — |
| onValueChange# | (value: string) => voidCallback fired when selected value changes | — |
| filter# | (value: string, search: string, keywords?: string[]) => numberCustom filter function that scores items for search; defaults to prefix/include matching | — |
| shouldFilter# | booleanWhether to apply filtering based on search input | true |
| label# | stringAria-label for the root element | 'Command Menu' |
| loop# | booleanWhether arrow navigation loops from last to first item and vice versa | false |
| asChild# | booleanRender as child element, merging props with child component | — |
| className# | stringCSS class name (styled version adds default popover styling) | — |
| ref# | React.Ref<HTMLDivElement>Ref to the root div element | — |
Input
Search/filter input field that updates the command's search state
| Prop | Type | Default |
|---|---|---|
| className# | stringCSS class name (styled version wraps input with search icon) | — |
| asChild# | booleanRender as child element, merging props with child component | — |
| value# | stringControlled input value | — |
| onChange# | (event: React.ChangeEvent<HTMLInputElement>) => voidCallback when input value changes | — |
| placeholder# | stringInput placeholder text | — |
| ref# | React.Ref<HTMLInputElement>Ref to the input element | — |
List
Container for command items and groups; scrollable container with role listbox
| Prop | Type | Default |
|---|---|---|
| className# | stringCSS class name (styled version adds max-height and scroll behavior) | — |
| asChild# | booleanRender as child element, merging props with child component | — |
| aria-label# | stringAria-label for the list | 'Command results' |
| ref# | React.Ref<HTMLDivElement>Ref to the list div element | — |
Item
Selectable command item within a list or group
| Prop | Type | Default |
|---|---|---|
| value# | stringItem value; falls back to textContent if not provided | — |
| keywords# | string[]Additional keywords for search matching beyond the item text | — |
| disabled# | booleanPrevents selection and interaction with the item | — |
| onSelect# | (value: string) => voidCallback fired when item is clicked or selected via keyboard | — |
| className# | stringCSS class name (styled version adds selection and disabled styling) | — |
| asChild# | booleanRender as child element, merging props with child component | — |
| ref# | React.Ref<HTMLDivElement>Ref to the item div element | — |
Group
Logical grouping of command items with optional heading
| Prop | Type | Default |
|---|---|---|
| heading# | React.ReactNodeSection heading displayed above items in the group | — |
| className# | stringCSS class name (styled version adds padding and heading styles) | — |
| asChild# | booleanRender as child element, merging props with child component | — |
| ref# | React.Ref<HTMLDivElement>Ref to the group div element | — |
Empty
Placeholder content shown when no items match the search query
| Prop | Type | Default |
|---|---|---|
| className# | stringCSS class name (styled version adds padding and text centering) | — |
| ref# | React.Ref<HTMLDivElement>Ref to the empty state div element | — |
Separator
Visual divider between command groups or sections
| Prop | Type | Default |
|---|---|---|
| className# | stringCSS class name (styled version adds border styling) | — |
| asChild# | booleanRender as child element, merging props with child component | — |
| ref# | React.Ref<HTMLDivElement>Ref to the separator div element | — |
Loading
Loading indicator displayed during async operations
| Prop | Type | Default |
|---|---|---|
| progress# | numberProgress value (0-100) for aria-valuenow | — |
| className# | stringCSS class name | — |
| ref# | React.Ref<HTMLDivElement>Ref to the loading div element | — |
Shortcut
Keyboard shortcut hint displayed in command items (styled version only)
| Prop | Type | Default |
|---|---|---|
| className# | stringCSS class name (styled version adds muted text styling and right alignment) | — |
Source code
If you didn't find what you need here, read the component implementation .