Unified UI

Kbd

A keyboard shortcut display component for rendering key combinations in a monospaced, styled element.

Basic

Displays keyboard keys and shortcuts in a styled, monospaced element with a tactile inset shadow.

+K
Ctrl+S
Shift+Enter

Installation

Install the component via the CLI in one command.

npx @work-rjkashyap/unified-ui add kbd
pnpm dlx @work-rjkashyap/unified-ui add kbd
npx @work-rjkashyap/unified-ui add kbd
bunx @work-rjkashyap/unified-ui add kbd

If you haven't initialized your project yet, run npx @work-rjkashyap/unified-ui init first. See the CLI docs for details.

Or install the full package

Use this approach if you prefer to install the entire design system as a dependency instead of copying individual components.

npm install @work-rjkashyap/unified-ui
pnpm add @work-rjkashyap/unified-ui
yarn add @work-rjkashyap/unified-ui
bun add @work-rjkashyap/unified-ui

Anatomy

import { Kbd } from "@work-rjkashyap/unified-ui";

Basic Usage

Wrap any key name or symbol in <Kbd> to render it as a styled keyboard key.

<Kbd>Enter</Kbd>
<Kbd>Escape</Kbd>
<Kbd>⌘</Kbd>
<Kbd>⇧</Kbd>
<Kbd>Tab</Kbd>

Sizes

Three sizes are available. The default is md.

+K
+K
+K
SizeFont SizePadding
sm10pxpx-1.5 py-0.5
md12pxpx-2 py-1
lg14pxpx-2.5 py-1

Key Combinations

Chain multiple Kbd components with a separator to show shortcuts.

Command palette
+K
Save file
Ctrl+S
Select all
+A
Undo
+Z

Inline Usage

Kbd is an inline element — it works naturally inside paragraphs and labels.

<p className="text-sm text-muted-foreground">
  Press <Kbd>⌘</Kbd> + <Kbd>K</Kbd> to open the command palette.
</p>

<p className="text-sm text-muted-foreground">
  Use <Kbd>Tab</Kbd> to move focus between fields and <Kbd>Enter</Kbd> to submit.
</p>

Shortcuts Table

A common pattern is a keyboard shortcuts reference table.

Keyboard Shortcuts
Command palette
+K
Quick search
+P
Save
+S
Undo
+Z
Redo
++Z

Props

PropTypeDefaultDescription
size"sm" | "md" | "lg""md"Size of the key badge.
classNamestringAdditional CSS classes.
childrenReactNodeKey label or symbol.

All standard <kbd> HTML attributes are also accepted.

Accessibility

  • Renders as a semantic <kbd> HTML element, which screen readers announce as "keyboard input."
  • select-none prevents accidental text selection.
  • Works with aria-label or surrounding text context for screen reader descriptions.
  • For interactive shortcut hints (e.g., in a search bar), wrap the hint in an aria-hidden container and provide a separate screen-reader description.

Design Tokens

TokenUsage
--mutedKey background
--borderKey border and inset shadow
--radius-mdBorder radius
--font-monoMonospaced font for key labels

On this page