Documentation Index
Fetch the complete documentation index at: https://mintlify.com/konhi/elevenlabs-speech-to-text-api-ui/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The Scrub Bar is a composable audio control component that provides an interactive progress bar for seeking through audio/video content. It consists of multiple sub-components that work together through React Context to provide scrubbing functionality.Components
ScrubBarContainer
The root component that manages scrub bar state and provides context to child components.Total duration of the audio/video in seconds
Current playback position in seconds
Callback fired when user scrubs to a new position. Receives the new time in seconds.
Callback fired when user starts scrubbing (pointer down)
Callback fired when user finishes scrubbing (pointer up)
Additional CSS classes. Default container uses
flex flex-col gap-2ScrubBarTrack
The interactive track area where users can click and drag to scrub.Additional CSS classes. Default track uses
relative w-full cursor-pointerChild components (typically ScrubBarProgress and ScrubBarThumb)
- Handles pointer events for click-and-drag scrubbing
- Calculates time position from mouse/touch coordinates
- Manages global pointer events during drag
- Stores current value in
data-scrub-valueattribute
ScrubBarProgress
Visual progress indicator that fills based on current playback position.Additional CSS classes. Default height is
h-2value, which is automatically calculated from context.
ScrubBarThumb
Draggable thumb indicator that shows the current position.Additional CSS classes. Default styles:
absolute top-1/2 size-3 -translate-x-1/2 -translate-y-1/2 rounded-full bg-primaryOptional content inside the thumb
- Positioned absolutely using
left: ${progress}% - Pointer events disabled (
pointer-events-none) - Automatically centered on track
ScrubBarTimeLabel
Formatted time display component.Time value in seconds to display
Custom formatter function. Defaults to
formatTimestamp which displays as M:SSAdditional CSS classes. Default styles:
text-xs text-muted-foreground- Formats time as
M:SS(e.g.,0:00,3:42,12:05) - Handles invalid/negative values by returning
"0:00"
Usage Example
Basic Usage
With Audio Control
Custom Time Format
Real-World Example
From the TranscriptViewer component (src/components/ui/transcript-viewer.tsx:328):
Implementation Details
Context API
The scrub bar uses React Context to share state between components:Pointer Event Handling
TheScrubBarTrack component implements advanced pointer event handling:
- Pointer Down: Captures initial click position and starts scrubbing
- Pointer Move: Tracks drag movement globally (window-level)
- Pointer Up: Ends scrubbing and cleans up event listeners
Time Calculation
Time is calculated from pointer position using:Styling
All components support Tailwind CSS classes and use thecn() utility for class merging:
- Container: Default
flex flex-col gap-2 - Track: Default
relative w-full cursor-pointer - Progress: Default
h-2(via Progress component) - Thumb: Default
absolute top-1/2 size-3 -translate-x-1/2 -translate-y-1/2 rounded-full bg-primary - Time Label: Default
text-xs text-muted-foreground
Accessibility
- Uses semantic HTML elements
- Pointer events support touch and mouse input
- Visual feedback through cursor changes
- Time values stored in
data-scrub-valueattribute for testing/debugging
Related Components
- Form Controls - Other UI components in the design system
- TranscriptViewer - Higher-level component using ScrubBar