Component packs › Pressworks › 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.
| Prop | Type | Default | Description |
|---|---|---|---|
label | string | Inlaid in the fallboard and used as the accessible name. | |
disabled | boolean | ||
onPress | (note: string) => void | Called with the note pressed ("C", "C#", "D", "D#", "E"); Space and Enter play D. | |
theme | 'light' | 'dark' | ||
size | number | Scale factor. 1 = 260 × 184 px. | |
autoplay | number | false | Showcase mode: plays a short phrase every N ms while visible. |
press(note?: string): void: Presses a key by note name.setDisabled(disabled: boolean): voiddestroy(): voidimport PianoKey from './PianoKey';
<PianoKey />The Vue, HTML, Next.js, Tailwind and Motion versions take the same options.
Good for: Buttons.