---
title: "Command · Ark UI — StyleX Blocks"
description: "Keyboard shortcut groups that space and mute a row of key hints."
url: "https://stylexblocks.com/components/ark-ui/command/"
agent:
  instructions: "Use this search API to find relevant components and blocks across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://stylexblocks.com/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Command

Keyboard shortcut groups that space and mute a row of key hints.

- Behavior engine: Ark UI
- Also available for: [Base UI](https://stylexblocks.com/components/base-ui/command.md), [UI SDK](https://stylexblocks.com/components/ui-sdk/command.md)
- Category: Form
- Sizes: xs, sm, md, lg
- HTML page: https://stylexblocks.com/components/ark-ui/command/

## Install

Configure the project once (sets the behavior engine and import aliases):

```sh
npx stylexblocks init
```

Then add the item as source you own:

```sh
npx stylexblocks add command
```

Equivalent: `npx shadcn add @stylexblocks/command`. Registry item JSON: https://stylexblocks.com/r/ark-ui/command.json

## Usage

```tsx
import * as stylex from "@stylexjs/stylex";
import { Command } from "#components/ui/ark-ui/command.tsx";
import { kbdSizes, kbdStyles, kbdVariants } from "@stylexblocks/ui/recipes/kbd.ts";

export function Example() {
  return (
    // the size prop resolves through the StyleX recipe; composition via asChild
    <Command size="sm">
      <kbd {...stylex.props(kbdStyles.base, kbdSizes.sm, kbdVariants.raised)}>⌘</kbd>
      <kbd {...stylex.props(kbdStyles.base, kbdSizes.sm, kbdVariants.raised)}>K</kbd>
    </Command>
  );
}
```

## Source

`components/ui/ark-ui/command.tsx`

```tsx
import * as stylex from "@stylexjs/stylex";
import { createComponent } from "#lib/ark-ui/create-component.tsx";
import { defineRecipe } from "#lib/recipe-props.ts";
import { fontSizes } from '@stylexblocks/ui/tokens/font-sizes.stylex.ts'
import { semanticColors } from '@stylexblocks/ui/semantic-tokens/colors.stylex.ts'
import { spacing } from '@stylexblocks/ui/tokens/spacing.stylex.ts'

const commandStyles = stylex.create({
  base: {
    display: 'inline-flex',
    gap: spacing._1,
    color: semanticColors.fgMuted,
  },
})

const commandSizes = stylex.create({
  xs: {
    fontSize: fontSizes._2xs,
  },
  sm: {
    fontSize: fontSizes.xs,
  },
  md: {
    fontSize: fontSizes.sm,
  },
  lg: {
    fontSize: fontSizes.md,
  },
})

export type CommandSize = keyof typeof commandSizes

/**
 * Command — a keyboard-shortcut group that spaces and mutes a row of key
 * hints (usually `<Kbd>` children). The size prop resolves mechanically from
 * the recipe's size map. Composition via `asChild`.
 */
const commandRecipe = defineRecipe({
  styles: commandStyles,
  axes: { size: commandSizes },
  defaultVariants: { size: "sm" },
});

export const Command = createComponent("span", commandRecipe, "Command");

export type CommandProps = React.ComponentProps<typeof Command>;
```
