Skip to content
Logic2BUI

Search docs

Search components and documentation

New
Menu

Command

Fast, composable command menu for React.

Installation

npx logic2b@latest add command

Usage

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

<Command>
  <CommandInput placeholder="Type a command or search..." />
  <CommandList>
    <CommandEmpty>No results found.</CommandEmpty>
    <CommandGroup heading="Suggestions">
      <CommandItem>Calendar</CommandItem>
    </CommandGroup>
  </CommandList>
</Command>

CommandDialog

Use CommandDialog to render the command menu inside a modal (cmd+k style). It depends on the dialog component.

import { CommandDialog, CommandInput, CommandList } from "@/components/ui/command"

<CommandDialog open={open} onOpenChange={setOpen}>
  <CommandInput placeholder="Type a command or search..." />
  <CommandList>...</CommandList>
</CommandDialog>

API

Built on cmdk. Props flow through to the underlying primitives.

Prop Type Default
shouldFilter (Command) boolean — filter items automatically as you type true
filter (Command) (value, search, keywords) => number — custom scoring
value / onValueChange (Command) string / (value: string) => void — control the highlighted item
value (CommandItem) string — value used for filtering text content
onSelect (CommandItem) (value: string) => void
disabled (CommandItem) boolean false
title / description (CommandDialog) string — accessible labels for the dialog Command Palette / Search for a command to run...
showCloseButton (CommandDialog) boolean true

Examples

With Icons

Command Dialog

Render the menu inside a modal and toggle it with a keyboard shortcut.

Press
J
or .

Command Palette

Search for a command to run...

Accessibility

  • Fully keyboard driven: the arrow keys move between items, Enter runs the highlighted item, and Home / End jump to the ends of the list.
  • CommandInput is a combobox that owns the list via aria-activedescendant, so focus stays in the input while items are announced as active.
  • CommandDialog traps focus, closes on Escape, and ships an sr-only title and description so screen readers announce the palette on open.