Components
Voice Sample Player
An audio player pill with a waveform equalizer that reveals on play.
A voice-sample row: press play and the name slides up and out, a lime
waveform equalizer slides in and starts oscillating, and the button
morphs from play to pause. Pass a src to play real audio. Driven by GSAP.
Ada Lovelace
British female · warm & precise
Grace Hopper
American female · clear & confident
Alan Turing
British male · calm & thoughtful
Installation
pnpm dlx shadcn@latest add @tween-ui/voice-sample-playerUsage
import VoiceSamplePlayer from '@/components/tweenui/media/voice-sample-player';
export default function Page() {
return (
<VoiceSamplePlayer
name="Ada Lovelace"
description="British female · warm & precise"
avatar="/avatars/ada.jpg"
src="/audio/ada-sample.mp3"
/>
);
}To keep only one player active at a time, control playing from the parent:
const [activeId, setActiveId] = useState<string | null>(null);
<VoiceSamplePlayer
name="Ada Lovelace"
playing={activeId === 'ada'}
onPlayingChange={(next) => setActiveId(next ? 'ada' : null)}
/>;Props
| Prop | Type | Default | Description |
|---|---|---|---|
name | string | — | Speaker / voice name. |
description | string | — | Short line under the name (accent, tone, …). |
avatar | string | — | Avatar image URL; falls back to the name initials. |
avatarAlt | string | name | Alt text for the avatar. |
src | string | — | Audio file to play. Omit to animate without sound. |
playing | boolean | — | Controlled playing state. |
defaultPlaying | boolean | false | Uncontrolled initial state. |
onPlayingChange | (playing: boolean) => void | — | Fires when playback starts or stops. |
Accessibility
The play button is a real <button> with aria-pressed and an
aria-label that flips between "Play" and "Pause". The waveform is decorative
(aria-hidden). Under prefers-reduced-motion: reduce the label and waveform
swap instantly with no slide, and the equalizer holds a static shape.