Component packs › Spool › Piano Keys

Piano Keys

Press a key and it hitches on the latch and stays down, while the key that was down is kicked back up past its rest and settles.

Piano Keys is a radio group from Spool, a component pack with 6 deck controls: Controls built from the mechanics of a tape deck: latching keys, reels, drums and a VU needle. Price: $2 for the whole pack.

Built with: latch hitch keyframes, kick-up overshoot, roving arrow keys.

Code: React and Next.js (TypeScript), Vue 3, plain HTML/CSS/JS, Tailwind CSS v4 and Motion (motion.dev). No npm packages needed. Keyboard accessible, with a reduced-motion version, in dark and light.

Piano Keys props

PropTypeDefaultDescription
optionsstring[]Day, Week, Month, YearKey labels. Default Day, Week, Month, Year.
valuenumber0Index of the latched key. Default 0.
labelstring"Range"Accessible name of the group. Default "Range".
onChange(index: number, label: string) => void
darkboolean
autoplaynumber | falseShowcase mode: presses the next key every N ms.

Methods on the ref

Use it in React

import PianoKeys from './PianoKeys';

<PianoKeys />

The Vue, HTML, Next.js, Tailwind and Motion versions take the same options.

More in Spool

Good for: Skeuomorphic UI.