# Command

> An inline, searchable list of commands.

- Category: [Overlays](https://tarve.dev/docs.md#overlays)
- Import: `import { Command } from "@tarve/core";`
- Props type: `CommandProps`
- Source: [packages/core/src/popups.ts:649](https://github.com/omarcosr/tarve/blob/main/packages/core/src/popups.ts#L649)

## Usage

```tsx title="Command.tsx"
import { Command } from "@tarve/core";

let query = "";

<Command
  id="commands"
  query={query}
  items={[
    { value: "new", label: "New file", icon: "plus", shortcut: "Ctrl+N", group: "File" },
    { value: "settings", label: "Open settings", icon: "settings", group: "App" },
  ]}
  onQueryChange={(next) => {
    query = next;
  }}
  onSelect={(value) => console.log(value)}
/>
```

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `id` (required) | `string` | — |  |
| `items` (required) | `readonly CommandItem[]` | — |  |
| `query` (required) | `string` | — |  |
| `emptyText` | `string` | `"No results found."` |  |
| `onEscape` | `() => void` | — |  |
| `onQueryChange` | `(query: string) => void` | — |  |
| `onSelect` | `(value: string) => void` | — |  |
| `onValueChange` | `(value: string) => void` | — |  |
| `placeholder` | `string` | `"Type a command or search..."` |  |
| `value` | `string` | — |  |

## Common props

Shared by every component (descriptions: https://tarve.dev/docs.md#common-props): `children`, `class`, `className`, `highlight`, `key`, `motionFrom`, `onHighlight`, `onPaste`, `onPointerLeave`, `onPointerMove`, `onSize`, `onTransitionEnd`, `rovingGroup`, `style`.

## Types

```ts title="CommandItem"
interface CommandItem {
  value: string;
  label: string;
  keywords?: readonly string[];
  icon?: IconName;
  group?: string;
  shortcut?: string;
  disabled?: boolean;
}
```

Previous: [ContextMenu](https://tarve.dev/docs/components/ContextMenu.md) · Next: [CommandPalette](https://tarve.dev/docs/components/CommandPalette.md)

---

Tarve v0.13.8 · HTML version: https://tarve.dev/docs/components/Command · Index for agents: https://tarve.dev/llms.txt
