Waveform Scrubber

Accessible waveform playback with drag and keyboard seeking

A compact media control with deterministic waveform bars, a responsive playhead and complete slider semantics. It can manage playback and progress internally or plug into an external audio source.

Preview

Field recording · July 090:39 of 2:22

Play, drag the waveform, or use the arrow keys.

Installation

Install the component using the CLI.

npx shadcn@latest add https://rohan.run/r/waveform-scrubber.json

Usage

Import the component:

import { WaveformScrubber } from "@/components/rohan/waveform-scrubber"

Use it in your code:

<WaveformScrubber
  label="Field recording"
  duration={142}
  defaultProgress={0.28}
  onChange={(progress) => seek(progress)}
/>

Props

PropertyTypeDefaultDescription
progress / defaultProgressnumber0Controlled or initial normalized playhead position from 0 to 1.
playing / defaultPlayingbooleanfalseControlled or initial playback state.
durationnumber86Media duration in seconds.
datareadonly number[]generatedNormalized waveform bar heights from 0 to 1.
labelstring"Audio preview"Visible media title and accessible name for the controls.
seekStepnumber5Seconds moved by each arrow-key press.
onChange(progress: number) => voidCalled whenever playback, pointer or keyboard input moves the playhead.
onPlayChange(playing: boolean) => voidCalled when the play button changes state.
disabledbooleanfalseDisables playback and seeking interactions.
Components