Skip to content

components/keycap

KeycapTone = "neutral" | "primary" | "accent" | "ink" | "destructive"

Molded key colors. ink is the dark key; destructive stays neutral until hovered or focused; the rest follow the theme.


KeycapSize = "sm" | "md" | "lg"

Keycap sizes: a legend chip, a dock key and a big face key.


KeycapProps = HTMLAttributes<HTMLElement> > & object

Props accepted by Keycap.

optional tone?: KeycapTone

optional size?: KeycapSize

optional pressed?: boolean

Show the key held down. Presentation only; the host owns input.


KeycapButtonProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>>, "children"> > & object

Props accepted by KeycapButton.

label: ReactNode

Visible name of the action, e.g. “Build”. null makes an icon-only key, which then needs an aria-label.

optional shortcut?: string

The keyboard key that runs the same action, shown as a small keycap.

optional icon?: ReactNode

Decorative icon before the label.

optional readout?: ReactNode

Extra readout after the label, such as a PixelNumber count.

optional tone?: KeycapTone

optional pressed?: boolean

Toggle state for mode keys. undefined is a momentary key; a boolean adds aria-pressed and lights the key’s indicator.

optional expanded?: boolean

Disclosure state for keys that open a palette or window. A boolean adds aria-expanded and lights the lamp; use it instead of pressed for menus.

const Keycap: ForwardRefExoticComponent<HTMLAttributes<HTMLElement> > & object & RefAttributes<HTMLElement>>>>

One molded key legend, rendered as native <kbd>: the key a player presses. The key sits on its own travel so pressed and resting keys take the same room.


const KeycapButton: ForwardRefExoticComponent<Omit<ButtonHTMLAttributes<HTMLButtonElement>>, "children"> > & object & RefAttributes<HTMLButtonElement>>>>

A chunky action key for game docks and toy panels. The host owns the action and the keyboard binding; shortcut only labels it.