Command
Composable command menu (command palette) with search.
Preview
Installation
npx sigma-ui@latest add commandUsage
<script setup lang="ts">
import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from '@/components/ui/command';
</script>
<template>
<Command>
<CommandInput placeholder="Type a command..." />
<CommandList>
<CommandEmpty>No results found.</CommandEmpty>
<CommandGroup heading="Suggestions">
<CommandItem value="calendar">
Calendar
</CommandItem>
</CommandGroup>
</CommandList>
</Command>
</template>Wrap it in CommandDialog for a command palette, or in Popover / DropdownMenu for an inline menu.
Examples
Basic
Dialog
Popover
Dropdown menu
Responsive
Popover on desktop and Drawer on mobile.
Form
API Reference
Command
Props
| Prop | Type | Default |
|---|---|---|
openThe controlled open state of the Combobox. Can be binded with | boolean | true |
defaultOpenThe open state of the combobox when it is initially rendered. <br> Use when you do not need to control its open state. | boolean | - |
resetSearchTermOnBlurWhether to reset the searchTerm when the Combobox input blurred | boolean | `true` |
resetSearchTermOnSelectWhether to reset the searchTerm when the Combobox value is selected | boolean | `true` |
openOnFocusWhether to open the combobox when the input is focused | boolean | `false` |
openOnClickWhether to open the combobox when the input is clicked | boolean | `false` |
ignoreFilterWhen | boolean | - |
resetModelValueOnClearWhen | boolean | - |
unmountOnHideWhen set to | boolean | true |
multipleWhether multiple options can be selected or not. | boolean | - |
disabledWhen | boolean | - |
dirThe reading direction of the listbox when applicable. <br> If omitted, inherits globally from | Direction | - |
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
modelValueThe controlled value of the listbox. Can be binded with | AcceptableValue | AcceptableValue[] | "" |
defaultValueThe value of the listbox when initially rendered. Use when you do not need to control the state of the Listbox | AcceptableValue | AcceptableValue[] | - |
nameThe name of the field. Submitted with its owning form as part of a name/value pair. | string | - |
requiredWhen | boolean | - |
highlightOnHoverWhen | boolean | - |
loopWhen | boolean | - |
byUse this to compare objects by a particular field, or pass your own comparison function for complete control over how objects are compared. | string | ((a: AcceptableValue, b: AcceptableValue) => boolean) | - |
Events
| Event | Payload |
|---|---|
update:modelValueEvent handler called when the value changes. | [value: AcceptableValue] |
update:openEvent handler called when the open state of the combobox changes. | [value: boolean] |
highlightEvent handler when highlighted element changes. | [payload: { ref: HTMLElement; value: AcceptableValue; }] |
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
CommandDialog
Props
| Prop | Type | Default |
|---|---|---|
openThe controlled open state of the dialog. Can be binded as | boolean | - |
defaultOpenThe open state of the dialog when it is initially rendered. Use when you do not need to control its open state. | boolean | - |
modalThe modality of the dialog When set to | boolean | - |
unmountOnHideWhen set to | boolean | true |
Events
| Event | Payload |
|---|---|
update:openEvent handler called when the open state of the dialog changes. | [value: boolean] |
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
CommandEmpty
Props
| Prop | Type | Default |
|---|---|---|
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
CommandGroup
Props
| Prop | Type | Default |
|---|---|---|
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
headingLabel shown above the group items. | string | - |
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
CommandInput
Props
| Prop | Type | Default |
|---|---|---|
displayValueThe display value of input for selected item. Does not work with | ((val: any) => string) | - |
modelValueThe controlled value of the filter. Can be binded with v-model. | string | - |
autoFocusFocus on element when mounted. | boolean | - |
disabledWhen | boolean | - |
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
CommandItem
Props
| Prop | Type | Default |
|---|---|---|
textValueA string representation of the item contents. If the children are not plain text, then the | string | - |
valuerequiredThe value given as data when submitted with a | AcceptableValue | - |
disabledWhen | boolean | - |
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
Events
| Event | Payload |
|---|---|
selectEvent handler called when the selecting item. <br> It can be prevented by calling | [event: SelectEvent$3<AcceptableValue>] |
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
CommandList
Props
| Prop | Type | Default |
|---|---|---|
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
CommandSeparator
Props
| Prop | Type | Default |
|---|---|---|
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
CommandShortcut
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
Accessibility
The menu is a listbox. The input filters the options, and arrow keys move the active item. Reka UI sets role="listbox" and the active descendant.
| Key | Description |
|---|---|
| Tab | Moves focus to the search input. |
| ArrowDown | Moves to the next item. |
| ArrowUp | Moves to the previous item. |
| Enter | Runs the focused item. |
| Escape | Closes the menu when it is inside a dialog or popover. |