# Kbd

> Displays keyboard keys and shortcuts with monospace font, border, and a raised 3D effect. Ideal for documenting keyboard shortcuts.

Source: https://vaneui.com/docs/basic-components/kbd

Import: `import { Kbd, Col, PageTitle, Row, SectionTitle, Text, Title } from "@vaneui/ui"`

Use Kbd for the keys a reader presses and [Code](/docs/basic-components/code) for inline source or literal values. Kbd renders the native `<kbd>` element, with a font one step smaller than Code at the same size. Its keycap edge comes from a bottom border twice as thick as the other three sides.

## Basic usage

Display keyboard keys with the `Kbd` component. Kbd defaults to a monospace font, a border, and `md` size.

```tsx demo
<Row flexWrap>
  <Kbd>Ctrl</Kbd>
  <Kbd>Shift</Kbd>
  <Kbd>Enter</Kbd>
  <Kbd>Esc</Kbd>
  <Kbd>Tab</Kbd>
</Row>
```

## Sizes

Kbd elements in different sizes: `xs`, `sm`, `md` (default), `lg`, `xl`.

```tsx demo
<Row flexWrap itemsEnd>
  <Col itemsCenter>
    <Kbd xs>Ctrl</Kbd>
    <Text sm secondary>xs</Text>
  </Col>
  <Col itemsCenter>
    <Kbd sm>Ctrl</Kbd>
    <Text sm secondary>sm</Text>
  </Col>
  <Col itemsCenter>
    <Kbd>Ctrl</Kbd>
    <Text sm secondary>md</Text>
  </Col>
  <Col itemsCenter>
    <Kbd lg>Ctrl</Kbd>
    <Text sm secondary>lg</Text>
  </Col>
  <Col itemsCenter>
    <Kbd xl>Ctrl</Kbd>
    <Text sm secondary>xl</Text>
  </Col>
</Row>
```

## Appearances

Different color appearances for keyboard keys.

```tsx demo
<Row flexWrap>
  <Kbd primary>Ctrl</Kbd>
  <Kbd accent>Alt</Kbd>
  <Kbd secondary>Tab</Kbd>
  <Kbd tertiary>Esc</Kbd>
  <Kbd success>Enter</Kbd>
  <Kbd danger>Del</Kbd>
  <Kbd warning>Fn</Kbd>
  <Kbd info>F5</Kbd>
</Row>
```

## Shapes

```tsx demo
<Row itemsCenter flexWrap>
  <Kbd>rounded, the default</Kbd>
  <Kbd sharp>sharp</Kbd>
  <Kbd pill>pill</Kbd>
</Row>
```

## Variants

Kbd is `outline` by default, which is what gives it the raised key edge. `filled` trades that for a solid block.

```tsx demo
<Row itemsCenter flexWrap>
  <Kbd>outline, the default</Kbd>
  <Kbd filled>filled</Kbd>
  <Kbd ghost>ghost</Kbd>
</Row>
```

## Key combinations

Combine multiple `Kbd` elements to show keyboard shortcuts.

```tsx demo
<Col>
  <Text><Kbd>Ctrl</Kbd> + <Kbd>C</Kbd> to copy</Text>
  <Text><Kbd>Ctrl</Kbd> + <Kbd>V</Kbd> to paste</Text>
  <Text><Kbd>Ctrl</Kbd> + <Kbd>Shift</Kbd> + <Kbd>P</Kbd> for the command palette</Text>
  <Text><Kbd>Alt</Kbd> + <Kbd>Tab</Kbd> to switch windows</Text>
</Col>
```

## In text context

Kbd elements blend naturally within text content.

```tsx demo
<Col>
  <Text>Press <Kbd>Ctrl</Kbd> + <Kbd>S</Kbd> to save your work.</Text>
  <Text>Use <Kbd sm>Esc</Kbd> to close the dialog.</Text>
  <Text>Hit <Kbd info>F5</Kbd> to refresh the page.</Text>
</Col>
```

## In heading context

Kbd uses an em-based geometry pipeline: its font-size, padding, and border-radius all scale proportionally to the surrounding text. The same `<Kbd>` keeps its keycap look at body, subheading, section heading, and page title sizes.

```tsx demo
<Col>
  <Text>Press <Kbd>Ctrl</Kbd> + <Kbd>S</Kbd> to save.</Text>
  <Title>Subheading: hit <Kbd>Esc</Kbd> to close.</Title>
  <SectionTitle>Section: use <Kbd>Tab</Kbd> to focus</SectionTitle>
  <PageTitle><Kbd>⌘</Kbd> + <Kbd>K</Kbd></PageTitle>
</Col>
```

## Shortcut table

Display a set of keyboard shortcuts in a structured layout.

```tsx demo
<Col>
  <Row justifyBetween><Text>Undo</Text><Text><Kbd>Ctrl</Kbd> + <Kbd>Z</Kbd></Text></Row>
  <Row justifyBetween><Text>Redo</Text><Text><Kbd>Ctrl</Kbd> + <Kbd>Shift</Kbd> + <Kbd>Z</Kbd></Text></Row>
  <Row justifyBetween><Text>Find</Text><Text><Kbd>Ctrl</Kbd> + <Kbd>F</Kbd></Text></Row>
  <Row justifyBetween><Text>Save</Text><Text><Kbd>Ctrl</Kbd> + <Kbd>S</Kbd></Text></Row>
  <Row justifyBetween><Text>Select all</Text><Text><Kbd>Ctrl</Kbd> + <Kbd>A</Kbd></Text></Row>
</Col>
```

## Props

| Prop | Category | Default | Description |
| --- | --- | --- | --- |
| `primary` | Appearance |  | Primary color appearance (gray) |
| `accent` | Appearance |  | Accent color appearance (rose) |
| `secondary` | Appearance | yes | Secondary color appearance (gray) |
| `tertiary` | Appearance |  | Tertiary color appearance |
| `success` | Appearance |  | Success color appearance (green) |
| `danger` | Appearance |  | Danger color appearance (red) |
| `warning` | Appearance |  | Warning color appearance (amber) |
| `info` | Appearance |  | Info color appearance (cyan) |
| `inheritAppearance` | Appearance |  | Inherit appearance from parent — suppresses own data-appearance/data-variant, uses parent's CSS variables |
| `disabled` | Disabled |  | Disable the component — reduces opacity, changes cursor to not-allowed, and prevents interaction |
| `flex1` | Flex |  | Take up remaining space (= `flex-1`, i.e. `flex: 1 1 0%`) |
| `flexAuto` | Flex |  | Grow but respect intrinsic size (= `flex-auto`, i.e. `flex: 1 1 auto`) |
| `flexNone` | Flex |  | Don't grow and don't shrink (= `flex-none`, i.e. `flex: none`) |
| `fontSans` | Font Family |  | Sans-serif font family (default) — emits font-sans |
| `fontSerif` | Font Family |  | Serif font family — emits font-serif |
| `fontMono` | Font Family | yes | Monospace font family — emits font-mono |
| `fontHeading` | Font Family |  | Heading font family (defaults to sans, customizable via --font-heading) — emits font-heading |
| `italic` | Font Style |  | Italic font style |
| `notItalic` | Font Style |  | Not italic (normal) font style |
| `fontThin` | Font Weight |  | Thin font weight (100) — emits font-thin |
| `fontExtralight` | Font Weight |  | Extra light font weight (200) — emits font-extralight |
| `fontLight` | Font Weight |  | Light font weight (300) — emits font-light |
| `fontNormal` | Font Weight |  | Normal font weight (400) — emits font-normal |
| `fontMedium` | Font Weight |  | Medium font weight (500) — emits font-medium |
| `fontSemibold` | Font Weight | yes | Semibold font weight (600) — emits font-semibold |
| `fontBold` | Font Weight |  | Bold font weight (700) — emits font-bold |
| `fontExtrabold` | Font Weight |  | Extra bold font weight (800) — emits font-extrabold |
| `fontBlack` | Font Weight |  | Black font weight (900) — emits font-black |
| `inheritSize` | Inherit Size |  | Inherit font-size and line-height from the nearest parent typography element |
| `noInheritSize` | Inherit Size |  | Keep own font-size; do not inherit from parent |
| `padding` | Padding | yes | Enable internal padding |
| `paddingX` | Padding |  | Enable only horizontal padding |
| `paddingY` | Padding |  | Enable only vertical padding |
| `noPadding` | Padding |  | Disable internal padding |
| `pill` | Shape |  | Fully rounded corners (circular) |
| `sharp` | Shape |  | No rounded corners (square) |
| `rounded` | Shape | yes | Medium rounded corners (default) |
| `noShrink` | Shrink |  | Prevent the flex item from shrinking below its content size (= `shrink-0`) |
| `xs` | Size |  | Extra small size |
| `sm` | Size |  | Small size |
| `md` | Size | yes | Medium size (default) |
| `lg` | Size |  | Large size |
| `xl` | Size |  | Extra large size |
| `skeleton` | Skeleton |  | Show the component as a loading placeholder in its own size and shape. On a container, every component inside it becomes a placeholder too |
| `textLeft` | Text Align |  | Align text to left (physical side, does not flip under RTL) |
| `textCenter` | Text Align |  | Align text to center |
| `textRight` | Text Align |  | Align text to right (physical side, does not flip under RTL) |
| `textJustify` | Text Align |  | Justify text |
| `textStart` | Text Align |  | Align text to the reading-direction start (left in LTR, right in RTL) |
| `textEnd` | Text Align |  | Align text to the reading-direction end (right in LTR, left in RTL) |
| `underline` | Text Decoration |  | Add underline decoration below text |
| `lineThrough` | Text Decoration |  | Add strikethrough/line-through decoration across text |
| `noUnderline` | Text Decoration |  | Remove ALL text-decoration — underline, line-through, and overline (text-decoration: none) |
| `overline` | Text Decoration |  | Add overline decoration above text |
| `uppercase` | Text Transform |  | Transform text to uppercase |
| `lowercase` | Text Transform |  | Transform text to lowercase |
| `capitalize` | Text Transform |  | Capitalize first letter of each word |
| `normalCase` | Text Transform |  | Normal text case (no transformation) |
| `filled` | Variant |  | Filled variant - solid background with contrasting text color |
| `outline` | Variant | yes | Outline variant - transparent background with border and colored text (default) |
| `ghost` | Variant |  | Ghost variant - transparent background, no border, appearance-colored text, tinted hover background |
| `breakNormal` | Word Break |  | Reset breaking - overflow-wrap and word-break normal |
| `breakWords` | Word Break |  | Break long words to prevent overflow - overflow-wrap: break-word |
| `breakAll` | Word Break |  | Break between any two characters - word-break: break-all |
| `breakKeep` | Word Break |  | Do not break CJK text - word-break: keep-all |

Layout and utility props (Border, Cursor, Display, Flex Direction, Focus Visible, Gap, Height, Hide, Items, Justify, Overflow, Position, Responsive Sizing, Responsive Width, Ring, Shadow, Show, Transition, Transparent, Whitespace, Width, Wrap) are listed on [Common Props](https://vaneui.com/docs/reference/common-props.md).
