Appica UIUI 1.0.0

Kbd

A keyboard key, and groups of keys, for documenting shortcuts.

K

Usage

Kbd renders a single keyboard key — a styled <kbd> element — for documenting shortcuts inline, in tooltips, and in menus. Two parts live under @appica/ui-react/kbd:

  • Kbd — one key. Three sizes; the content is whatever you pass as children (a letter, a word like Esc, or a glyph like ).
  • KbdGroup — a wrapper that lays out a sequence of keys with even spacing and propagates a shared size to the Kbds inside it.

It's purely presentational: it carries no shortcut behavior, so wire up the actual key handling yourself.

Examples

Default

A single key sized to its content — narrow for one letter, wider for a word. The minimum width keeps single characters square.

Sizes

Three sizes — sm, md (default), and lg — scale the height, padding, and text together so a key sits comfortably next to surrounding type.

Key combinations

Wrap several Kbds in a KbdGroup to show a chord. The group spaces the keys evenly and pushes a shared size down to each one — and leaves any non-Kbd child (like a + separator) untouched.

Shortcut list

A common layout: action on one side, its shortcut on the other. The KbdGroup keeps each combo aligned and consistently sized.

Inside a button

Drop a Kbd into a Button as a trailing shortcut hint — a familiar pattern for search and command-menu triggers.

Inside a tooltip

Kbd detects a Tooltip surface and inverts its colors automatically, so a shortcut stays legible against the dark tooltip background with no extra styling.

RTL

Every Appica UI component supports right-to-left layouts out of the box. Set the dir attribute on a container (commonly your <html> element) so CSS logical properties resolve correctly, and wrap your tree in DirectionProvider so direction-aware behavior follows the same direction.

The list and its labels flip to the right, while each shortcut's keys stay in left-to-right reading order — pin the KbdGroup with dir="ltr" so a ⌘ K combo isn't reversed into K ⌘. For setup details and caveats, see the RTL guide.

  • فتح قائمة الأوامرK
  • بحثF
  • تبديل الشريط الجانبيB

API reference

Kbd and KbdGroup are styled native elements (<kbd> and <span>) — they're not Base UI primitives. Each forwards ref and every remaining attribute to its underlying element.

Kbd

A single key. Renders a <kbd>.

KbdGroup

A row of keys. Renders a <span> and forwards size to its Kbd children.

Accessibility

  • Kbd renders the semantic <kbd> element, which assistive tech recognizes as keyboard input.
  • The component is decorative documentation, not an interactive control — pair it with the real key handler, and make sure the shortcut also has a discoverable, non-keyboard way to trigger the same action.
  • When a glyph alone might be ambiguous (e.g. vs "Command"), consider an aria-label on the Kbd so it's announced clearly.
  • Inside a KbdGroup, keys read in source order; pin the group to dir="ltr" under RTL so a combo isn't announced or displayed in reverse.

© 2026 Appica UI. A free component library, crafted by the Appica team.