Black Friday is here šŸ”„ Get Wensity Pro for 20% less with

Kbd

A React kbd component that renders real kbd tags for keyboard shortcuts, with key combinations, key sequences, command rows, and an inline size.

Loading preview

Examples

Practical examples and common states for the same installable component.

Shortcut

Combine multiple keys into a shortcut using the keys prop.

examples/kbd-shortcut.tsx
import { Kbd } from "@/components/wensity/kbd";
export function ShortcutKeys() {
return (
<div className="flex flex-wrap items-center gap-3">
<Kbd keys={["⌘", "K"]} />
<Kbd keys={["⌘", "Shift", "P"]} />
<Kbd keys={["Ctrl", "D"]} />
</div>
);
}

Inline

Embed keyboard hints inside paragraph text.

examples/kbd-inline.tsx
import { Kbd } from "@/components/wensity/kbd";
export function InlineKeys() {
return (
<div className="max-w-sm text-sm leading-relaxed">
<p className="mb-2">
Press <Kbd inline>⌘</Kbd><Kbd inline>J</Kbd> to toggle the terminal.
</p>
<p>
Hold <Kbd inline>⌄</Kbd> and click to add a new cursor.
</p>
</div>
);
}

Sequence

Show keys pressed in a specific order.

examples/kbd-sequence.tsx
import { Kbd } from "@/components/wensity/kbd";
export function KeySequence() {
return (
<Kbd.Sequence>
<Kbd>⌘</Kbd><Kbd>K</Kbd>
<span className="px-1 text-[11px] text-neutral-500">then</span>
<Kbd>G</Kbd>
</Kbd.Sequence>
);
}

Command

Application commands with labelled shortcuts.

examples/kbd-command.tsx
import { Kbd } from "@/components/wensity/kbd";
export function CommandList() {
return (
<div className="flex w-full max-w-xs flex-col gap-2">
<Kbd.Command keys={["⌘", "K"]}>Toggle Search</Kbd.Command>
<Kbd.Command keys={["⌘", "Shift", "P"]}>Command Palette</Kbd.Command>
<Kbd.Command keys={["⌘", "B"]}>Toggle Sidebar</Kbd.Command>
</div>
);
}

Overview

Kbd is a React and Tailwind CSS keyboard key component, in Next.js or any React app, that renders real kbd elements, the HTML tag meant for keyboard input. Pass a keys array and it draws each key with a plus between them for a combination like Cmd plus K. Kbd.Sequence lays out keys pressed one after another, Kbd.Command pairs an action label with its shortcut for menus and help panels, and the inline option shrinks it to sit inside running text. It only displays keys, so wire the actual shortcut with your own keydown listener.

Installation

Run the following command

~/your-project
pnpm dlx wensity@latest add kbd

Usage

Import Kbd from @/components/wensity/kbd and render it anywhere in your React or Next.js app. The source lands in your own repo, so every prop, class and animation below is yours to edit.

app/example.tsx
import { Kbd } from "@/components/wensity/kbd";
export function KbdDemo() {
return (
<div className="flex items-center gap-1.5">
<Kbd>⌘</Kbd>
<Kbd>K</Kbd>
</div>
);
}

Props

PropTypeDefaultDescription
childrenReact.ReactNode-A single key, such as the command symbol, Ctrl, or K.
keysstring[]-Several keys rendered as one combined shortcut.
inlineboolean-Tighter styling for use inside a line of text.
size"sm" | "md"-Key cap size.
  • Mechanical Keyboard component preview

    Mechanical Keyboard

    A 75 percent mechanical keyboard with sculpted keycaps and recorded switch sound.

  • Magic Keyboard component preview

    Magic Keyboard

    A Mac keyboard with three finishes, a latching caps LED, and ANSI or ISO layouts.

  • Tactile Keyboard component preview

    Tactile Keyboard

    A 65% QWERTY board with real key travel, live shift legends, and five colorways.

  • Animated Terminal component preview

    Animated Terminal

    A terminal UI with self-typing commands, CRT phosphor glow and scanlines, streaming output that never re-renders a line.