Primitives

Kbd

Inline keyboard-shortcut hint rendered as a small monospace pill.

Preview
01 Installation

Install

Pull Kbd from the barrel for everyday use, or the granular path when you want a tighter bundle.

tsxBarrel1 line
import { Kbd } from "@brika/clay";
tsxGranular1 line
import { Kbd } from "@brika/clay/components/kbd";
02 Usage

A minimal example

Drop this into a page. Native HTML attributes pass through to the underlying primitive.

tsxKbd.tsx6 lines
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>;
}
03 Examples

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.

04 Accessibility

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.
  • KbdGroup wraps a sequence of keys with role="group" and an accessible label so the chord is announced as a single shortcut.
05 Tokens 18 theme-overridable

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
ColorFill, border, and text colors.3
  • --kbd-containercolorvar(--muted)
    components.kbd.container

    Background of the kbd pill.

  • --kbd-labelcolorvar(--muted-foreground)
    components.kbd.label

    Glyph color of the kbd pill.

  • --kbd-border-colorcolorvar(--border)
    components.kbd.borderColor

    Hairline border color of the kbd pill.

GeometrySizes, lengths, and corner radii.5
  • --kbd-radiusradiusvar(--radius-control)
    components.kbd.radius

    Kbd corner radius.

  • --kbd-heightsize1.25rem
    components.kbd.height

    Default kbd height.

  • --kbd-padding-xsizecalc(var(--spacing) * 1.5)
    components.kbd.paddingX

    Inline padding inside the kbd.

  • --kbd-padding-ysize0.0625rem
    components.kbd.paddingY

    Block padding inside the kbd.

  • --kbd-gapsizecalc(var(--spacing) * 1)
    components.kbd.gap

    Gap between adjacent children inside the kbd.

BorderBorder width and style.2
  • --kbd-border-widthborder-width1px
    components.kbd.borderWidth

    Border width on the kbd. Set non-zero for outline-style variants.

  • --kbd-border-styleborder-stylesolid
    components.kbd.borderStyle

    Border style on the kbd (`solid`, `dashed`, `double`, `none`).

TypographyTypeface, size, weight, spacing.6
  • --kbd-font-familyfont-familyvar(--font-mono)
    components.kbd.fontFamily

    Typeface for kbd.

  • --kbd-font-sizefont-sizevar(--text-label-sm)
    components.kbd.fontSize

    Font size for kbd.

  • --kbd-font-weightfont-weight500
    components.kbd.fontWeight

    Font weight for kbd.

  • --kbd-line-heightline-height1.25
    components.kbd.lineHeight

    Line height for kbd.

  • --kbd-letter-spacingletter-spacing0
    components.kbd.letterSpacing

    Letter spacing for kbd. Useful for caps labels.

  • --kbd-text-transformtext-transformnone
    components.kbd.textTransform

    Text transform for kbd (`uppercase`, `lowercase`, `capitalize`, `none`).

MotionAnimation duration and easing.2
  • --kbd-durationdurationvar(--motion-standard-duration)
    components.kbd.duration

    Transition duration for kbd state changes.

  • --kbd-easingeasingvar(--motion-standard-easing)
    components.kbd.easing

    Transition 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.

jsonmy-theme.json12 lines
{
  "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.

06 API reference

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 />

passthrough

No wrapper-specific props, all attributes pass through to the underlying primitive.

<KbdGroup />

passthrough

No wrapper-specific props, all attributes pass through to the underlying primitive.