Skip to content
Browse docs and components

Voice Button

voice-button

The record button of a voice interface: push to talk or tap to toggle, a live waveform and a running clock while recording, then transcribing, done or try again. You drive the state; it records nothing itself.

Responsive

Install

$npxshadcnadd@forme/voice-button

Adds the component, its registry dependencies, and the token stylesheet you import once.

API reference

Read from the source, so it is the API of the file you install. A prop marked * is required.

VoiceButton

The record button of a voice interface, as a state machine you drive: idle → recording (a live waveform and a running clock) → processing → success or error, which both accept another press. It records nothing itself; onStart and onStop are where the MediaRecorder goes.

PropTypeDefaultDescription
state*'error' | 'success' | 'idle' | 'recording' | 'processing'—Controlled: the app moves it on, because only the app knows when transcription ends.
onStart() => void—Fires on press (hold) or first click (toggle). Start the recorder here.
onStop() => void—Fires on release (hold) or second click (toggle). Stop and transcribe here.
mode"hold" | "toggle""hold"hold is push-to-talk: press, speak, release — Space or Enter held down does the same. toggle is click to start, click to stop.
levelnumber—Microphone loudness, 0–1, for the waveform while recording.
analyserAnalyserNode | nullnullOr the recorder's analyser, for a spectrum instead of a level.
labelstring—Replaces the default label for the current state.
classNamestring—