# Command

Fast, composable, command menu for React.

> For the complete documentation index, see [llms.txt](/llms.txt). Markdown variants are available by appending `.md` to any URL or sending an `Accept: text/markdown` header. An agent skill is available at [/.well-known/agent-skills/site-skill.md](/.well-known/agent-skills/site-skill.md).





<ComponentPreview name="command-demo" align="start">
  <CommandDemo />
</ComponentPreview>

## Installation [#installation]

<Tabs defaultValue="cli">
  <TabsList>
    <TabsTrigger value="cli">
      CLI
    </TabsTrigger>

    <TabsTrigger value="manual">
      Manual
    </TabsTrigger>
  </TabsList>

  <TabsContent value="cli">
    ```bash
    npx shadcn@latest add https://shadcn-cssinjs.com/r/command.json
    ```
  </TabsContent>

  <TabsContent value="manual">
    <Steps>
      <Step>
        Install the following dependencies:
      </Step>

      ```bash
      pnpm add cmdk @stylexjs/stylex
      ```

      <Step>
        Make sure [StyleX is configured](/docs/installation) and the design tokens are
        installed.
      </Step>

      <Step>
        Copy and paste the following code into your project.
      </Step>

      <ComponentSource name="command" title="command.tsx" />

      <Step>
        Update the import paths to match your project setup.
      </Step>
    </Steps>
  </TabsContent>
</Tabs>

## Usage [#usage]

```tsx
import {
  Command,
  CommandEmpty,
  CommandGroup,
  CommandInput,
  CommandItem,
  CommandList,
  CommandSeparator,
  CommandShortcut,
} from "@/components/ui/command/command";
```

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

## Composition [#composition]

Use the following composition to build a `Command`:

```txt
Command
├── CommandInput
└── CommandList
    ├── CommandEmpty
    ├── CommandGroup
    │   └── CommandItem
    │       └── CommandShortcut
    └── CommandSeparator
```

## Examples [#examples]

### Groups & Shortcuts [#groups--shortcuts]

Group related items with `CommandGroup` and annotate them with
`CommandShortcut`.

<ComponentPreview name="command-demo" align="start">
  <CommandDemo />
</ComponentPreview>



### Basic [#basic]

Use `CommandDialog` to render the command menu in a dialog.

<ComponentPreview name="command-basic" align="start">
  <CommandBasic />
</ComponentPreview>

### Shortcuts [#shortcuts]

<ComponentPreview name="command-shortcuts" align="start">
  <CommandShortcuts />
</ComponentPreview>

### Groups [#groups]

<ComponentPreview name="command-groups" align="start">
  <CommandGroups />
</ComponentPreview>

### Scrollable [#scrollable]

<ComponentPreview name="command-scrollable" align="start">
  <CommandScrollable />
</ComponentPreview>



## RTL [#rtl]

To enable right-to-left support, see the [RTL guide](/docs/rtl).

<ComponentPreview name="command-rtl" direction="rtl">
  <CommandRtl />
</ComponentPreview>

## API Reference [#api-reference]

See the [cmdk](https://github.com/pacocoursey/cmdk) documentation for more information.
