audio/ui
Toggle Mode D
Audio UI
Copy Registry URL
Installation
Copy to Clipboardpnpm dlx shadcn@latest add @audio-ui/scrubber
Anatomy
The scrubber is a Timeline: its bar is the ruler, with a playhead for the fill and one for the thumb.
Copy to Clipboardimport { Timeline } from "@/components/audio-ui/timeline/react"; <Timeline.Root> <Timeline.Ruler> <Timeline.Playhead /> {/* the fill */} <Timeline.Playhead /> {/* the thumb */} </Timeline.Ruler> </Timeline.Root>
Usage
Copy to Clipboardimport { createSource } from "@/components/audio-ui/primitive"; import { Scrubber } from "@/components/audio-ui/scrubber"; const position = createSource(0); // seconds; set it from your player's clock <Scrubber duration={215} onPlayingChange={(playing) => (playing ? player.play() : player.pause())} onSeek={(seconds) => player.seek(seconds)} playing={isPlaying} source={position} />;
Keyboard
The bar holds a native <input type="range">: the arrow keys move it by a second, Page Up and Page Down by ten, Home and End go to the ends. It announces the position as a clock, such as "1:15".
API reference
Props · 6
The playback position in seconds, a live value.
Length of the track, in seconds.
Whether it is playing: the button shows pause.
The play button was pressed.
The bar was pressed, dragged or moved by key.
Names the bar. Defaults to "Playback position".