Kbd renders keyboard keys with a realistic keyboard shortcut appearance. Use KbdGroup to display key combinations.
Installation
npm install @soft-ui/react
Usage
import { Kbd, KbdGroup } from "@soft-ui/react/kbd"
<Kbd>⌘</Kbd>
<Kbd>K</Kbd>
// Or as a group
<KbdGroup keys={["⌘", "K"]} />
API Reference
Kbd
variant
'tertiary' | 'inverted'
default:"'tertiary'"
Visual style:
tertiary: Light background (default)
inverted: Dark background with white text
KbdGroup
Renders multiple keyboard keys with proper spacing.
Array of key labels to display
variant
'tertiary' | 'inverted'
default:"'tertiary'"
Visual style (applied to all keys)
Additional CSS classes for the container
Examples
Single Key
<Kbd>Esc</Kbd>
<Kbd>Enter</Kbd>
<Kbd>⌘</Kbd>
Key Combinations
<div className="flex items-center gap-2">
<Kbd>⌘</Kbd>
<Kbd>K</Kbd>
</div>
Using KbdGroup
<KbdGroup keys={["⌘", "K"]} />
<KbdGroup keys={["Ctrl", "Shift", "P"]} />
<KbdGroup keys={["↑", "↓"]} />
Inverted Variant
<div className="bg-content-strong p-4 rounded">
<KbdGroup keys={["⌘", "K"]} variant="inverted" />
</div>
Common Shortcuts
<div className="space-y-2">
<div className="flex items-center justify-between">
<span>Search</span>
<KbdGroup keys={["⌘", "K"]} />
</div>
<div className="flex items-center justify-between">
<span>Save</span>
<KbdGroup keys={["⌘", "S"]} />
</div>
<div className="flex items-center justify-between">
<span>Undo</span>
<KbdGroup keys={["⌘", "Z"]} />
</div>
<div className="flex items-center justify-between">
<span>Copy</span>
<KbdGroup keys={["⌘", "C"]} />
</div>
</div>
Arrow Keys
<div className="flex items-center gap-2">
<span>Navigate</span>
<KbdGroup keys={["↑", "↓", "←", "→"]} />
</div>
With Text
<p className="flex items-center gap-2">
Press <KbdGroup keys={["⌘", "K"]} /> to open the command palette
</p>
Special Characters
<div className="flex flex-wrap gap-2">
<Kbd>⌘</Kbd>
<Kbd>⌥</Kbd>
<Kbd>⇧</Kbd>
<Kbd>⌃</Kbd>
<Kbd>⏎</Kbd>
<Kbd>⌫</Kbd>
<Kbd>⇥</Kbd>
<Kbd>⎋</Kbd>
</div>