Button Library · Signature
Keycap
A real keyboard key: dished top, deep travel.
States
Default
Hover
Active
Focus
Code
sig-keycap.html
<button class="btn-sig-keycap" type="button">
<span class="btn-sig-keycap__cap">
<span>Enter</span>
<span class="btn-sig-keycap__legend" aria-hidden="true">↵</span>
</span>
</button>
sig-keycap.css
.btn-sig-keycap {
--btn-bg: #e9e4d8;
--btn-fg: #26252c;
--btn-font: ui-monospace, monospace;
--btn-size: 15px;
--btn-weight: 600;
--btn-px: 22px;
--btn-py: 11px;
--btn-w: auto;
--btn-h: auto;
--btn-bw: 0px;
--btn-line: #8b6cff;
--btn-radius: 8px;
--btn-speed: 180ms;
}
.btn-sig-keycap {
position: relative;
display: inline-flex;
align-items: center;
justify-content: center;
gap: 0.5em;
box-sizing: border-box;
width: var(--btn-w);
height: var(--btn-h);
padding: 5px 8px 11px;
font-family: var(--btn-font);
font-size: var(--btn-size);
font-weight: var(--btn-weight);
line-height: 1.2;
color: var(--btn-fg);
background: linear-gradient(180deg, color-mix(in srgb, var(--btn-bg) 72%, #000), color-mix(in srgb, var(--btn-bg) 50%, #000));
border: var(--btn-bw) solid var(--btn-line);
border-radius: calc(var(--btn-radius) + 4px);
box-shadow: 0 6px 0 rgba(0,0,0,.5), 0 12px 18px rgba(0,0,0,.4);
cursor: pointer;
text-decoration: none;
white-space: nowrap;
transition: all var(--btn-speed) ease;
}
.btn-sig-keycap:focus-visible {
outline: 2px solid var(--btn-bg);
outline-offset: 2px;
}
.btn-sig-keycap:disabled {
opacity: 0.5;
pointer-events: none;
}
.btn-sig-keycap__icon {
width: 1.15em;
height: 1.15em;
flex-shrink: 0;
}
.btn-sig-keycap:hover {
transform: translateY(1px);
box-shadow: 0 5px 0 rgba(0,0,0,.5), 0 10px 16px rgba(0,0,0,.4);
}
.btn-sig-keycap__cap {
display: inline-flex;
align-items: center;
gap: 14px;
padding: var(--btn-py) var(--btn-px);
background: linear-gradient(165deg, color-mix(in srgb, var(--btn-bg) 86%, #fff), var(--btn-bg));
border-radius: var(--btn-radius);
box-shadow: inset 0 1px 0 rgba(255,255,255,.55), inset 0 -3px 4px rgba(0,0,0,.14);
}
.btn-sig-keycap__legend {
font-size: 0.85em;
opacity: 0.55;
}
.btn-sig-keycap:active {
transform: translateY(5px);
box-shadow: 0 1px 0 rgba(0,0,0,.5), 0 3px 6px rgba(0,0,0,.4);
}
@media (prefers-reduced-motion: reduce) {
.btn-sig-keycap {
animation: none !important;
transition: none !important;
}
}
sig-keycap.js
// No JavaScript needed: this one is CSS only.
sig-keycap.tsx
import type React from "react";
import "./sig-keycap.css"; // the CSS tab
export function BtnSigKeycap({ children = "Enter", ...props }: React.ComponentProps<"button">) {
return (
<button className="btn-sig-keycap" type="button" {...props}>
<span className="btn-sig-keycap__cap">
<span>{children}</span>
<span className="btn-sig-keycap__legend" aria-hidden="true">{"↵"}</span>
</span>
</button>
);
}
sig-keycap.html
<button class="relative inline-flex items-center justify-center gap-[0.5em] [box-sizing:border-box] [padding:5px_8px_11px] [font-family:ui-monospace,_monospace] text-[15px] font-[600] [line-height:1.2] text-[#26252c] [background:linear-gradient(180deg,_color-mix(in_srgb,_#e9e4d8_72%,_#000),_color-mix(in_srgb,_#e9e4d8_50%,_#000))] [border:0px_solid_#8b6cff] rounded-[calc(8px_+_4px)] [box-shadow:0_6px_0_rgba(0,0,0,.5),_0_12px_18px_rgba(0,0,0,.4)] cursor-pointer no-underline whitespace-nowrap [transition:all_180ms_ease] focus-visible:[outline:2px_solid_#e9e4d8] focus-visible:[outline-offset:2px] disabled:[opacity:0.5] disabled:[pointer-events:none] hover:[transform:translateY(1px)] hover:[box-shadow:0_5px_0_rgba(0,0,0,.5),_0_10px_16px_rgba(0,0,0,.4)] active:[transform:translateY(5px)] active:[box-shadow:0_1px_0_rgba(0,0,0,.5),_0_3px_6px_rgba(0,0,0,.4)] motion-reduce:[transition:none!important]" type="button">
<span class="inline-flex items-center gap-[14px] [padding:11px_22px] [background:linear-gradient(165deg,_color-mix(in_srgb,_#e9e4d8_86%,_#fff),_#e9e4d8)] rounded-[8px] [box-shadow:inset_0_1px_0_rgba(255,255,255,.55),_inset_0_-3px_4px_rgba(0,0,0,.14)]">
<span>Enter</span>
<span class="text-[0.85em] [opacity:0.55]" aria-hidden="true">↵</span>
</span>
</button>