# Command

Command menu for search and quick actions.

Section: Components / Overlays
Page: https://ui.heyramzi.com/components/command
Import path: `@heyramzi/ui/shadcn/command`

## Import

```ts
import * as Command from "@heyramzi/ui/shadcn/command";
```

## Usage

```svelte
<Command.Root>
  <Command.Input placeholder="Type a command or search..." />
  <Command.List>
    <Command.Empty>No results found.</Command.Empty>
    <Command.Group heading="Suggestions">
      <Command.Item>Calendar</Command.Item>
      <Command.Item>Search emoji</Command.Item>
    </Command.Group>
    <Command.Separator />
    <Command.Group heading="Settings">
      <Command.Item>
        Profile
        <Command.Shortcut>⌘P</Command.Shortcut>
      </Command.Item>
    </Command.Group>
  </Command.List>
</Command.Root>
```

## Demo

```svelte
<script lang="ts">
	import { Calculator, CalendarBlank, CreditCard, Gear, Smiley, User } from "phosphor-svelte";
	import * as Command from "@heyramzi/ui/shadcn/command";
</script>

<Command.Root class="rounded-lg border shadow-md md:min-w-[450px]">
	<Command.Input placeholder="Type a command or search..." />
	<Command.List>
		<Command.Empty>No results found.</Command.Empty>
		<Command.Group heading="Suggestions">
			<Command.Item>
				<CalendarBlank aria-hidden="true" />
				<span>Calendar</span>
			</Command.Item>
			<Command.Item>
				<Smiley aria-hidden="true" />
				<span>Search Emoji</span>
			</Command.Item>
			<Command.Item disabled>
				<Calculator aria-hidden="true" />
				<span>Calculator</span>
			</Command.Item>
		</Command.Group>
		<Command.Separator />
		<Command.Group heading="Settings">
			<Command.Item>
				<User aria-hidden="true" />
				<span>Profile</span>
				<Command.Shortcut>⌘P</Command.Shortcut>
			</Command.Item>
			<Command.Item>
				<CreditCard aria-hidden="true" />
				<span>Billing</span>
				<Command.Shortcut>⌘B</Command.Shortcut>
			</Command.Item>
			<Command.Item>
				<Gear aria-hidden="true" />
				<span>Settings</span>
				<Command.Shortcut>⌘S</Command.Shortcut>
			</Command.Item>
		</Command.Group>
	</Command.List>
</Command.Root>
```

## API

### Command.Root

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `api` | `CommandRootApi \| null` | `null` | bindable |
| `ref` | `HTMLElement \| null` | `null` | bindable |
| `value` | `string` | `""` | bindable |
| `class` | `string` |  |  |

Every prop of `Command.Root` from `bits-ui`.

### Command.Input

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `wrapperClass` | `string` |  | Classes for the row that holds the glyph, the field and `trailing`. |
| `size` | `"default" \| "lg"` | `"default"` | `lg` is the standalone search header; `default` is a combobox popover. |
| `trailing` | `Snippet` |  | Right-aligned affordances: a dismiss hint, a close button, a scope chip. |
| `ref` | `HTMLElement \| null` | `null` | bindable |
| `class` | `string` |  |  |
| `value` | `string` | `""` | bindable |

Every prop of `Command.Input` from `bits-ui`, except `size`.

### Command.List

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `ref` | `HTMLElement \| null` | `null` | bindable |
| `class` | `string` |  |  |
| `children` | `Snippet` |  |  |

Every prop of `Command.List` from `bits-ui`.

### Command.Empty

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `ref` | `HTMLElement \| null` | `null` | bindable |
| `class` | `string` |  |  |

Every prop of `Command.Empty` from `bits-ui`.

### Command.Group

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `heading` | `string` |  |  |
| `ref` | `HTMLElement \| null` | `null` | bindable |
| `class` | `string` |  |  |
| `children` | `Snippet` |  |  |
| `value` |  |  |  |

Every prop of `Command.Group` from `bits-ui`.

### Command.Item

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `ref` | `HTMLElement \| null` | `null` | bindable |
| `class` | `string` |  |  |
| `children` | `Snippet` |  |  |

Every prop of `Command.Item` from `bits-ui`.

### Command.Separator

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `ref` | `HTMLElement \| null` | `null` | bindable |
| `class` | `string` |  |  |

Every prop of `Command.Separator` from `bits-ui`.

### Command.Shortcut

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `ref` | `HTMLElement \| null` | `null` | bindable |
| `class` | `string` |  |  |
| `children` | `Snippet` |  |  |

Every prop of `HTMLAttributes<HTMLElement>` from `svelte/elements`.

### Command.Dialog

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `portalProps` | `DialogPrimitive.PortalProps` |  |  |
| `children` | `Snippet` |  | required |
| `title` | `string` | `"Command Palette"` |  |
| `description` | `string` | `"Search for a command to run..."` |  |
| `showCloseButton` | `boolean` | `false` |  |
| `closeLabel` | `string` | `"Close"` | What a screen reader calls the close button, in the app's language. |
| `class` | `string` |  |  |
| `open` | `boolean` | `false` | bindable |
| `ref` | `HTMLElement \| null` | `null` | bindable |
| `value` | `string` | `""` | bindable |

Every prop of `Dialog.Root` from `bits-ui`, except `child, children`.

Every prop of `Command.Root` from `bits-ui`, except `child, children`.

### Command.LinkItem

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `ref` | `HTMLElement \| null` | `null` | bindable |
| `class` | `string` |  |  |

Every prop of `Command.LinkItem` from `bits-ui`.

### Command.Loading

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `ref` | `HTMLElement \| null` | `null` | bindable |

Every prop of `Command.Loading` from `bits-ui`.
