components / waveform

waveform.

a track's amplitude envelope with the played portion filled in, seekable by click. bars are elements rather than a canvas — crisp at every dpr, hoverable, and the fill is a css transition instead of a repaint loop. ships samplePeaks() to downsample raw pcm.

seekable

38% — click anywhere on the wave

mirrored, taller bars
inline, unplayed
installation
bunx @justin06lee/chrome@latest add waveform
props
nametypedefaultdescription
peaks *number[]-peak amplitudes 0–1, left to right; one entry per bar. samplePeaks() builds these from pcm.
progressnumber0how far through, 0–1.
onSeek(ratio: number) => void-makes the waveform seekable; ratio is 0–1.
heightnumber48height in px.
barWidthnumber3widest a bar may get; bars flex to fill the container up to this.
gapnumber2gap between bars in px.
mirrorbooleanfalsemirror each bar around the centre line instead of standing it on the floor.
accentstring'#fff'css color of the played bars.
floornumber0.06shortest bar as a fraction of the tallest, so silence still has a spine.
ariaLabelstring'waveform'
classNamestring-