Install
Pull Kbd from the barrel for everyday use, or the granular path when you want a tighter bundle.
import { Kbd } from "@brika/clay";import { Kbd } from "@brika/clay/components/kbd";A minimal example
Drop this into a page. Native HTML attributes pass through to the underlying primitive.
import { Kbd } from '@brika/clay/components/kbd';
/** Single key cap, use for one-press hints like the Command symbol. */
export default function KbdDefaultDemo() {
return <Kbd>⌘</Kbd>;
}Kbd, every way
Group
`KbdGroup` aligns a chord and exposes it as a single ARIA group.
In Button
Kbd is `pointer-events-none`, so a key cap inside a button doesn't swallow clicks.
In Input
Drop a chord into an `InputGroupAddon` to advertise a search shortcut.
In Text
Kbd flows inline with body copy thanks to `align-middle` and `inline-flex`.
In Tooltip
Inside `TooltipContent`, Kbd auto-recolors to read against the inverted surface.
Platform modifier
`useModifier` resolves the shortcut key on the client (Command on Apple devices, Control elsewhere) so the hint is right on any OS.
Accessibility
- Renders a native
<kbd>so assistive tech announces it as keyboard input. - Use real key names (
Ctrl,Shift,Enter) so screen readers spell them sensibly; symbols like⌘are visual shorthand and should be paired with text alternatives where possible. -
KbdGroupwraps a sequence of keys withrole="group"and an accessible label so the chord is announced as a single shortcut.
Theme tokens
Every CSS variable Kbd reads, with its default and the
dotted path you'd write in a ThemeConfig JSON
to override it. Set any of these in your theme to retune Kbd
without touching component code.
Kbd tokens
18 tokens--kbd-containercolorvar(--muted)components.kbd.containerBackground of the kbd pill.
--kbd-labelcolorvar(--muted-foreground)components.kbd.labelGlyph color of the kbd pill.
--kbd-border-colorcolorvar(--border)components.kbd.borderColorHairline border color of the kbd pill.
--kbd-radiusradiusvar(--radius-control)components.kbd.radiusKbd corner radius.
--kbd-heightsize1.25remcomponents.kbd.heightDefault kbd height.
--kbd-padding-xsizecalc(var(--spacing) * 1.5)components.kbd.paddingXInline padding inside the kbd.
--kbd-padding-ysize0.0625remcomponents.kbd.paddingYBlock padding inside the kbd.
--kbd-gapsizecalc(var(--spacing) * 1)components.kbd.gapGap between adjacent children inside the kbd.
--kbd-border-widthborder-width1pxcomponents.kbd.borderWidthBorder width on the kbd. Set non-zero for outline-style variants.
--kbd-border-styleborder-stylesolidcomponents.kbd.borderStyleBorder style on the kbd (`solid`, `dashed`, `double`, `none`).
--kbd-font-familyfont-familyvar(--font-mono)components.kbd.fontFamilyTypeface for kbd.
--kbd-font-sizefont-sizevar(--text-label-sm)components.kbd.fontSizeFont size for kbd.
--kbd-font-weightfont-weight500components.kbd.fontWeightFont weight for kbd.
--kbd-line-heightline-height1.25components.kbd.lineHeightLine height for kbd.
--kbd-letter-spacingletter-spacing0components.kbd.letterSpacingLetter spacing for kbd. Useful for caps labels.
--kbd-text-transformtext-transformnonecomponents.kbd.textTransformText transform for kbd (`uppercase`, `lowercase`, `capitalize`, `none`).
--kbd-durationdurationvar(--motion-standard-duration)components.kbd.durationTransition duration for kbd state changes.
--kbd-easingeasingvar(--motion-standard-easing)components.kbd.easingTransition easing for kbd state changes.
Override in a theme
Authoring a theme is plain JSON. Drop overrides under
components.kbd, the names
are camelCase versions of the variable suffix.
{
"id": "my-theme",
"name": "My Theme",
"description": "...",
"accentSwatches": ["#000"],
"components": {
"kbd": {
"paddingX": "calc(var(--spacing) * 1.5)"
}
}
}
Then apply with applyTheme(myTheme)
(see the theming guide),
scope it to a subtree with themeToCssVars(myTheme, mode),
or consume any token directly in your own JSX with the matching Tailwind utility
(e.g. bg-kbd-…) — see the
chips on each token row.
API reference
Props specific to Kbd. Native HTML attributes pass through to the underlying primitive, see the component source on GitHub for the full type signature.
<Kbd />
passthroughNo wrapper-specific props, all attributes pass through to the underlying primitive.
<KbdGroup />
passthroughNo wrapper-specific props, all attributes pass through to the underlying primitive.