Kbd
Keyboard shortcut display that renders key combinations with platform-appropriate symbols. Accepts a ’+’ separated key string.
import { Kbd } from "phoundry-ui";Basic Shortcuts
Loading interactive example…
View source
<script lang="ts"> import { Kbd } from "phoundry-ui";</script>
<div class="flex items-center gap-4"> <Kbd keys="Mod+S" /> <Kbd keys="Enter" /> <Kbd keys="Escape" /></div>Modifier Combos
Loading interactive example…
View source
<script lang="ts"> import { Kbd } from "phoundry-ui";</script>
<div class="flex items-center gap-4"> <Kbd keys="Mod+Shift+K" /> <Kbd keys="Ctrl+Alt+Delete" /> <Kbd keys="Mod+Z" /></div>Arrow keys
Loading interactive example…
View source
<script lang="ts"> import { Kbd } from "phoundry-ui";</script>
<p class="mb-2 text-xs text-txt-secondary"> Direction tokens map to arrows on macOS glyphs.</p><div class="flex flex-wrap items-center gap-3"> <Kbd keys="Up" /> <Kbd keys="Down" /> <Kbd keys="Left" /> <Kbd keys="Right" /></div>Sizes
Loading interactive example…
View source
<script lang="ts"> import { Kbd } from "phoundry-ui";</script>
<div class="flex items-center gap-4"> <span class="text-xs text-txt-tertiary">sm:</span> <Kbd keys="Mod+K" size="sm" /> <span class="text-xs text-txt-tertiary">md:</span> <Kbd keys="Mod+K" size="md" /></div>Variants
Loading interactive example…
View source
<script lang="ts"> import { Kbd } from "phoundry-ui";</script>
<div class="flex items-center gap-4"> <Kbd keys="Mod+K" variant="filled" /> <Kbd keys="Mod+K" variant="ghost" /></div>API
From phoundry-ui@0.4.21
| Name | Type | Default | Description |
|---|---|---|---|
keysrequired | string | — | Key combo string with "+" separator, e.g. "Mod+Shift+K". |
size | "sm" | "md" | 'sm' | Keycap height from shared control tokens: sm 1.5rem, md 1.75rem. |
variant | KbdVariant | 'filled' | Filled keycaps or a transparent ghost treatment. |
class | ClassValue | — | Additional CSS classes. |
style | string | — | Inline styles on the stable component root. |
Usage tips
Modresolves to ⌘ on macOS and Ctrl on other platforms.- Keys are automatically uppercased and mapped to platform glyphs (e.g. ⇧ for Shift on Mac).
- Pair with command palette items, menu labels, or tooltip descriptions to show shortcuts inline.
Styling
.ph-kbd is the stable root hook. Consumer class values are additive, and style applies to that root. Styling uses vanilla CSS with semantic state attributes. variant="filled" is the default and retains the current translucent keycap style. variant="ghost" removes the fill and text shadow while retaining the same keycap geometry. The root always emits data-size and data-variant. Keycap heights now consume --ph-comp-h-sm (1.5rem, previously 1.25rem) and --ph-comp-h-md (1.75rem). Platform-specific key formatting and PC separator labels are unchanged. KbdVariant is exported from phoundry-ui. Internal part selectors and --_ph-* properties remain implementation details.