Audio player
A React component in Beamline's Voice & audio category.
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. Use the ready layouts or compose the parts.
Use it for
- Call recordings, voice notes and generated speech in an app.
- A list of recordings that play one at a time in a shared player.
Not for
- Video (video).
- A transcript that follows the audio word by word (transcript-viewer).
- Only a position control for your own player (scrub-bar).
Anatomy
- root (one <audio>)
- play button (loading while buffering; play and pause swap in place)
- title and subtitle
- scrub bar with elapsed and total time
- skip back / forward
- speed menu
- playlist (rows: state, title, subtitle, length)
- error line with retry
Variants
- layout: card, inline
States
- empty (no source)
- loading metadata (length unknown, hatched)
- paused
- playing
- buffering
- ended
- error (file failed: the words and Retry replace the title; the play button turns quiet so Retry leads)
- playlist: current row (filled disc in the accent, row tint), playing row (level bars and "Playing")
- narrow room (under 256 px: the card folds its skip buttons, the inline row its speed; the scrub bar's times move under the rail)
- wide room (640 px and up: the card sets its title beside the timeline; the playlist stays full width below)
Keyboard
- Tab reaches play, skip, the scrub bar, speed and each playlist row
- On the scrub bar: ← → seek 5 s, Page keys a tenth, Home / End, Space or K play and pause
- Speed menu: ↑ ↓ and Enter
- Playlist row: Enter or Space plays it (or pauses the one playing)
Motion
Play and pause swap in place: the glyph leaving shrinks and fades over --pui-motion-out as the other grows in over --pui-motion-in (a fade only under reduced motion). The current playlist row's tint is one plate that travels to the next recording when it is chosen or plays on. Rows tint on hover at 0 ms and let go over --pui-motion-out; a press dips the row to 0.985. The failure fades in where the title was. The playing row's level bars move only while it plays and on screen, and stop under reduced motion (the row says Playing instead).
Props
| Prop | Type | Default | Description |
|---|---|---|---|
src / title / subtitle | string | — | src: One recording. For several, pass `tracks`. title: Heading shown above the content. Defaults to no heading. subtitle: Secondary text beneath the title. Defaults to no secondary text. |
tracks | AudioTrack[] | — | Tracks offered in the shared audio player. Defaults to an empty playlist. |
value / defaultValue / onValueChange | string | — | value: Id of the loaded track: controlled with onValueChange, or uncontrolled from defaultValue (the first track). defaultValue: Initial id of the track to play when uncontrolled. Defaults to the first track id. onValueChange: Reports id of the track to play after an edit; no callback by default. |
rate / defaultRate / onRateChange | number | 1 | rate: Controlled playback speed; omit to use defaultRate. defaultRate: Initial playback speed when uncontrolled. Defaults to 1. onRateChange: Reports playback speed after a change; no callback by default. |
rates | number[] | [0.75, 1, 1.25, 1.5, 2] | Playback speed choices. Defaults to 0.75x, 1x, 1.25x, 1.5x and 2x. |
layout | "card" | "inline" | "card" | The ready layout used when there are no children. |
autoAdvance | boolean | true | Play the next track when one ends. Default true. |
onEnded | (track: AudioTrack) => void | — | Runs when the current media track reaches its end; no handler by default. |
children | ReactNode | — | Your own arrangement of the AudioPlayer… parts. |
classNames | AudioPlayerClassNames | — | 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 documented root element; no ref by default. |
AudioPlayer parts native props / ref | Button, div, span, ul or ScrubBar props | — | Built-in playback handlers and required media accessibility remain owned by the player; classNames combines player and part overrides. |
src | string | — | One recording. For several, pass `tracks`. |
title | string | — | Heading shown above the content. Defaults to no heading. |
subtitle | string | — | Secondary text beneath the title. Defaults to no secondary text. |
value | string | — | Id of the loaded track: controlled with onValueChange, or uncontrolled from defaultValue (the first track). |
defaultValue | string | — | Initial id of the track to play when uncontrolled. Defaults to the first track id. |
onValueChange | ((id: string) => void) | — | Reports id of the track to play after an edit; no callback by default. |
rate | number | — | Controlled playback speed; omit to use defaultRate. |
defaultRate | number | — | Initial playback speed when uncontrolled. Defaults to 1. |
onRateChange | ((rate: number) => void) | — | Reports playback speed after a change; no callback by default. |
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<HTMLDivElement> | — | Receives the documented root element; no ref by default. |
AudioPlayerButton.asChild | boolean | — | On AudioPlayerButton: Render the single child (a link, a Radix trigger) with the button's look instead of a <button>. |
AudioPlayerButton.tone | ButtonTone | — | On AudioPlayerButton: Market side. On primary/accent the fill becomes --pui-up (buy) or --pui-down (sell); on the quiet variants the label takes that colour. Pair it with a word or arrow: colour is never the only signal. |
AudioPlayerButton.variant | ButtonVariant | — | On AudioPlayerButton: Visual weight: primary (ink-filled), secondary, outline, ghost, danger, or accent (filled with the brand). |
AudioPlayerButton.size | ButtonSize | — | On AudioPlayerButton: Height 32 / 36 / 40 px; touch 44 px for a bottom action bar on a phone. |
AudioPlayerButton.look | BuiltInLook | — | On AudioPlayerButton: Paint this button in another look than the one in force around it (DESIGN-LANGUAGE.md "Looks"). |
AudioPlayerButton.iconOnly | boolean | — | On AudioPlayerButton: A square button holding only an icon (give it an aria-label). Decided by the children when left out: icon-only when no words sit anywhere among them (an icon, or a frame of icons), so `<span>Close</span>` is a label. |
AudioPlayerScrubber.label | string | — | On AudioPlayerScrubber: Accessible name. Default "Seek". |
AudioPlayerScrubber.disabled | boolean | — | On AudioPlayerScrubber: Prevents interaction with the control. Defaults to false. |
AudioPlayerScrubber.step | number | — | On AudioPlayerScrubber: Seconds per arrow key. Default 5. |
AudioPlayerScrubber.size | "md" | "sm" | — | On AudioPlayerScrubber: Control size within the supported size steps. Defaults to "md". |
AudioPlayerScrubber.markers | ScrubMarker[] | — | On AudioPlayerScrubber: Chapter or speaker marks; their label shows in the pointer preview. |
AudioPlayerScrubber.peaks | readonly (number | null)[] | — | On AudioPlayerScrubber: Draw the track as the recording's waveform (loudness 0–1 per slice, null where unmeasured). |
AudioPlayerScrubber.format | ((seconds: number) => string) | — | On AudioPlayerScrubber: Formats a raw numeric value for display. Defaults to minutes and seconds. |
AudioPlayerScrubber.showTime | boolean | — | On AudioPlayerScrubber: Elapsed and total time at the ends. Default true. |
AudioPlayerScrubber.onScrubbingChange | ((scrubbing: boolean) => void) | — | On AudioPlayerScrubber: Reports scrubbing state after a change; no callback by default. |
AudioPlayerSkip.asChild | boolean | — | On AudioPlayerSkip: Render the single child (a link, a Radix trigger) with the button's look instead of a <button>. |
AudioPlayerSkip.tone | ButtonTone | — | On AudioPlayerSkip: Market side. On primary/accent the fill becomes --pui-up (buy) or --pui-down (sell); on the quiet variants the label takes that colour. Pair it with a word or arrow: colour is never the only signal. |
AudioPlayerSkip.variant | ButtonVariant | — | On AudioPlayerSkip: Visual weight: primary (ink-filled), secondary, outline, ghost, danger, or accent (filled with the brand). |
AudioPlayerSkip.size | ButtonSize | — | On AudioPlayerSkip: Height 32 / 36 / 40 px; touch 44 px for a bottom action bar on a phone. |
AudioPlayerSkip.look | BuiltInLook | — | On AudioPlayerSkip: Paint this button in another look than the one in force around it (DESIGN-LANGUAGE.md "Looks"). |
AudioPlayerSkip.iconOnly | boolean | — | On AudioPlayerSkip: A square button holding only an icon (give it an aria-label). Decided by the children when left out: icon-only when no words sit anywhere among them (an icon, or a frame of icons), so `<span>Close</span>` is a label. |
AudioPlayerSkip.seconds (required) | number | — | On AudioPlayerSkip: Seconds to jump on activation; negative moves backward. Required. |
AudioPlayerSpeed.asChild | boolean | — | On AudioPlayerSpeed: Render the single child (a link, a Radix trigger) with the button's look instead of a <button>. |
AudioPlayerSpeed.tone | ButtonTone | — | On AudioPlayerSpeed: Market side. On primary/accent the fill becomes --pui-up (buy) or --pui-down (sell); on the quiet variants the label takes that colour. Pair it with a word or arrow: colour is never the only signal. |
AudioPlayerSpeed.variant | ButtonVariant | — | On AudioPlayerSpeed: Visual weight: primary (ink-filled), secondary, outline, ghost, danger, or accent (filled with the brand). |
AudioPlayerSpeed.size | ButtonSize | — | On AudioPlayerSpeed: Height 32 / 36 / 40 px; touch 44 px for a bottom action bar on a phone. |
AudioPlayerSpeed.look | BuiltInLook | — | On AudioPlayerSpeed: Paint this button in another look than the one in force around it (DESIGN-LANGUAGE.md "Looks"). |
AudioPlayerSpeed.iconOnly | boolean | — | On AudioPlayerSpeed: A square button holding only an icon (give it an aria-label). Decided by the children when left out: icon-only when no words sit anywhere among them (an icon, or a frame of icons), so `<span>Close</span>` is a label. |
AudioPlayerScrubber.stops | readonly number[] | — | On AudioPlayerScrubber: Positions the arrows step between instead of `step` (the events of a replay: each step's start and end), in seconds. |
Built from
- button
- scrub-bar
- dropdown-menu
- tooltip
Used in
Dependencies
lucide-react
Import
import { AudioPlayer, AudioPlayerButton, AudioPlayerTitle, AudioPlayerScrubber, AudioPlayerTime, AudioPlayerSkip } from "@beamline/audio-player";
Get it
Audio player 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…
- Voice button: 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…
- 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…