Free shadcn/ui kbd component for React to display keyboard shortcuts and key hints in menus, tooltips, and command triggers. Copy or install in one command.

Installation

1 Configure registry — once per project
{
  "registries": {
    "@designrevision": "https://registry.designrevision.com/r/{name}.json"
  }
}

Add to your existing components.json. Requires shadcn/ui v2.3+.

2 Install the component

Packages

utils

Props

No props documented yet.

Copied!
components/ui/kbd.tsx
import * as React from "react"

import { cn } from "@/lib/utils"

function Kbd({ className, ...props }: React.ComponentProps<"kbd">) {
  return (
    <kbd
      className={cn(
        "pointer-events-none inline-flex h-5 select-none items-center gap-1 rounded border bg-muted px-1.5 font-mono text-[10px] font-medium text-muted-foreground",
        className
      )}
      {...props}
    />
  )
}

export { Kbd }

Examples

Keys and shortcuts

Single keys and a key combination — render one Kbd per key and group them for a shortcut.

Packages

kbd

Props

No props documented yet.

Copied!
components/ui/kbd-keys-01.tsx
import { Kbd } from "@/components/ui/kbd"

export default function KbdKeys01() {
  return (
    <div className="flex flex-wrap items-center gap-3">
      <Kbd>⌘</Kbd>
      <Kbd>⇧</Kbd>
      <Kbd>⌥</Kbd>
      <Kbd>↵</Kbd>
      <Kbd>Esc</Kbd>
      <span className="flex items-center gap-1">
        <Kbd>⌘</Kbd>
        <Kbd>K</Kbd>
      </span>
    </div>
  )
}

Frequently asked questions

The kbd component renders a keyboard key or shortcut hint, like Command K. Use it in menus, tooltips, and command triggers to show users the shortcut for an action.
Render one Kbd per key and place them side by side, for example a Command key followed by a K. Group them in a flex container with a small gap for clean spacing.