Talisman LogoTalisman Logo Design System
Browse documentation
Components

Command

A search field with a filtered list of items, built on cmdk, for command palettes and as the base of the other selection components.

Stableimport { Command } from "@repo/ui/command";Source

Type to filter. Use the arrow keys to highlight an item.

When to use

  • A command palette or global search that opens pages and runs actions (CommandDialog).
  • A searchable list that is always visible, such as a side panel.
  • To build a new selection control that Combobox, Creatable combobox and Autocomplete do not cover.

When not to use

  • Choosing a value for a form field. Use Select for short lists or Combobox for searchable ones; both already wrap Command in a popover.
  • A menu of actions on one element. Use a Dropdown menu.
  • A modal that asks a question. Use Dialog.

Which one to use

Component The user Options Value Typical use
Select Picks from a list Fixed, short One of the options Status, type, role
Combobox Searches, then picks Long or loaded from an API One of the options Customer, template, model
Creatable combobox Searches, picks or types Suggestions An option or free text Field name, tag
Autocomplete Types and gets suggestions Filtered as they type One option, shown as a chip Search for a person or entity
Command Types to find an action Actions and pages Runs an action, holds no value Global search, shortcuts

Anatomy

Part Role
Command The root. Owns the search text, the highlight and the filter.
CommandInput The search field, with a search icon.
CommandList Scrollable area, up to 300px high.
CommandGroup A set of items. heading names it.
CommandItem One result. onSelect runs when chosen; disabled blocks it.
CommandSeparator A line between groups.
CommandShortcut A key hint aligned to the right of an item.
CommandEmpty Shown when nothing matches. It has no default text.
CommandDialog Command inside a modal Dialog, for a global palette.

Examples

Palette with groups

Searching by label and description

By default, cmdk matches what is in the item value. When the value is an id and the user reads a label, pass options so the search reads the label and description instead. The search ignores accents and case.

Busque por “reu” ou “mérito”: a busca ignora acentos e também lê a descrição.

Custom filter

Use filter when you need your own rule. Call filterOptions inside it to keep the built-in behavior and add to it.

In a dialog

CommandDialog needs a title and a description. They are read by screen readers and are not visible.

Filtering

filterOptions(value, search, options?) is the function Command uses when you do not pass filter. It returns 1 to show an item and 0 to hide it. There is no ranking: matching items keep the order you gave them.

Rule Detail
Empty search Every item matches.
Normalization Both sides lose accents and special characters, become lowercase and use - for spaces, with no length limit. “Réplica” matches “replica”.
With options The item is found by its value, and the search runs over its label and description together.
Without options (or value not in it) The search runs over the item value.
Multiple words They match as a sequence: “petição inicial” matches, “inicial petição” does not.
Performance options is indexed once and cached by array identity. Pass a stable array (a constant or useMemo), not a new one on every render.

Set shouldFilter={false} when the items already come filtered, such as server results, and render only what should be visible.

Content

  • Group headings name the kind of result: “Páginas”, “Ações”.
  • Items are short and start with the noun or the verb: “Tarefas”, “Buscar processo”.
  • Always add a CommandEmpty with a short message: “Nenhum resultado”.
  • Show shortcuts with CommandShortcut, and use real keys: “⌘K”.
  • Icons are optional; mark them aria-hidden because the label already says it.

Do and don’t

value=“defense”, label “Contestação”

DoPass options so users search the label they read, not an internal id.

value=“defense”, no options

Don'tDon't put only an id in `value` without options. Searching 'contestação' finds nothing.

Accessibility

  • Built on cmdk: CommandInput is role="combobox" linked to the list by aria-controls and aria-activedescendant; CommandList is role="listbox"; items are role="option" with aria-selected and aria-disabled.
  • Focus stays in the input while the highlight moves, so users can keep typing.
  • Keyboard: ArrowDown and ArrowUp move, Home and End go to the first and last item, Enter runs onSelect. Disabled items are skipped.
  • CommandDialog uses Radix Dialog: focus moves in on open, Escape closes it, and focus returns to the opener. Its required title and description become the dialog name and description.
  • Icons inside items are decorative; give them aria-hidden.

Code

import {
  Command,
  CommandEmpty,
  CommandGroup,
  CommandInput,
  CommandItem,
  CommandList,
} from "@repo/ui/command";

<Command>
  <CommandInput placeholder="Buscar páginas e ações…" />
  <CommandList>
    <CommandEmpty>Nenhum resultado</CommandEmpty>
    <CommandGroup heading="Páginas">
      <CommandItem onSelect={openTasks}>Tarefas</CommandItem>
    </CommandGroup>
  </CommandList>
</Command>;

Props

Command
PropTypeDefaultDescription
filter(value: string, search: string, keywords?: string[]) => number—Custom match function. Return 1 to show the item and 0 to hide it. Replaces the built-in `filterOptions`
onValueChange(value: string) => void—Called when the highlighted item changes
options{ value: string; label: string; description?: string }[][]Label and description of each item, so search matches what the user reads and not only the item `value`
shouldFilterbooleantrueSet to false when you filter the items yourself, for example with results from a server
valuestring—Controlled highlighted item
CommandDialog
PropTypeDefaultDescription
open / onOpenChangeboolean / (open: boolean) => void—Controls the dialog.
titleReactNode—Accessible name of the dialog, not visible. Required.
descriptionReactNode—Accessible description of the dialog, not visible. Required.
shouldFilterbooleantrueSet to false when you filter the items.
CommandItem
PropTypeDefaultDescription
valuestring—Identifies the item for filtering and selection. Defaults to its text.
onSelect(value: string) => void—Runs on click or `Enter`.
disabledbooleanfalseSkips the item in navigation and blocks selection.
keywordsstring[]—Extra terms the default cmdk filter can match.
CommandInput
PropTypeDefaultDescription
placeholderstring—Text of the empty field. Pass translated copy.
value / onValueChangestring / (value: string) => void—Controls the search text.
CommandGroup
PropTypeDefaultDescription
headingReactNode—Label of the group.
filterOptions(value, search, options?)
PropTypeDefaultDescription
valuestring—The item value.
searchstring—The current search text.
options{ value; label; description? }[]—Optional. Enables label and description matching.

Known issues

Issue Effect
CommandInput sets placeholder:text-primary. The placeholder has the same color as typed text, so an empty field looks filled in.
CommandDialog does not pass closeLabel to DialogContent. The corner close button is named “Close” in English and an app cannot translate it.
CommandDialog sets md:min-w-[800px]. The palette cannot be narrower than 800px on medium screens and above, and overflows small laptop windows.
CommandEmpty has no default text. An empty result shows a blank area unless you add a message.
filterOptions removes characters other than letters, digits, spaces and hyphens, so a search made only of punctuation (“.”, “/”) becomes empty. Typing only punctuation matches every item instead of none.
Disabled items use data-[disabled=true]:opacity-50. Translucent dimming rather than a disabled token, with lower contrast.
Edit this page on GitHub