Component packs › Pressworks › Piano Key

Piano Key

Ivory and ebony keys pivot on the balance rail: the front drops, sinks behind the front rail and lands on the felt with a small bounce.

Piano Key is a button group from Pressworks, a component pack with 8 buttons: Eight buttons, each a different real mechanism you can feel. Price: $2 for the whole pack.

Built with: balance-rail pivot, keys under the fallboard, felt in your accent.

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 Key props

PropTypeDefaultDescription
labelstringInlaid in the fallboard and used as the accessible name.
disabledboolean
onPress(note: string) => voidCalled with the note pressed ("C", "C#", "D", "D#", "E"); Space and Enter play D.
theme'light' | 'dark'
sizenumberScale factor. 1 = 260 × 184 px.
autoplaynumber | falseShowcase mode: plays a short phrase every N ms while visible.

Methods on the ref

Use it in React

import PianoKey from './PianoKey';

<PianoKey />

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

More in Pressworks

Good for: Buttons.