Skip to Content
⭐️ Leave a star →
ComponentsCommand

Command

A command palette (cmdk/kbar-style): grouped, filterable actions with keyboard navigation and an optional global hotkey. Distinct from Combobox — it selects actions, not form values.

Features

Case-insensitive substring filtering, or a custom filter matcher.
Per-item keywords to broaden what each item matches.
Arrow-key navigation with optional looping and an Command.Empty fallback.
Groups hide automatically when none of their items match.
Optional toggleable palette with a global shortcut hotkey (e.g. mod+k).
Controlled or uncontrolled search query and open state.

Example

import { Command } from '@wire-ui/react' <Command.Root> <Command.Input placeholder="Type a command or search…" /> <Command.List> <Command.Empty>No results found.</Command.Empty> <Command.Group heading="Suggestions"> <Command.Item value="New File" keywords={['create']}>New File</Command.Item> <Command.Item value="Search Docs">Search Docs</Command.Item> </Command.Group> <Command.Separator /> <Command.Group heading="Settings"> <Command.Item value="Profile">Profile</Command.Item> <Command.Item value="Billing" disabled>Billing</Command.Item> </Command.Group> </Command.List> </Command.Root>

Styling

Items expose data-active (the keyboard/pointer-highlighted item) and data-disabled. Hovering or arrow-keying moves the active item; style it as the highlight. Groups whose items are all filtered out get the native hidden attribute — collapse them with [&[hidden]]:hidden if needed. The heading prop renders a labelled element for the group; you can also render your own visible heading inside the group.

<Command.Item value="Profile" className=" text-black data-[active]:bg-[#f5f5f5] data-[disabled]:opacity-40 data-[disabled]:cursor-not-allowed "> Profile </Command.Item>

Using data attributes

/* Highlighted (active) item */ [data-active] { background: #f5f5f5; } /* Disabled item */ [data-disabled] { opacity: 0.4; cursor: not-allowed; }

Root props

PropTypeDefaultDescription
searchValuestringControlled search query
defaultSearchValuestring''Initial search query (uncontrolled)
onSearchChange(value: string) => voidCalled when the query changes
filter(value: string, search: string, keywords: string[]) => booleansubstring matchCustom matcher
onSelect(value: string) => voidCalled when any item is selected, with its value
loopbooleantrueWrap active-item navigation
openbooleanControlled open state (toggleable palette)
defaultOpenbooleanInitial open state
onOpenChange(open: boolean) => voidCalled when the open state changes
shortcutstringGlobal hotkey (e.g. 'mod+k') that toggles open

Group props

PropTypeDescription
headingReactNodeOptional heading rendered above the group’s items

Item props

PropTypeDefaultDescription
valuestringrequiredUnique value — used as identity and default search text
keywordsstring[]Extra terms to match against
disabledbooleanfalseDisable this item
onSelect(value: string) => voidCalled when this item is chosen

Data attributes

AttributeElementValues
data-command-rootRootPresent on the root element
data-activeItemPresent on the active (highlighted) item
data-disabledItemPresent when the item is disabled
data-command-group-headingGroup headingPresent on the rendered heading element

Accessibility

  • Input renders as role="combobox" with aria-expanded, aria-controls pointing at the list, and aria-activedescendant tracking the active item.
  • List renders as role="listbox"; items as role="option" with aria-selected and aria-disabled.
  • Groups render as role="group" (with aria-labelledby when a heading is set); separators as role="separator".

Keyboard Interactions

KeyDescription
ArrowDownMove the active item down.
ArrowUpMove the active item up.
EnterSelect the active item.
EscapeClose the palette (when used as a toggleable palette).
shortcut (e.g. K)Toggle the palette open/closed when shortcut is set.
Last updated on

MIT License © 2026 wire-ui

Command – Wire UI