Waveform
A static waveform of a clip with a smooth playhead, seeking, hover time, regions and markers.
Installation
$ pnpm dlx shadcn@latest add @audiocn/waveformUsage
import { Waveform } from "@/components/ui/waveform";const player = useAudioPlayer({ src });
const { peaks, duration } = useWaveformData(src);
<Waveform
duration={duration}
onSeekCommitted={player.seek}
peaks={peaks}
time={player.time}
/>;Pass time (a frame source) for a playhead that moves every frame without re-rendering React, or currentTime for plain controlled use.
Anatomy
<Waveform>
<WaveformCanvas />
<WaveformCursor />
<WaveformHover />
<WaveformRegion />
<WaveformMarker />
</Waveform>Examples
Variants
bars
mirror
line
Regions and markers
Intro ends
Clip 0:09 – 0:22
Theming
| Variable or attribute | Meaning |
|---|---|
--waveform | Unplayed colour, default muted-foreground |
--waveform-progress | Played colour, default primary |
--waveform-cursor | Playhead colour |
--waveform-position | Live playhead position, 0..1 |
data-loading, data-dragging, data-disabled | State |
Accessibility
When interactive, the waveform is a slider with aria-valuetext such as "1:24 of 3:40". Arrow keys seek by step, Shift by largeStep, and Home and End jump to the ends. Region edges are separate sliders.
API reference
Waveform
Prop
Type
WaveformRegion
Prop
Type
WaveformMarker
Prop
Type