Command
An inline searchable command palette that filters items and emits an execute event on activation.
Base Command renders an inline, searchable list of executable commands. Pressing Enter or clicking an item emits execute with the selected command for your application to handle.
Preview
Section titled “Preview” Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
Installation
Section titled “Installation”Available starting in 0.3.0-rc.1 and later releases.
Anatomy
Section titled “Anatomy”Compose Root, Input, Content, Item, Empty, plus optional grouping parts (Group, Label, Separator):
- The command list stays inline and open by default (
defaultOpen={true}); typing filters items without executing them. Groupbinds its localLabeland hides both visually and from the accessibility tree when no descendantItemmatches;Separatoris a decorative contentless divider.Rootexposes controlled and uncontrolled active-item ownership viaactiveValue,defaultActiveValue,setActiveValue(), andactiveValueChange.- Built-in filtering matches
textValueandkeywordscase- and diacritic-insensitively. Setfilter={false}to filter items yourself. Emptyreflects whether any items match; disabled and duplicate-valued items cannot execute.
Controlled state and keyboard behavior
Section titled “Controlled state and keyboard behavior”value,inputValue, andopencan each be controlled independently.Inputkeeps focus during arrow-key navigation, and active IME composition never triggers command execution.
Root Props
Section titled “Root Props”Pass value, inputValue, or open to control the corresponding state.
| Prop | Type | Default |
|---|---|---|
value | string | — |
defaultValue | string | '' |
activeValue | string | — |
defaultActiveValue | string | '' |
inputValue | string | — |
defaultInputValue | string | '' |
open | boolean | — |
defaultOpen | boolean | true |
disabled | boolean | false |
readOnly | boolean | false |
filter | boolean | true |
loop | boolean | true |
a11yLabel | string | '' |
Other parts
Section titled “Other parts”- Input:
placeholder,a11yLabel, andnamedefault to''. - Content:
sidedefaults to'bottom',alignto'start',sideOffsetto4, andcollisionPaddingto8. - Item:
value,textValue, andkeywordsdefault to'';disableddefaults tofalse. - Empty: no props.
- Group / Label / Separator: no extra props;
Groupexposes avisiblestate.