Skip to content
Logic2BUI

Search docs

Search components and documentation

New
Menu

Command

Fast, composable command menu for React.

Installation

npx logic2b@next 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>

Usage notes

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

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.
  • CommandSeparator is decorative by default, which keeps it out of the listbox child-role contract while retaining its visual grouping.
  • CommandDialog traps focus, closes on Escape, and ships an sr-only title and description so screen readers announce the palette on open.

Live playground

Edit the component props and inspect the exact JSX before copying it. The preview loads only when this section enters the viewport.

Generated JSX
<Command
  className="w-full max-w-md border shadow-sm"
  aria-label="Component commands"
>
  <CommandInput
    placeholder="Search components…"
    aria-label="Search commands"
   />
  <CommandList>
    <CommandEmpty>No component found.</CommandEmpty>
    <CommandGroup
      heading="Components"
    >
      <CommandItem
        value="button"
      >Button</CommandItem>
      <CommandItem
        value="dialog"
      >Dialog</CommandItem>
      <CommandItem
        value="tooltip"
      >Tooltip</CommandItem>
    </CommandGroup>
  </CommandList>
</Command>

API reference

Generated from the public TypeScript exports in src/ui/command.tsx.

View JSON

Command

Component
Props: React.ComponentProps<typeof CommandPrimitive>

CommandDialog

Component
Props: React.ComponentProps<typeof Dialog> & { title?: string description?: string className?: string showCloseButton?: boolean }
PropTypeRequiredDefaultDescription
titlestringNo"Command Palette"—
descriptionstringNo"Search for a command to run..."—
showCloseButtonbooleanNotrue—

CommandInput

Component
Props: React.ComponentProps<typeof CommandPrimitive.Input>

CommandList

Component
Props: React.ComponentProps<typeof CommandPrimitive.List>

CommandEmpty

Component
Props: React.ComponentProps<typeof CommandPrimitive.Empty>

CommandGroup

Component
Props: React.ComponentProps<typeof CommandPrimitive.Group>

CommandItem

Component
Props: React.ComponentProps<typeof CommandPrimitive.Item>

CommandShortcut

Component
Props: React.ComponentProps<"span">

CommandSeparator

Component
Props: React.ComponentProps<typeof CommandPrimitive.Separator>

Accessibility contract

Machine-readable behavior and consumer responsibilities for command.

View JSON
Support
Primitive-managed
Pattern
combobox with listbox
cmdk
Keyboard interactions for command
KeysBehavior
ArrowUp ArrowDownMove through matching commands.
EnterRun the active command.
EscapeClose the open surface and restore focus.

Built-in semantics

  • The input and list coordinate with combobox/listbox semantics and active descendant state.

Consumer responsibilities

  • Give the dialog and input useful labels; commands must remain understandable without shortcut text.