WaveformScrubber

An audio seek bar drawn as a waveform. The played part fills with the accent, hovering previews a time, dragging scrubs, and arrow keys step five seconds. Media.

Open playground
0:00-3:34

About

WaveformScrubber is a React component in the Media category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { WaveformScrubber } from "@ashutoshswamy/smoui" and set duration, value, peaks among its 5 props.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

TSX
import { WaveformScrubber } from "@ashutoshswamy/smoui";

<WaveformScrubber duration={214} value={time} onChange={(s) => (audio.currentTime = s)} peaks={peaks} />

Props 5

duration

Length in seconds.

number
value / defaultValue / onChange

Playhead in seconds. onChange fires while dragging and on every key press.

number
peaks

Bar heights from 0 to 1. Left out, a placeholder shape is drawn.

number[]
label

Accessible name.

stringdefault "Seek"
height

Height of the waveform in px.

numberdefault 56