Skip to content
NavigationInteractive playground

Command

An action list that filters as you type.

Preparing the playground…
Text and Markdown example
Command · Example
1<Command style={{width:360}}><CommandInput placeholder="Search for an action…" /><CommandList><CommandEmpty>No results.</CommandEmpty><CommandGroup heading="Actions"><CommandItem value="proyecto">Create project</CommandItem><CommandItem value="equipo">Invite to team</CommandItem></CommandGroup></CommandList></Command>
Read documentation in Markdown

How to use it

Set value on each action and handle onSelect. CommandDialog displays the search interface in a dialog.

Import

React / Next.js
1import { Command, CommandDialog, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem, CommandSeparator, CommandShortcut } from "@kivora/nextjs";

Interactive examples run inside a component with "use client". The playground's Copy button includes the imports needed for the current example.

API reference 0.2.0

Types from the installed published version, including component properties and common HTML attributes. “Optional” does not imply a default value; omitting a property lets the component decide.

PropertyTypeDescription
aria-labelstringAccessible name of the control.
asChildbooleanApply props and behavior to a single compatible child element.
childrenReactNodeContent or child elements of the component.
classNamestringAdditional CSS classes to customize the element.
defaultCheckedbooleanInitial selection of the control.
defaultValuestring | (readonly string[] & string)Initial value when the component manages its own state.
disablePointerSelectionbooleanOptionally set to `true` to disable selection via pointer events.
filterCommandFilterCustom filter function for whether each command menu item should matches the given search query. It should return a number between 0 and 1, with 1 being the best match and 0 being hidden entirely. By default, uses the `command-score` library.
idstringElement identifier; associates labels and descriptions.
labelstringText or accessible label.
loopbooleanOptionally set to `true` to turn on looping around when using the arrow keys.
onChangeChangeEventHandler<HTMLDivElement, Element>Change event. Check the type: some controls return an object, others a DOM event.
onClickMouseEventHandler<HTMLDivElement>Action performed when the element is activated.
onSubmitSubmitEventHandler<HTMLDivElement>Form submission event.
onValueChange((value: string) => void)Receives the value after an interaction.
roleAriaRoleSemantic role of the element. Keep the default role unless a change is justified.
shouldFilterbooleanOptionally set to `false` to turn off the automatic filtering and sorting. If `false`, you must conditionally render valid items based on the search query yourself.
styleCSSPropertiesReact inline styles.
tabIndexnumberKeyboard focus order and availability.
titlestringTitle or supplementary information.
valuestringControlled value. Update it from the change callback.
vimBindingsbooleanSet to `false` to disable ctrl+n/j/p/k shortcuts. Defaults to `true`.

Subcomponents and composition

Review each component's properties and published declaration. Native and accessibility attributes are inherited from the element specified by its type.

Command22 properties
Command · TypeScript
1Command: React.ForwardRefExoticComponent<CommandProps & React.RefAttributes<HTMLDivElement>>
CommandDialog10 properties
PropertyTypeDescription
childrenReactNodeContent or child elements of the component.
commandClassNamestringCSS classes for the specified element.
contentClassNamestringCSS classes for the specified element.
defaultOpenbooleanWhether it starts open in uncontrolled mode.
modalbooleanConfigures modal. The type describes the supported values and structure.
onOpenChange((open: boolean) => void)Receives the new open state.
openbooleanControlled open state.
shortcutbooleanConfigures shortcut. The type describes the supported values and structure.
shortcutKeystringConfigures shortcutKey. The type describes the supported values and structure.
triggerReactNodeConfigures trigger. The type describes the supported values and structure.
CommandDialog · TypeScript
1declare function CommandDialog({ children, commandClassName, contentClassName, defaultOpen, onOpenChange, open, shortcut, shortcutKey, trigger, ...props }: CommandDialogProps): React.JSX.Element;
CommandInput27 properties
PropertyTypeDescription
altstringAlternative text for the image.
aria-labelstringAccessible name of the control.
asChildbooleanApply props and behavior to a single compatible child element.
autoCompleteHTMLInputAutoCompleteAttributeTell the browser which autocomplete type to use.
checkedbooleanControlled selection state.
childrenReactNodeContent or child elements of the component.
classNamestringAdditional CSS classes to customize the element.
defaultCheckedbooleanInitial selection of the control.
defaultValuestring | number | readonly string[]Initial value when the component manages its own state.
disabledbooleanDisable interaction with the control.
idstringElement identifier; associates labels and descriptions.
maxstring | numberMaximum allowed value.
maxLengthnumberMaximum number of characters.
minstring | numberMinimum allowed value.
namestringName used to identify the control in forms.
onClickMouseEventHandler<HTMLInputElement>Action performed when the element is activated.
onSubmitSubmitEventHandler<HTMLInputElement>Form submission event.
onValueChange((search: string) => void)Receives the value after an interaction.
placeholderstringShort hint displayed when there is no value.
requiredbooleanIndicates that a value is required.
roleAriaRoleSemantic role of the element. Keep the default role unless a change is justified.
srcstringResource path or URL.
stepstring | numberIncrement between values.
styleCSSPropertiesReact inline styles.
tabIndexnumberKeyboard focus order and availability.
titlestringTitle or supplementary information.
valuestringControlled value. Update it from the change callback.
CommandInput · TypeScript
1CommandInput: React.ForwardRefExoticComponent<CommandInputProps & React.RefAttributes<HTMLInputElement>>
CommandList15 properties
PropertyTypeDescription
aria-labelstringAccessible name of the control.
asChildbooleanApply props and behavior to a single compatible child element.
childrenReactNodeContent or child elements of the component.
classNamestringAdditional CSS classes to customize the element.
defaultCheckedbooleanInitial selection of the control.
defaultValuestring | number | readonly string[]Initial value when the component manages its own state.
idstringElement identifier; associates labels and descriptions.
labelstringText or accessible label.
onChangeChangeEventHandler<HTMLDivElement, Element>Change event. Check the type: some controls return an object, others a DOM event.
onClickMouseEventHandler<HTMLDivElement>Action performed when the element is activated.
onSubmitSubmitEventHandler<HTMLDivElement>Form submission event.
roleAriaRoleSemantic role of the element. Keep the default role unless a change is justified.
styleCSSPropertiesReact inline styles.
tabIndexnumberKeyboard focus order and availability.
titlestringTitle or supplementary information.
CommandList · TypeScript
1CommandList: React.ForwardRefExoticComponent<CommandListProps & React.RefAttributes<HTMLDivElement>>
CommandEmpty14 properties
PropertyTypeDescription
aria-labelstringAccessible name of the control.
asChildbooleanApply props and behavior to a single compatible child element.
childrenReactNodeContent or child elements of the component.
classNamestringAdditional CSS classes to customize the element.
defaultCheckedbooleanInitial selection of the control.
defaultValuestring | number | readonly string[]Initial value when the component manages its own state.
idstringElement identifier; associates labels and descriptions.
onChangeChangeEventHandler<HTMLDivElement, Element>Change event. Check the type: some controls return an object, others a DOM event.
onClickMouseEventHandler<HTMLDivElement>Action performed when the element is activated.
onSubmitSubmitEventHandler<HTMLDivElement>Form submission event.
roleAriaRoleSemantic role of the element. Keep the default role unless a change is justified.
styleCSSPropertiesReact inline styles.
tabIndexnumberKeyboard focus order and availability.
titlestringTitle or supplementary information.
CommandEmpty · TypeScript
1CommandEmpty: React.ForwardRefExoticComponent<CommandEmptyProps & React.RefAttributes<HTMLDivElement>>
CommandGroup17 properties
PropertyTypeDescription
aria-labelstringAccessible name of the control.
asChildbooleanApply props and behavior to a single compatible child element.
childrenReactNodeContent or child elements of the component.
classNamestringAdditional CSS classes to customize the element.
defaultCheckedbooleanInitial selection of the control.
defaultValuestring | number | readonly string[]Initial value when the component manages its own state.
forceMountbooleanWhether this group is forcibly rendered regardless of filtering.
headingReactNodeOptional heading to render for this group.
idstringElement identifier; associates labels and descriptions.
onChangeChangeEventHandler<HTMLDivElement, Element>Change event. Check the type: some controls return an object, others a DOM event.
onClickMouseEventHandler<HTMLDivElement>Action performed when the element is activated.
onSubmitSubmitEventHandler<HTMLDivElement>Form submission event.
roleAriaRoleSemantic role of the element. Keep the default role unless a change is justified.
styleCSSPropertiesReact inline styles.
tabIndexnumberKeyboard focus order and availability.
titlestringTitle or supplementary information.
valuestringControlled value. Update it from the change callback.
CommandGroup · TypeScript
1CommandGroup: React.ForwardRefExoticComponent<CommandGroupProps & React.RefAttributes<HTMLDivElement>>
CommandItem19 properties
PropertyTypeDescription
aria-labelstringAccessible name of the control.
asChildbooleanApply props and behavior to a single compatible child element.
childrenReactNodeContent or child elements of the component.
classNamestringAdditional CSS classes to customize the element.
defaultCheckedbooleanInitial selection of the control.
defaultValuestring | number | readonly string[]Initial value when the component manages its own state.
disabledbooleanDisable interaction with the control.
forceMountbooleanWhether this item is forcibly rendered regardless of filtering.
idstringElement identifier; associates labels and descriptions.
keywordsstring[]Optional keywords to match against when filtering.
onChangeChangeEventHandler<HTMLDivElement, Element>Change event. Check the type: some controls return an object, others a DOM event.
onClickMouseEventHandler<HTMLDivElement>Action performed when the element is activated.
onSelect((value: string) => void)Action or selection made by the user.
onSubmitSubmitEventHandler<HTMLDivElement>Form submission event.
roleAriaRoleSemantic role of the element. Keep the default role unless a change is justified.
styleCSSPropertiesReact inline styles.
tabIndexnumberKeyboard focus order and availability.
titlestringTitle or supplementary information.
valuestringControlled value. Update it from the change callback.
CommandItem · TypeScript
1CommandItem: React.ForwardRefExoticComponent<CommandItemProps & React.RefAttributes<HTMLDivElement>>
CommandSeparator15 properties
PropertyTypeDescription
alwaysRenderbooleanWhether this separator should always be rendered. Useful if you disable automatic filtering.
aria-labelstringAccessible name of the control.
asChildbooleanApply props and behavior to a single compatible child element.
childrenReactNodeContent or child elements of the component.
classNamestringAdditional CSS classes to customize the element.
defaultCheckedbooleanInitial selection of the control.
defaultValuestring | number | readonly string[]Initial value when the component manages its own state.
idstringElement identifier; associates labels and descriptions.
onChangeChangeEventHandler<HTMLDivElement, Element>Change event. Check the type: some controls return an object, others a DOM event.
onClickMouseEventHandler<HTMLDivElement>Action performed when the element is activated.
onSubmitSubmitEventHandler<HTMLDivElement>Form submission event.
roleAriaRoleSemantic role of the element. Keep the default role unless a change is justified.
styleCSSPropertiesReact inline styles.
tabIndexnumberKeyboard focus order and availability.
titlestringTitle or supplementary information.
CommandSeparator · TypeScript
1CommandSeparator: React.ForwardRefExoticComponent<CommandSeparatorProps & React.RefAttributes<HTMLDivElement>>
CommandShortcut13 properties
PropertyTypeDescription
aria-labelstringAccessible name of the control.
childrenReactNodeContent or child elements of the component.
classNamestringAdditional CSS classes to customize the element.
defaultCheckedbooleanInitial selection of the control.
defaultValuestring | number | readonly string[]Initial value when the component manages its own state.
idstringElement identifier; associates labels and descriptions.
onChangeChangeEventHandler<HTMLSpanElement, Element>Change event. Check the type: some controls return an object, others a DOM event.
onClickMouseEventHandler<HTMLSpanElement>Action performed when the element is activated.
onSubmitSubmitEventHandler<HTMLSpanElement>Form submission event.
roleAriaRoleSemantic role of the element. Keep the default role unless a change is justified.
styleCSSPropertiesReact inline styles.
tabIndexnumberKeyboard focus order and availability.
titlestringTitle or supplementary information.
CommandShortcut · TypeScript
1CommandShortcut: { 2 ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>): React.JSX.Element; 3 displayName: string; 4}
API generated from @kivora/nextjs 0.2.0View package