Skip to content

shadcn.io is not affiliated with official shadcn/ui

Shadcn Kbd for React

Styled representation of a single key.

Ctrl+B

Installation

bunx --bun shadcn@latest add https://kit.dev/r/base/kbd.json

Usage

import { Kbd, KbdGroup } from "@/components/ui/kbd";
<div className="flex flex-col items-center gap-4">
  <KbdGroup>
    <Kbd>⌘</Kbd>
    <Kbd>⇧</Kbd>
    <Kbd>⌥</Kbd>
    <Kbd>⌃</Kbd>
  </KbdGroup>
  <KbdGroup>
    <Kbd>Ctrl</Kbd>
    <span>+</span>
    <Kbd>B</Kbd>
  </KbdGroup>
</div>

Demos

Group

Use the KbdGroup component to group keyboard keys together.

Button

Use the Kbd component inside a Button to display a keyboard key.

Tooltip

Use Kbd inside a Tooltip to show a keyboard shortcut.

Input Group

Use Kbd inside an InputGroupAddon to show a keyboard shortcut.

Rtl

Right-to-left kbd. See the RTL configuration guide for document direction.

API Reference

Kbd

PropType
AttributeType

KbdGroup

PropType
AttributeType