Display

Kbd for keyboard shortcut keycaps

Kbd renders keyboard shortcuts as semantic <kbd> keycaps. Pass a single key through children or a multi-key chord through the keys array with an optional separator. It ships sizes, the full Zentauri appearance and gradient system, and an optional animated key press from the kbd/animated entry.

Open command palette+K
EscCtrl+Shift+P+Enter+Tab

Examples

Kbd renders keyboard shortcuts as semantic keycaps. Pass a single key via children, or a chord via the keys array with an optional separator.


Esc

+K

GthenI

+K

Kbd variants examples

Use Show output / Show code on each row. Snippets start with a Variant line naming the axis and token.


Appearance: DEFAULT | Size: MD

Esc+KCtrl+Shift+P

Appearance: SECONDARY | Size: MD

Esc+KCtrl+Shift+P

Appearance: DESTRUCTIVE | Size: MD

Esc+KCtrl+Shift+P

Appearance: OUTLINE | Size: MD

Esc+KCtrl+Shift+P

Appearance: GHOST | Size: MD

Esc+KCtrl+Shift+P

Appearance: GLASS | Size: MD

Esc+KCtrl+Shift+P

Appearance: EMERALD | Size: MD

Esc+KCtrl+Shift+P

Appearance: INDIGO | Size: MD

Esc+KCtrl+Shift+P

Appearance: PURPLE | Size: MD

Esc+KCtrl+Shift+P

Appearance: PINK | Size: MD

Esc+KCtrl+Shift+P

Appearance: ROSE | Size: MD

Esc+KCtrl+Shift+P

Appearance: SKY | Size: MD

Esc+KCtrl+Shift+P

Appearance: TEAL | Size: MD

Esc+KCtrl+Shift+P

Appearance: YELLOW | Size: MD

Esc+KCtrl+Shift+P

Appearance: ORANGE | Size: MD

Esc+KCtrl+Shift+P

Appearance: GRAY | Size: MD

Esc+KCtrl+Shift+P

Appearance: AMBER | Size: MD

Esc+KCtrl+Shift+P

Appearance: VIOLET | Size: MD

Esc+KCtrl+Shift+P

Appearance: GRADIENT-BLUE | Size: MD

Esc+KCtrl+Shift+P

Appearance: GRADIENT-GREEN | Size: MD

Esc+KCtrl+Shift+P

Appearance: GRADIENT-RED | Size: MD

Esc+KCtrl+Shift+P

Appearance: GRADIENT-YELLOW | Size: MD

Esc+KCtrl+Shift+P

Appearance: GRADIENT-PURPLE | Size: MD

Esc+KCtrl+Shift+P

Appearance: GRADIENT-TEAL | Size: MD

Esc+KCtrl+Shift+P

Appearance: GRADIENT-INDIGO | Size: MD

Esc+KCtrl+Shift+P

Appearance: GRADIENT-PINK | Size: MD

Esc+KCtrl+Shift+P

Appearance: GRADIENT-ORANGE | Size: MD

Esc+KCtrl+Shift+P

Appearance: OUTLINE | Size: SM

Esc+KCtrl+Shift+P

Appearance: OUTLINE | Size: MD

Esc+KCtrl+Shift+P

Appearance: OUTLINE | Size: LG

Esc+KCtrl+Shift+P

Motion: ANIMATED KEY PRESS

+K
CSS variable overrides

Kbd CSS variables

Override these kbd variables on :root, a theme selector, or a component wrapper. Structural variables drive the radius and keycap shadow; each appearance sets the keycap background, foreground, and border tokens.

133 variables

Pattern: --zui-<component>-<slot?>-<variant?>-<property>-<state?>-dark?

:root {
  --zui-kbd-radius: 0.375rem;
  --zui-kbd-shadow: inset 0 -1px 0 #0000001f;
  --zui-kbd-default-bg: #0f172a;
  --zui-kbd-default-fg: #f8fafc;
  --zui-kbd-default-shadow: 0 1px 2px #0f172a14;
  --zui-kbd-secondary-bg: #e2e8f0;
  --zui-kbd-secondary-fg: #0f172a;
  --zui-kbd-destructive-bg: #f43f5e;
  --zui-kbd-destructive-fg: #ffffff;
  --zui-kbd-outline-border: #0000001a;
  --zui-kbd-outline-bg: #0000000d;
  --zui-kbd-outline-fg: #0f172a;
  --zui-kbd-ghost-fg: #334155;
  --zui-kbd-glass-border: #00000026;
  --zui-kbd-glass-bg: #0000001a;
  --zui-kbd-glass-fg: #0f172a;
  --zui-kbd-emerald-bg: #10b981;
  --zui-kbd-emerald-fg: #ffffff;
  --zui-kbd-indigo-bg: #3730a3;
  --zui-kbd-indigo-fg: #ffffff;
  --zui-kbd-purple-bg: #6b21a8;
  --zui-kbd-purple-fg: #ffffff;
  --zui-kbd-pink-bg: #9d174d;
  --zui-kbd-pink-fg: #ffffff;
  --zui-kbd-rose-bg: #9f1239;
  --zui-kbd-rose-fg: #ffffff;
  --zui-kbd-sky-bg: #0ea5e9;
  --zui-kbd-sky-fg: #ffffff;
  --zui-kbd-teal-bg: #14b8a6;
  --zui-kbd-teal-fg: #ffffff;
  --zui-kbd-yellow-bg: #eab308;
  --zui-kbd-yellow-fg: #ffffff;
  --zui-kbd-orange-bg: #f97316;
  --zui-kbd-orange-fg: #ffffff;
  --zui-kbd-gray-bg: #6b7280;
  --zui-kbd-gray-fg: #ffffff;
  --zui-kbd-amber-bg: #f59e0b;
  --zui-kbd-amber-fg: #ffffff;
  --zui-kbd-violet-bg: #5b21b6;
  --zui-kbd-violet-fg: #ffffff;
  --zui-kbd-gradient-blue-from: #1e40af;
  --zui-kbd-gradient-blue-to: #6b21a8;
  --zui-kbd-gradient-blue-fg: #ffffff;
  --zui-kbd-gradient-green-from: #166534;
  --zui-kbd-gradient-green-to: #3f6212;
  --zui-kbd-gradient-green-fg: #ffffff;
  --zui-kbd-gradient-red-from: #991b1b;
  --zui-kbd-gradient-red-to: #9d174d;
  --zui-kbd-gradient-red-fg: #ffffff;
  --zui-kbd-gradient-yellow-from: #854d0e;
  --zui-kbd-gradient-yellow-to: #9a3412;
  --zui-kbd-gradient-yellow-fg: #ffffff;
  --zui-kbd-gradient-purple-from: #6b21a8;
  --zui-kbd-gradient-purple-to: #9d174d;
  --zui-kbd-gradient-purple-fg: #ffffff;
  --zui-kbd-gradient-teal-from: #115e59;
  --zui-kbd-gradient-teal-to: #155e75;
  --zui-kbd-gradient-teal-fg: #ffffff;
  --zui-kbd-gradient-indigo-from: #3730a3;
  --zui-kbd-gradient-indigo-to: #6b21a8;
  --zui-kbd-gradient-indigo-fg: #ffffff;
  --zui-kbd-gradient-pink-from: #9d174d;
  --zui-kbd-gradient-pink-to: #9f1239;
  --zui-kbd-gradient-pink-fg: #ffffff;
  --zui-kbd-gradient-orange-from: #9a3412;
  --zui-kbd-gradient-orange-to: #991b1b;
  --zui-kbd-gradient-orange-fg: #ffffff;
}

/* Dark theme variables follow the same names with -dark appended. */
.dark {
  --zui-kbd-shadow-dark: inset 0 -1px 0 #0000004d;
  --zui-kbd-default-bg-dark: #f8fafc;
  /* ...same variables with -dark at the end */
}

What it does

Kbd turns a key or chord into styled keycaps backed by semantic <kbd> elements. A single key comes from children, while the keys array renders a sequence of keycaps joined by an optional separator node.

The static entry renders instantly, while the animated entry adds a subtle press or pop motion when a keycap mounts.

Composition and API

Import Kbd from the kbd entrypoint, or KbdAnimated from kbd/animated for the motion variant. Use children for a single keycap, keys for a chord, and separator for the node between keycaps. Tune the look with appearance and size.

Common use cases

Reach for Kbd wherever a keyboard shortcut needs to be visible: command palettes, help menus, tooltips and buttons that expose hotkeys, onboarding tours, and settings or cheat-sheet screens that list key bindings.

Accessibility

Each keycap renders a native <kbd> element so the shortcut is exposed as keyboard input to assistive technology. Keep separators meaningful (for example "+" or "then") and ensure the surrounding context names what the shortcut does.

Next.js integration notes

The static Kbd is a plain presentational component and works in server and client components alike. KbdAnimated relies on framer-motion, so render it inside client components or interactive islands.

FAQ

How do I render a multi-key chord?

Pass the keys prop an array such as keys={['⌘', 'K']} and set separator to the node you want between keycaps, like "+" or "then". Each entry renders as its own keycap.

What is the difference between children and the keys prop?

Use children for a single keycap, e.g. <Kbd>Esc</Kbd>. Use keys for a chord of multiple keycaps. When keys is provided it takes precedence over children.

Does Kbd render semantic markup?

Yes. Each keycap is a real <kbd> element wrapped in a span, so assistive technology and styling hooks recognize the shortcut as keyboard input.