Skip to content

Keycap Button

A sculpted keycap compresses into its base with a satisfying press.

LIVE PREVIEWInteract with the component
Just React. No extra dependencies.

Copy the component and its CSS module into your project.

CSS Modules

Usage

Matches your current playground settings.

jsx
import KeycapButton from "./KeycapButton";
export default function Example() {
return (
<KeycapButton
children={"Create"}
hint={"↵"}
color={"#ded7cb"}
baseColor={"#8e8275"}
inkColor={"#37302b"}
depth={7}
disabled={false}
style={{
"fontSize": 17
}}
/>
);
}

Using Keycap Button

Use a concise action label in children and an optional hint for supporting text. Connect onClick to the action.

depth changes how far the key appears raised above its base. Use type explicitly when placing the button inside a form.

Props

NameTypeRequiredDefaultDescription
childrenReactNodeNoundefinedButton content.
hintReactNodeNoundefinedOptional visual key hint. This does not register a keyboard shortcut.
colorstringNo"#ddd6ca"Keycap surface colour.
baseColorstringNo"#867c73"Keycap base colour.
inkColorstringNo"#37312e"Inherited label colour.
depthnumberNo7Unpressed travel height in pixels.
pressedbooleanNofalseOptional visual pressed state; native pointer and keyboard pressing also work.
disabledbooleanNofalseNative disabled state.
typestringNo"button"Native button type: button, submit, or reset.
onClickfunctionNoundefinedNative click handler. Other native button and accessibility props are forwarded.
classNamestringNo""Additional classes merged with component styles.
styleCSSPropertiesNoundefinedInline styles for caller-defined sizing, typography, and appearance.

Related components

An action label contracts into a circular loader and resolves to a checkmark.

Alternating shutters close into a solid button face on hover or focus.

A raised rubber-stamp button leaves a fading outline when pressed.

A clipped corner floods the button with colour as its arrow turns.