Skip to content
Redpanda UI
Esc
↑↓navigate↵open⌘Jpreview
Made by shadcn
Edit on GitHub

Kbd

Used to display textual user input from keyboard.

Installation

bash
npx shadcn@latest add @redpanda/kbd
bash
pnpm dlx shadcn@latest add @redpanda/kbd
bash
yarn dlx shadcn@latest add @redpanda/kbd
bash
bunx shadcn@latest add @redpanda/kbd
bash
nubx shadcn@latest add @redpanda/kbd
bash
aube dlx shadcn@latest add @redpanda/kbd

When to use

The Kbd component displays keyboard keys and shortcuts in a styled format. Use this decision tree to determine when it’s appropriate:

Usage

tsx
<Kbd>  <Command /> +K</Kbd>

Anatomy

The Kbd component displays keyboard keys in a styled format. Here’s how the components work together:

tsx
<Kbd>          {/* Container styled as a keyboard key */}  <Command />  {/* Optional icon (⌘, Ctrl, Shift, etc.) */}  +K           {/* Key text or combination */}</Kbd>
<KbdGroup>     {/* Groups multiple keys together */}  <Kbd>⌘</Kbd>  <Kbd>K</Kbd></KbdGroup>

Layout Structure

  • Kbd: Root component with keyboard key styling (border, padding, rounded corners)
  • KbdGroup: Flex container that groups multiple Kbd components with proper spacing

Typical Usage Patterns

tsx
// Single key<Kbd>K</Kbd>
// Combination with icon<Kbd><Command /> K</Kbd>
// Multiple keys in sequence<KbdGroup>  <Kbd>Ctrl</Kbd>  <Kbd>Shift</Kbd>  <Kbd>P</Kbd></KbdGroup>
// In button<Button>  Search <Kbd className="ml-2">⌘K</Kbd></Button>
// In tooltip<TooltipContent>  <p>Search</p>  <Kbd><Command /> K</Kbd></TooltipContent>
// In input group<InputGroup>  <InputGroupInput placeholder="Search..." />  <InputGroupAddon>    <Kbd>⌘K</Kbd>  </InputGroupAddon></InputGroup>

Examples

Default

Group

Use the KbdGroup component to group keyboard keys together.

Button

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

Tooltip

You can use the Kbd component inside a Tooltip component to display a tooltip with a keyboard key.

Input Group

You can use the Kbd component inside a InputGroupAddon component to display a keyboard key inside an input group.

Props

Credits

  • We take our inspiration from Shadcn UI for the kbd component and style.

Recent changes

  • patchv1.2.0Pin shipped dependency floors to the version we develop against. Registry items now declare ranges like `^5.1.9` (the actual installed version) instead of collapsing to `^5.0.0`, so consumers start on the known-tested baseline while caret semantics still allow any compatible release within the same major.#133
  • minorv1.1.0Theme docs refresh, readability pass on semantic foregrounds, and consumer-facing Base UI regression fixes.#121
  • minorv1.0.0Post-Base-UI polish. Public API unchanged.#116
  • majorv1.0.0Migrate every Radix-based primitive to `@base-ui/react@^1.4.0` (Base UI).#114
  • minorv0.3.0Add theme-provider component to the registry with documentation and tests. Includes playground type improvements (export RegistryItem, remove as-const boilerplate) and docs site dark mode border color fix.#109
See full history →

Last updated on

Was this page helpful?