structyl

Command API

View component

The full prop reference for the Command component. A command palette with fuzzy search, cmdk-style.

Import

tsx
import { Command } from '@structyl/styled';

Props

Root

Root command container that manages state and provides context for all command subcomponents

PropTypeDefault
value#string

Controlled selected item value

—
defaultValue#string

Default selected item value when uncontrolled

—
onValueChange#(value: string) => void

Callback fired when selected value changes

—
filter#(value: string, search: string, keywords?: string[]) => number

Custom filter function that scores items for search; defaults to prefix/include matching

—
shouldFilter#boolean

Whether to apply filtering based on search input

true
label#string

Aria-label for the root element

'Command Menu'
loop#boolean

Whether arrow navigation loops from last to first item and vice versa

false
asChild#boolean

Render as child element, merging props with child component

—
className#string

CSS 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

PropTypeDefault
className#string

CSS class name (styled version wraps input with search icon)

—
asChild#boolean

Render as child element, merging props with child component

—
value#string

Controlled input value

—
onChange#(event: React.ChangeEvent<HTMLInputElement>) => void

Callback when input value changes

—
placeholder#string

Input placeholder text

—
ref#React.Ref<HTMLInputElement>

Ref to the input element

—

List

Container for command items and groups; scrollable container with role listbox

PropTypeDefault
className#string

CSS class name (styled version adds max-height and scroll behavior)

—
asChild#boolean

Render as child element, merging props with child component

—
aria-label#string

Aria-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

PropTypeDefault
value#string

Item value; falls back to textContent if not provided

—
keywords#string[]

Additional keywords for search matching beyond the item text

—
disabled#boolean

Prevents selection and interaction with the item

—
onSelect#(value: string) => void

Callback fired when item is clicked or selected via keyboard

—
className#string

CSS class name (styled version adds selection and disabled styling)

—
asChild#boolean

Render 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

PropTypeDefault
heading#React.ReactNode

Section heading displayed above items in the group

—
className#string

CSS class name (styled version adds padding and heading styles)

—
asChild#boolean

Render 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

PropTypeDefault
className#string

CSS 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

PropTypeDefault
className#string

CSS class name (styled version adds border styling)

—
asChild#boolean

Render 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

PropTypeDefault
progress#number

Progress value (0-100) for aria-valuenow

—
className#string

CSS class name

—
ref#React.Ref<HTMLDivElement>

Ref to the loading div element

—

Shortcut

Keyboard shortcut hint displayed in command items (styled version only)

PropTypeDefault
className#string

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

structyl — Accessible React Component Library