Voice button
A React component in Beamline's Voice & audio category.
The control that starts and stops talking: click to toggle or hold to talk (pointer, Space, Enter or a global shortcut), with a live level while recording, a loader while words are finished, and a check or a retry when it ends. The state comes from your operation, never from a timer.
Use it for
- Starting and stopping dictation, a voice command or a voice note.
- Push-to-talk with a keyboard shortcut.
Not for
- Ordinary actions (button).
- A whole voice call with mute and text (conversation-bar).
- A text field you dictate into (speech-input, which uses this).
Anatomy
- button
- glyph (mic, check, alert in one place: the next grows in as the last shrinks away)
- label
- live level (while recording; widens into the button)
- shortcut keycaps
- glow (optional)
Variants
- variant: secondary, outline, ghost, primary, accent
- size: sm, md, lg
- mode: toggle, hold
States
- idle
- recording (pressed, a red ring drawn over the look's own paint, red mic, live level, optional glow)
- processing (loader, keeps size and focus)
- success (green check and the word)
- error (red alert icon and a retry label; icon-only keeps a red mic)
- disabled
Keyboard
- Enter / Space: toggle (toggle mode) or hold to talk (hold mode)
- The `shortcut` works anywhere on the page while the button is mounted (not inside text fields unless it has a modifier); in hold mode releasing the key stops
- Touch, hold mode: the button keeps the finger (touch-action none, no long-press callout), so a thumb that drifts while it holds never scrolls the page and cuts the recording off
Motion
The glyph turns in place (mic, check, alert: in over --pui-motion-in, out over --pui-motion-out; a fade only under reduced motion) and the words follow with the system Button's label morph and width spring. The live level widens into the button as recording starts and moves only while recording; the glow fades in over --pui-motion-in and out over --pui-motion-out and runs nothing when idle.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
state | "idle" | "recording" | "processing" | "success" | "error" | "idle" | Driven by your operation: recording while it listens, processing while words are finished, then success or error. |
onPress | () => void | — | Toggle mode: every click, Enter, Space or shortcut press. |
onPressStart / onPressEnd | () => void | — | onPressStart: Hold mode: pressed down and let go. onPressEnd: Reports the end of the held press; no handler by default. |
mode | "toggle" | "hold" | "toggle" | Toggle recording on each press or record while held; defaults to toggle. |
shortcut | string[] | — | A page-wide shortcut, as Kbd keys: ["alt", "space"], ["mod", "shift", "v"]. |
source | MediaStream | LevelSource | (() => number) | — | The level drawn inside the button while recording. |
label | ReactNode | — | Visible text; defaults follow the state. With iconOnly it is the accessible name. |
iconOnly | boolean | — | Shows only the icon while retaining the accessible name. Defaults to false. |
glow | boolean | — | Colour pools under the button while recording. |
variant / size / disabled | ButtonVariant / "sm" | "md" | "lg" / boolean | — | variant: Visual weight of the control. Defaults to "secondary". size: Control size within the supported size steps. Defaults to "md". disabled: Prevents interaction with the control. Defaults to false. |
classNames | VoiceButtonClassNames | — | Classes for the named visual parts; no part overrides by default. |
style / ref | CSSProperties / native Ref | — | style: Inline styles on the documented visual root; no inline overrides by default. ref: Receives the button or trigger; no ref by default. |
onPressStart | (() => void) | — | Hold mode: pressed down and let go. |
onPressEnd | (() => void) | — | Reports the end of the held press; no handler by default. |
variant | "accent" | "ghost" | "outline" | "primary" | "secondary" | — | Visual weight of the control. Defaults to "secondary". |
size | "lg" | "md" | "sm" | — | Control size within the supported size steps. Defaults to "md". |
disabled | boolean | — | Prevents interaction with the control. Defaults to false. |
className | string | — | Classes on the documented visual root; no override by default. |
style | CSSProperties | — | Inline styles on the documented visual root; no inline overrides by default. |
ref | Ref<HTMLButtonElement> | — | Receives the button or trigger; no ref by default. |
Built from
- button
- live-waveform
- kbd
- glow
- spinner
Used in
Dependencies
lucide-react
Import
import { VoiceButton } from "@beamline/voice-button";
Get it
Voice button is part of Beamline UI. Install the parts you need in your React app as compiled packages or editable source. Get Beamline · Connect your agent
More in Voice & audio
- Recorded answer: A spoken answer against a time limit: record (the microphone asked for first, a blocked one said with what to do), the running time against the limit…
- Orb: The agent's presence: a thin ring of light around a lens in the brand's hue that holds still at rest, sends an arc round while thinking and widens with…
- Call grid: The people on a video call, laid out for the room they are given: tiles as large as the space allows at the camera's shape, or the person talking (or a…
- Bar visualizer: A row of bars that says what a voice agent is doing: a sweep while connecting, the person's voice while listening, a slow breath while thinking, the…
- Matrix: A dot-matrix display: animated frame sets (loading, pulse, wave, syncing), text and digits in a 5×7 font, or a VU meter of levels or a live source. One…
- Transcript viewer: A recording and its words together: the spoken word lights up as it plays and the transcript follows it, any word or paragraph time plays from there…
- Waveform: The shape of a recording: one bar per slice of loudness, fitted to any width, with the played part in the accent, unmeasured slices hatched and a loading…
- Live waveform: Loudness drawn as it happens: a scrolling history of the microphone (or any live source) or its spectrum, a calm processing state while words are…
- Conversation bar: The control bar of a voice call with an agent: one button to call and hang up, the agent's state as bars, a call timer, mute, and typing when talking is…
- Audio player: One audio element and its controls: play with a loading state, a scrub bar with time, skip, speed and a playlist whose rows play into the same player…
- Scrub bar: A seekable timeline for audio or video: elapsed and total time, what has loaded, chapter marks, a time preview under the pointer, and the full keyboard…
- Speech input: A text field you can speak into: the mic dictates through any speech-to-text provider, the phrase being heard shows apart from the finished words, and…
- Voice picker: Choose a text-to-speech voice from a searchable list (name, accent, tone, use) and hear it first: each voice has its own orb, previews play one at a time…
- Microphone selector: Choose the microphone, test it with a live level and mute it, with every permission and device state spelled out: not yet allowed, blocked (and how to…