elementskbd
Kbd
Keyboard keycap component with configurable size, variant, and accessible label.
Import#
Slot Structure#
Kbd renders a single accessible keycap. Use KbdGroup for shortcut chords and ordered sequences.
Static aliases such as meta, enter, escape, and arrowup resolve to familiar key symbols with accessible labels.
Set symbol={false} to render the raw key value without alias resolution.
Use KbdT.Key in shortcut data models to retain alias autocomplete while accepting custom key names.
Examples#
Variants#
Outline, default, and invert visual modes.
Sizes#
Keycap sizes from xs to xl.
Inline Usage#
Single-key inline hint.
API Reference#
Attributes#
Slot
root0 attributesKeyboard keycap element.
No attribute metadata for this slot.
Props#
| Prop | Type | Default | Description |
|---|---|---|---|
| class | ClassValue | — | Class applied to the component root or trigger element. |
| classes | KbdT.Classes | undefined | — | — |
| label | string | undefined | — | Accessible label for assistive technology. |
| ref | JSX.HTMLElementTags["kbd"] extends { ref?: infer Ref; } ? Ref : never | undefined | — | — |
| size | "xs" | "sm" | "md" | "lg" | "xl" | undefined | — | — |
| slotName | string | undefined | — | Data slot used by the rendered keycap. |
| style | JSX.CSSProperties | undefined | — | — |
| styles | KbdT.Styles | undefined | — | — |
| symbol | boolean | undefined | true | Whether to resolve known key aliases to symbols. |
| value* | KbdT.Key | — | Value displayed by the keycap or resolved through the static key aliases. |
| variant | "default" | "outline" | "invert" | undefined | — | — |