Skip to main content

kbd

Used to display textual user input from keyboard.

Philosophy

Keyboard shortcuts deserve visual prominence. The Kbd component renders key combinations with consistent styling, making shortcut discovery a natural part of the UI rather than something hidden in documentation. We pair it with @gentleduck/vim for actual key binding — Kbd handles the display, vim handles the logic.

Installation


npx @gentleduck/cli add kbd

npx @gentleduck/cli add kbd

Usage

import { Kbd } from "@/components/ui/kbd"
import { Kbd } from "@/components/ui/kbd"
<Kbd>Ctrl</Kbd>
<Kbd>Ctrl</Kbd>

Examples

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.

API Reference

Kbd

Displays an individual keyboard key with consistent styling.

PropTypeDefaultDescription
dir'ltr' | 'rtl'--Text direction override. Resolved via useDirection (dir prop -> DirectionProvider -> 'ltr').
classNamestring--Additional class names for the kbd element
childrenReact.ReactNode--Key label text or icon
...propsReact.HTMLProps<HTMLElement>--Additional props to spread to the kbd element

KbdGroup

Groups multiple Kbd components together in an inline layout.

PropTypeDefaultDescription
classNamestring--Additional class names for the group
childrenReact.ReactNode--Kbd elements to group together
...propsReact.ComponentPropsWithoutRef<'div'>--Additional props to spread to the group element (renders as a kbd)

RTL Support

Direction is resolved through the shared primitives direction module. Use a local dir="rtl" override when the component exposes it, or set DirectionProvider at app/root level for global RTL/LTR behavior.