05 · press · controls

Record button Pro

Press the mic and it opens into a pill-shaped recorder: a light inside a lamp of neutral smoky glass, with one window reflection, follows your voice while the seconds roll. Press the lamp to stop, and the same glass shows a pale tick in a cooled light when it is saved, or a warm red cross if saving fails.

Install

bash
npx shadcn@latest add @mu-pro/record-button

Pro. Installs with a licence key through the @mu-pro registry. Checkout opens soon: until then Pro installs are closed, and nothing can be bought on this site.

Usage

tsx
import { RecordButton } from "@/components/mu/record-button/RecordButton";

<RecordButton
  onStart={() => recorder.start()}
  onStop={(seconds) => recorder.stop()}
  level={micLevel} // optional, 0..1 from an AnalyserNode
/>

How it works

Input and reduced motion

  • Pointer / touch / keyboard: the mic key starts recording; the lamp stops it. Both are real buttons with names, and both give under a press (the key's whole body squeezes). The lamp takes presses once it has arrived, so a fast double-tap on the key never stops what it just started. Keyboard focus moves to the lamp as the pill opens and back to the key as it closes; the lamp's name follows the state ("Stop recording", "Saving", "Saved, N seconds"). A polite live region says the same.
  • Off-screen: the light stops redrawing while the item is out of view, and whenever nothing about it is changing.
  • Reduced motion: the pill opens and closes instantly, digits change without rolling, the light holds a steady glow instead of following the voice, and the results show at once with their mark drawn.

Props

PropDefaultWhat it does
onStart—called when recording starts
onStop—called with the length in seconds; return or resolve false, or throw, to show the failed state
levelsimulated voicelive input level 0..1; the light inside the glass follows it, rising fast and falling slowly
maxSeconds600stops on its own after this long
labelsEnglish{ start, stop, recording, saving, saved(s), failed, min, sec }
soundoffkey, lamp and result sounds: true, or a volume 0–1 (see Sound)
className—added to the root

Sound

Off by default. With sound (or a volume, sound={0.5}) the key tocks as it goes down, the lamp arms with a soft tone when it is ready to press, pressing it tocks again, and the save answers with a two-note chime, or two low, rounded pulses stepping down if it fails. A stop at maxSeconds is silent. setMuted(true) from components/mu/sounds.ts silences every cottoncandy item at once.

Licence

Included with Pro: use it in unlimited end products for you and your clients; no reselling as a kit. See the licence.