Skip to content
Playground

Kbd

Composable keycaps for keyboard keys and shortcuts.

Display a keyboard key with Kbd, or combine several keys with Kbd.Group. Keycaps are informational: the application owns shortcut registration and handling.

CtrlShiftEnterEscCtrl+K
TSX
import { Kbd } from "@zentara-co/zenos-ui";

Use Kbd.Group to keep the keys of a shortcut together. Each Kbd renders a native kbd element; the group renders a span. Separators are optional and belong to the content you compose. Import only Kbd to use both keycaps and groups. Kbd.Root is an alias for Kbd.

TSX
<Kbd.Group>  <Kbd>Ctrl</Kbd>  <span>+</span>  <Kbd>K</Kbd></Kbd.Group>

Press Ctrl+K to open the command menu.

Groups inherit text direction from their container. Set native dir="rtl" when a group needs right-to-left presentation independently of the page.

Place a keycap next to an action label without adding another focusable control. The button keeps its native keyboard behavior; the keycap does not install a shortcut.

Combine an action description and keycaps inside Tooltip.Content. Keep the trigger’s accessible name meaningful even when the tooltip is closed.

Use InputGroup.Addon to show shortcut hints beside a field. Label the input independently; the keycaps do not replace its accessible name.

CtrlK

Use the usual className prop to override keycap appearance or group spacing. No variant or color props are required. Classes apply after the defaults, and native props, styles, and refs are forwarded to the rendered element.

CtrlK

The optional keys shorthand remains available for automatic key labels. Join tokens with +; use plus for a literal plus key. mod displays Command on Apple platforms and Control elsewhere, with a matching spoken label. When keys is supplied, it takes precedence over children.

Open command menu

Create new item

Close overlay

Recognized names include mod, ctrl, alt, shift, enter, escape, tab, backspace, the four arrow directions, and plus. Other tokens render as uppercase text. Literal children, such as <Kbd>Ctrl</Kbd>, are displayed exactly as supplied and are not platform-dependent.

Kbd
Kbd.Root
Kbd.Group

API

PropTypeDefaultDescription
children ReactNode — Literal key text or an icon rendered in a native kbd keycap. Group multiple keys with Kbd.Group.
className string — Custom keycap styles or group spacing. No variant or color props are required.
keys string — Optional platform-aware shortcut shorthand. Tokens are separated by +; use plus for a literal plus key. When supplied, it takes precedence over children.
native props React.HTMLAttributes<HTMLElement> — Forwards native attributes, events, aria-*, data-*, className, style, and ref.

Unless narrowed above, each DOM-rendering part also accepts its underlying native or Base UI props, including className, style, aria-*, and data-*.

Children-based keycaps use native keyboard-input semantics and leave their text available to assistive technology. Spell out ambiguous key symbols or pair a decorative symbol with visually hidden text. Kbd.Group only groups content and does not add interaction or focus.

The keys shorthand exposes the whole shortcut as one accessible image label and hides the individual visual keycaps from assistive technology. Neither form listens for keyboard commands. Keep the related action clear in nearby text and only advertise shortcuts that the application implements.