Kbd
A keycap for the keys in a shortcut.
Live demo
Kbd renders a single key as a physical keycap: a mono-faced label on a raised surface, the depth read from a heavier bottom edge rather than a drop shadow, so it sits cleanly inline in running text. It carries no layout of its own: set a few side by side in a Cluster to spell a chord (Ctrl + K).
Everything about its look is derived chrome: the surface, the edge, the radius all come from the same tokens the rest of the theme does, so a keycap matches the UI it documents. The size prop steps it with the surrounding type from sm to lg.
When to use
How this component composes with the rest of the set.
Props
1 prop, straight from the manifest.
| Prop | Type | Default | Bindings | Description |
|---|---|---|---|---|
Appearance
Sizes
sm
A compact keycap for dense inline hints.
md
The default keycap, sized with body text.
lg
A prominent keycap for a featured shortcut.
Anatomy
The named parts that make up the component, with their selectors.
kbd
The keycap root: a raised surface with a weighted bottom edge.
Tokens & coverage
What the component consumes, checked live against what the algorithm produces.
Live coverage check against the xoji-default register
(derive(xojiDefault, { anchors }) โ
coverComponent(manifest, register)). Every token this component
consumes must be a key the algorithm produces.
--bg-2
--border-thick
--border-thin
--fg-1
--font-mono
--leading-tight
--line-2
--radius-sm
--text-lg
--text-sm
--text-xs
--weight-medium
Slots
The key label: a glyph or short word like K, Esc, or Enter.
Accessibility
Code
Keys and sizes
Single keys and a chord, shown across the three sizes.
<xoji-kbd>Ctrl</xoji-kbd>
<xoji-kbd>K</xoji-kbd>
<xoji-kbd size="sm">Esc</xoji-kbd>
<xoji-kbd size="lg">Enter</xoji-kbd>
<script lang="ts">
import { Kbd } from "@xoji/svelte";
</script>
<Kbd>Ctrl</Kbd>
<Kbd>K</Kbd>
---
import Kbd from "@xoji/astro/Kbd.astro";
---
<Kbd>Ctrl</Kbd>
<Kbd>K</Kbd>