Xzero UI
Pro library

Keycap keyboardPro

Mechanical keycaps that sink and light up as you type, with the text above the board.

$ pnpm dlx shadcn@4.23.0 add @xzero-ui-pro/keycap-keyboard
Live · keyboard ready

When to use

When not to use

Installation

Register both Xzero UI namespaces in your project's components.json:

{
  "registries": {
    "@xzero-ui": "https://mcp.xzero.co.uk/r/{name}.json",
    "@xzero-ui-pro": "https://mcp.xzero.co.uk/r/pro/{name}.json"
  }
}
npx shadcn@4.23.0 add @xzero-ui-pro/keycap-keyboard

Install xzero-foundation once, and import @/components/xzero/foundation.css in your app root. No Xzero token is used by this snapshot. For sample portraits, photos, fonts, or logos, download https://mcp.xzero.co.uk/install-assets.mjs and run node xzero-install-assets.mjs <receiving-project>.

Usage

import { KeycapKeyboard } from "@/components/xzero/keycap-keyboard/keycap-keyboard";

export function TypeToTry() {
  return <KeycapKeyboard listen="window" placeholder="Type anything" />;
}

// Letters only
<KeycapKeyboard layout="letters" />

// A four key macro pad
<KeycapKeyboard rows={[["a", "r", "c", "backspace"]]} showOutput={false} />

API reference

KeycapKeyboard

A board of sculpted mechanical keycaps. Physical typing and clicks press the matching cap into its housing, bloom a faint light under it, and add the character to a wrapping text area above the board.

PropTypeDefaultDescription
valuestring–Controlled text.
defaultValuestring""Initial text when uncontrolled.
onValueChange(value: string) => void–Called with the new text after every key.
layout"compact" | "letters""compact"Compact is a full 60% board with numbers, punctuation, and modifiers. Letters is three letter rows with shift, delete, and a space bar.
rowsstring[][]–Custom rows that override layout. Single characters, plus "space", "backspace", "enter", "shift", "tab", and "caps".
maxLengthnumber280Longest text kept. Older characters drop off the start.
listen"focus" | "window""focus"Where physical keys are heard. "window" listens across the page but ignores other text fields and shortcuts with Command, Control, or Alt.
placeholderstring"Start typing"Shown while the text is empty.
showOutputbooleantrueHides the typed text area when you render the value yourself.
labelstring"Keyboard"Accessible name for the board.
classNamestring–Extra class on the root.

Keyboard interactions

KeysAction
Any printable keyTypes the character and holds the matching cap down while the key is held. Caps match on physical position, so every layout lights the right cap.
BackspaceDeletes the last character; holding it repeats.
EnterStarts a new line.
Shift, Tab, Caps, modifiersLight their caps. Tab still moves focus.
Tab to a cap, then Enter or SpacePresses that cap as a button. Shift latches for the next character.

Accessibility

Motion

Responsive behavior

Performance

Notes for AI

Also in type

Guidance for AI tools

Keycap keyboard: Mechanical keycaps that sink and light up as you type, with the text above the board. Follow the declared prop types and do not invent props. Keep keyboard access, reduced motion support, and both light and dark themes intact when adapting it.

Full library index: https://ui.xzero.co.uk/llms.txt

Browse all components