06 · press · controls

Voice composer Pro

Press the mic and speak: the field turns into one fine thread of ink that carries your voice, with a single light under it that only glows in the dark. Send, and the thread folds into a point of light that runs into the send key.

Install

bash
npx shadcn@latest add @mu-pro/voice-composer

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 { VoiceComposer } from "@/components/mu/voice-composer/VoiceComposer";

<VoiceComposer
  onStart={() => recorder.start()}
  onVoice={(seconds) => recorder.stop()}
  onCancel={() => recorder.cancel()}
  onSend={(text) => send(text)}
  onAttach={() => pickFile()}
  level={micLevel} // optional, 0..1 from an AnalyserNode
/>

How it works

Input and reduced motion

  • Pointer / touch: tap the mic to start, then send (↑) or cancel (✕). Or hold the mic to talk: the rim lights as you press, listening starts after a beat, and it sends when you let go; slide more than 24px off the key before letting go to cancel. After a voice send the key keeps its dome for about a second while the point of light lands on it; it is already the mic again (named Speak), so pressing it starts a new message at once.
  • Keyboard: the mic, send and cancel keys are real buttons with names; Enter in the field sends typed text, and Escape cancels listening. Cancelling from the ✕ key without onAttach moves focus to the mic, so it is never lost. A polite live region says "Listening".
  • Reduced motion: the thread and its light are drawn once at a steady level without drifting (and redrawn if the theme changes), the rim and the spill light without fading, a send clears the thread at once with no point of light or flare, and the field swaps without fading.
  • Off screen the thread's frame loop pauses; it runs only while the thread is open or a send is landing, then stops.
  • Performance: the light is its own small canvas, shown scaled up, so the compositor enlarges it rather than the main thread; the rim and the spill sit on their own layers, so the level only fades them. What a frame still costs is drawing the three strands, which a phone's GPU does off the main thread: listening costs 41–52 ms/s of main thread on a 4× slowed CPU at a 3× phone's density with a GPU canvas, and 116–141 ms/s without one.

Props

PropDefaultWhat it does
levelsimulated voicelive input level 0..1; the thread swings and the light brightens with it
onStart—called when listening starts
onVoice—called with the seconds spoken when a voice message is sent
onCancel—called when listening is cancelled
onSend—called with the text when a typed message is sent
onAttach—called by the + key; without it the + key is hidden (its place is kept)
placeholderAsk anythingthe field's placeholder
labelsEnglish{ attach, message, speak, send, cancel, listening }
soundofftones for listen, send and cancel: true, or a volume 0–1 (see Sound)
accentfalselights the composer with --mu-signal instead of its own cool blue; the ink stays neutral
className—added to the root

Sound

Off by default. With sound (or a volume, sound={0.5}) listening opens with a rising tone (after the beat, when held), sending lifts and cancelling falls, typed sends included. 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.