# Kbd

Used to display textual user input from keyboard.

> 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="kbd-demo">
  <KbdDemo />
</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/kbd.json
    ```
  </TabsContent>

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

      ```bash
      pnpm add @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="kbd" title="kbd.tsx" />

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

## Usage [#usage]

```tsx
import { Kbd, KbdGroup } from "@/components/ui/kbd/kbd";
```

```tsx
<KbdGroup>
  <Kbd>⌘</Kbd>
  <Kbd>K</Kbd>
</KbdGroup>
```

## Composition [#composition]

Use the following composition to build a `Kbd`:

```txt
KbdGroup
├── Kbd
└── Kbd
```

## Examples [#examples]

### Group [#group]

Use `KbdGroup` to display a key combination inline with text.

<ComponentPreview name="kbd-group">
  <KbdGroupExample />
</ComponentPreview>



### Button [#button]

Use `Kbd` inside a `Button` to show a shortcut.

<ComponentPreview name="kbd-button">
  <KbdButton />
</ComponentPreview>

### Tooltip [#tooltip]

Show keyboard shortcuts inside a `Tooltip`.

<ComponentPreview name="kbd-tooltip">
  <KbdTooltip />
</ComponentPreview>



### Input Group [#input-group]

Use `Kbd` inside an `InputGroup` addon.

<ComponentPreview name="kbd-input-group">
  <KbdInputGroup />
</ComponentPreview>



## RTL [#rtl]

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

<ComponentPreview name="kbd-rtl" direction="rtl">
  <KbdRtl />
</ComponentPreview>

## API Reference [#api-reference]

### Kbd [#kbd]

Use the `Kbd` component to display a keyboard key.

| Prop        | Type     | Default |
| ----------- | -------- | ------- |
| `className` | `string` | -       |

### KbdGroup [#kbdgroup]

Use the `KbdGroup` component to group `Kbd` components together.

| Prop        | Type     | Default |
| ----------- | -------- | ------- |
| `className` | `string` | -       |
