---
title: "Kbd"
description: "Shows a key or a shortcut in text, such as a search hint, a shortcut in a menu, or a key in help text."
url: https://gelatinui.com/components/kbd
markdown_url: https://gelatinui.com/components/kbd.md
access: free
install: "npx shadcn@latest add @gelatin-ui/kbd"
registry_item: https://gelatinui.com/r/kbd.json
version: "2026-11-08"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Kbd

> Shows a key or a shortcut in text, such as a search hint, a shortcut in a menu, or a key in help text.

Page: https://gelatinui.com/components/kbd

## When to use it

Best for: A key or a key combination in text: a search hint, a shortcut in a tooltip or a menu.

- Use it to show a key as people see it on the keyboard: "⌘", "Ctrl", "Esc", "Enter".
- Put keys that people press together in a `KbdGroup`. It has no plus sign.
- For keys pressed one after the other, put the word "then" between two keys.

## When not to use it

- Kbd does nothing on a click. For an action, use a [Button](https://gelatinui.com/components/button.md).

## Notes for agents

- Write the key as it shows on the keyboard: "⌘", "Ctrl", "Esc".
- Put keys pressed together in a `KbdGroup`; do not add a plus sign.

## Anatomy

```text
Kbd
└─ KbdGroup (0..n)
```

## API reference

### Kbd

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `size` | `"default" \| "lg"` | "default" |  |
| `variant` | `"default" \| "ghost"` | "default" |  |

### KbdGroup

No props of its own: `className`, `children`, and every other prop go to the element it renders.

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| Kbd | `kbd` |  |  |  |
| KbdGroup | `kbd-group` |  |  |  |

## Usage

Write the key as it shows on the keyboard: "⌘", "Ctrl", "Esc".

```tsx title="search-shortcut-hint.tsx"
import { Kbd, KbdGroup } from "@/components/ui/kbd";

export function SearchShortcutHint() {
  return (
    <p className="text-sm text-muted-foreground">
      Press{" "}
      <KbdGroup>
        <Kbd>⌘</Kbd>
        <Kbd>K</Kbd>
      </KbdGroup>{" "}
      to search, or <Kbd>Esc</Kbd> to close.
    </p>
  );
}
```

## Compose

Build it with:

- [Command](https://gelatinui.com/components/command.md): Holds the search field and the results.
- [Empty](https://gelatinui.com/components/empty.md): Shows when no result matches.

Rules:

- Every state is designed (`every-state`): Give each view of data its loading, empty, and error states: a skeleton in the final layout, an `Empty` with an illustration and one next action, and an error that says what failed and how to retry.
- Steady text weight (`steady-weight`): Never change the font weight on hover, focus, selected, active, or open; change the color or the fill, so the text does not jump.
- Sheets on phones (`phone-sheets`): Show a dialog or a large popover as a bottom sheet on a small screen.
- Compose the parts (`compose-parts`): Build each item from its named parts as children, and pass your text and icons in as parts.

Patterns: `gelatin://patterns/command-search`

## Add it

```bash
npx shadcn@latest add @gelatin-ui/kbd
```

It adds 2 registry items: 2 files, 94 lines, and the npm packages `clsx`, `tailwind-merge`, `tailwind-variants`.

## For AI agents

- Every item, one file: https://gelatinui.com/llms.txt
- MCP server (`search_items`, `get_item`, `get_install_plan`): https://gelatinui.com/mcp

## Related

- [Tooltip](https://gelatinui.com/components/tooltip.md)
- [Badge](https://gelatinui.com/components/badge.md)

## Accessibility

Kbd is the native `<kbd>`. It is not a button: it has no focus stop and takes no pointer events.

Kbd and `KbdGroup` set `dir="ltr"`, so "⌘ K" keeps its key order on a right-to-left page.
