Skip to content

Search Fields

Command is a filterable, keyboard-driven list built on cmdk. It pairs a search input with grouped, selectable items that filter as the user types, which makes it the building block for both inline search fields and the global command palette. Wrap it in CommandDialog to launch it as a modal palette from a keyboard shortcut.

Live demo

The interactive story below runs from the deployed Storybook.

Usage

Source: command.tsx

import {
Command,
CommandEmpty,
CommandGroup,
CommandInput,
CommandItem,
CommandList,
CommandSeparator,
} from "@beacon/design-system";
<Command className="rounded-lg border shadow-md w-[350px]">
<CommandInput placeholder="Type a command or search..." />
<CommandList>
<CommandEmpty>No results found.</CommandEmpty>
<CommandGroup heading="Suggestions">
<CommandItem>Calendar</CommandItem>
<CommandItem>Search Emoji</CommandItem>
<CommandItem>Calculator</CommandItem>
</CommandGroup>
<CommandSeparator />
<CommandGroup heading="Settings">
<CommandItem>Profile</CommandItem>
<CommandItem>Billing</CommandItem>
<CommandItem>Settings</CommandItem>
</CommandGroup>
</CommandList>
</Command>

To launch it as a modal palette, wrap the same children in CommandDialog and drive its open state from a keyboard shortcut.

Parts

PartRole
CommandRoot container that owns the filter state and renders the list.
CommandDialogWraps Command in a modal dialog. Accepts the dialog’s open and onOpenChange props.
CommandInputThe search input, prefixed with a search icon. Typing filters the items.
CommandListScrollable region that holds the groups, items, and empty state.
CommandEmptyShown when the query matches no items.
CommandGroupA labeled section of items; set the label with the heading prop.
CommandItemA selectable row. Disable with disabled; handle selection via onSelect.
CommandSeparatorA divider between groups.
CommandShortcutA right-aligned hint for the item’s keyboard shortcut.

When to use

  • A global command palette launched by a keyboard shortcut for jumping to records and actions.
  • An inline, filterable picker where the option set is long enough to need search.
  • Quick-switcher style navigation between entities (projects, liens, tenants).

Do not use Command for free-form text entry that is not a search; reach for a plain text input instead.