Scrub Bar

A time bar for any media timeline: played and buffered, markers like keyframe times, and the time under the pointer.

0:02.4

In use

Inside the Video Studio's player, marking where each keyframe landed. Generate a clip to see it.

Lumen
CreateEditVideo
240 credits

Your video will appear here

0s
40 credits

Installation

pnpm dlx shadcn@latest add https://mgp.paukraft.com/r/scrub-bar.json

ScrubBar

Not tied to a <video>: pass in its time and seek on change. The Video Player wires it for you; useMediaState does for any other clip.

PropTypeDefault
valuenumber

The time, in seconds. Or defaultValue, uncontrolled.

—
durationnumber

Length of the timeline, in seconds. Disabled while 0.

—
onValueChange(seconds: number) => void

Called as the handle moves: seek here.

—
onValueCommit(seconds: number) => void

Called when a drag ends, a press lands or a key steps.

—
bufferedTimeRange[]

Loaded spans as [start, end] seconds, drawn behind progress.

—
step / largeStepnumber

What the arrow keys and Shift + arrows step by, in seconds. Dragging snaps to step.

FRAME / 1
format(seconds: number) => string

Labels the hover time and the handle for screen readers.

formatTime
childrenReactNode

Go on the track, e.g. markers.

—

Parts

PropTypeDefault
ScrubBarRootBase UI Slider.Root props

The timeline and its pointer, without layers.

—
ScrubBarTrackSlider.Track props

The bar; thickens on hover.

—
ScrubBarProgressSlider.Indicator props

The track up to the value.

—
ScrubBarBuffered{ ranges: TimeRange[] }

What the media has loaded.

—
ScrubBarRange{ start: number; end: number }

A span of the track, e.g. a trim range.

—
ScrubBarMarker{ time: number }

A notch, e.g. where a keyframe lands.

—
ScrubBarThumbSlider.Thumb props

The handle. On hover devices it shows while the bar is used.

—
ScrubBarHover<span> props

The time under the pointer, above it.

—
useScrubBar() => { duration, hover, format, toPercent }

For your own layers.

—

Helpers

PropTypeDefault
formatTime(seconds: number, span?: number) => string

m:ss, with tenths when span, e.g. the duration, is under a minute: "0:07.5", "1:04".

—
FRAMEnumber

1/24: one frame at 24 fps.

—