Skip to content
RefineUI

Command

Command palette interface with search.

Overview

Machine-readable contract from Component Spec.

component: commandexport: Commandversion: 1attributes: data-refineui=command

Anatomy

Partdata-refineui
rootcommand
emptycommand-empty
groupcommand-group
group_headingcommand-group-heading
inputcommand-input
itemcommand-item
listcommand-list
separatorcommand-separator
shortcutcommand-shortcut

States

ScopeCategoryValues
componentpseudofocus-visible
componentcomponentdata-state: disabled, active, default
componentenvironmentforced-colors, dir

Accessibility

SlotElementRoleRequired attributes
command-itemdivoptionaria-selected: required=true, type: boolean

Keyboard

KeyActionNative
ArrowDownnext-trigger
ArrowUpprevious-trigger
Homefirst-trigger
Endlast-trigger
Enteractivate

Focus

SectionPropertyValue
visualrequiredtrue
visualselector:focus-visible

Layout

PropertyValue
directionlogical
rtltrue
npm install @refineui/react @refineui/tokens
import {
Command,
CommandInput,
CommandList,
CommandEmpty,
CommandGroup,
CommandGroupHeading,
CommandItem,
CommandSeparator
} from "@refineui/react";
<Command>
<CommandInput placeholder="Search commands..." />
<CommandList>
<CommandEmpty>No results found.</CommandEmpty>
<CommandGroup>
<CommandGroupHeading>File</CommandGroupHeading>
<CommandItem value="new" onSelect={() => handleNew()}>
New File
</CommandItem>
<CommandItem value="open">Open</CommandItem>
</CommandGroup>
<CommandSeparator />
<CommandGroup>
<CommandGroupHeading>Edit</CommandGroupHeading>
<CommandItem value="copy">Copy</CommandItem>
<CommandItem value="paste">Paste</CommandItem>
</CommandGroup>
</CommandList>
</Command>
<CommandDialog open={isOpen} onOpenChange={setIsOpen}>
<Command>
{/* Command content */}
</Command>
</CommandDialog>
PropDefaultTypeDescription
valuestringControlled search query.
defaultValuestringUncontrolled initial search query.
onValueChange(search: string) => voidEvent handler when search changes.
shouldFiltertruebooleanWhen true, filters items by search text.
filterCommandFilterCustom score function (return 0 to hide).
selectedValuestringControlled highlighted item value.
defaultSelectedValuestringUncontrolled initial highlighted item.
onSelectedValueChange(value: string) => voidEvent handler when highlighted item changes.
labelstringAccessible name (`aria-label`).

Command in a Dialog overlay.

PropDefaultTypeDescription
openbooleanControlled open state.
onOpenChange(open: boolean) => voidEvent handler when open state changes.
commandPropsCommandPropsProps forwarded to inner Command.

Search input with optional startIcon.

Scrollable list container (uses ScrollArea internally).

Shown when no items match.

Groups related items.

Heading for a group.

Visual divider.

PropDefaultTypeDescription
valuestringUnique value for filtering and selection (required).
keywordsstring[]Extra strings for default filter.
onSelect(value: string) => voidCalled when activated (click/Enter).
forceMountfalsebooleanKeep mounted when filtered out.
startIconReactNodeLeading icon.
endIconReactNodeTrailing icon.
shortcutReactNodeKeyboard shortcut hint.