GitHubGitHub
← All components
Data display / component

Kbd

A keycap, or a nested run of caps for a shortcut, rendered in the monospace token with a pressed-key inset.

CombinationSingle key
K P Esc

Press K to search, or Esc to dismiss.

<Kbd keys={['⌘', 'K']} />

Installation

pnpm add @chanrg/4ui

Import the stylesheet once, at the root of your app:

import '@chanrg/4ui/styles.css';

Usage

import { Kbd } from '@chanrg/4ui';<Kbd keys={['⌘', 'K']} />

API reference

Props

PropTypeDefaultDescription
keysstring[]Renders one cap per key. Takes precedence over children.
childrenSnippetA single cap when keys is omitted, e.g. Esc.

CSS variables

VariableDescription
--4ui-surfacePrimary component surface.
--4ui-textPrimary foreground color.
--4ui-borderDefault control and panel border.
--4ui-surface-2Cap face.
--4ui-border-strongCap edge and the inset that reads as depth.
--4ui-font-monoKeycap typeface.

Accessibility

  • Nested <kbd> is the standard markup for a combination: the outer element groups, each inner element is one physical key.
  • The dividers between caps are decorative and hidden.

Dependencies

No runtime component dependencies.