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.
Installation
Install the component via the CLI in one command.
npx @work-rjkashyap/unified-ui add kbdpnpm dlx @work-rjkashyap/unified-ui add kbdnpx @work-rjkashyap/unified-ui add kbdbunx @work-rjkashyap/unified-ui add kbdIf 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-uipnpm add @work-rjkashyap/unified-uiyarn add @work-rjkashyap/unified-uibun add @work-rjkashyap/unified-uiAnatomy
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.
| Size | Font Size | Padding |
|---|---|---|
sm | 10px | px-1.5 py-0.5 |
md | 12px | px-2 py-1 |
lg | 14px | px-2.5 py-1 |
Key Combinations
Chain multiple Kbd components with a separator to show shortcuts.
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.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
size | "sm" | "md" | "lg" | "md" | Size of the key badge. |
className | string | — | Additional CSS classes. |
children | ReactNode | — | Key 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-noneprevents accidental text selection.- Works with
aria-labelor surrounding text context for screen reader descriptions. - For interactive shortcut hints (e.g., in a search bar), wrap the hint in an
aria-hiddencontainer and provide a separate screen-reader description.
Design Tokens
| Token | Usage |
|---|---|
--muted | Key background |
--border | Key border and inset shadow |
--radius-md | Border radius |
--font-mono | Monospaced font for key labels |
Timeline
A vertical timeline component with icons, connectors, status indicators, and stagger animation. Ideal for activity feeds, changelogs, and process steps.
Code
Inline code and block code display components with syntax highlighting support, copy button, line numbers, filename label, and a dark variant.