FrameworkStyle

TimeSlider

A slider component for seeking through media playback time

Anatomy

<TimeSlider.Root />

Behavior

Displays and controls the current playback position. Dragging the slider seeks the media. The fill level reflects currentTime / duration as a percentage, and the buffer level shows how much media has been buffered.

Seeking is throttled via the commitThrottle prop (default 100ms) to avoid overwhelming the media element during drag operations.

Styling

Use CSS custom properties to style the fill, pointer, and buffer levels:

media-time-slider::before {
  width: calc(var(--media-slider-fill) * 1%);
}

Use data-seeking to style during active seek operations:

media-time-slider[data-seeking] {
  opacity: 0.8;
}

Accessibility

Renders with role="slider" and automatic aria-label of “Seek”. Override with the label prop. Keyboard controls:

  • Arrow Left / Arrow Right: step by step increment
  • Page Up / Page Down: step by largeStep increment
  • Home: seek to start
  • End: seek to end

Examples

Nest sub-components for full control over the slider’s DOM structure. This example includes a track, fill bar, buffer indicator, draggable thumb, and a tooltip that shows the pointed-at time.

0:00
import { createPlayer, TimeSlider } from '@videojs/react';
import { Video, videoFeatures } from '@videojs/react/video';

import './WithParts.css';

const Player = createPlayer({ features: videoFeatures });

export default function WithParts() {
  return (
    <Player.Provider>
      <Player.Container className="react-time-slider-parts">
        <Video
          src="https://stream.mux.com/lhnU49l1VGi3zrTAZhDm9LUUxSjpaPW9BL4jY25Kwo4/highest.mp4"
          autoPlay
          muted
          playsInline
          loop
        />
        <TimeSlider.Root className="react-time-slider-parts__slider">
          <TimeSlider.Track className="react-time-slider-parts__track">
            <TimeSlider.Buffer className="react-time-slider-parts__buffer" />
            <TimeSlider.Fill className="react-time-slider-parts__fill" />
          </TimeSlider.Track>
          <TimeSlider.Thumb className="react-time-slider-parts__thumb" />
          <TimeSlider.Value type="pointer" className="react-time-slider-parts__value" />
        </TimeSlider.Root>
      </Player.Container>
    </Player.Provider>
  );
}

API Reference

Root

Props

Prop Type Default
commitThrottle number 100
disabled boolean SliderCore.defaultProps.disabled
label string | function 'Seek'
largeStep number SliderCore.defaultProps.largeStep
orientation 'horizontal' | 'vertical' SliderCore.defaultProps.orientation
step number SliderCore.defaultProps.step
thumbAlignment 'center' | 'edge' SliderCore.defaultProps.thumbAlignment

State

State is accessible via the render, className, and style props.

Property Type
bufferPercent number
value number
fillPercent number
pointerPercent number
dragging boolean
pointing boolean
interactive boolean
orientation 'horizontal' | 'vertical'
disabled boolean
thumbAlignment 'center' | 'edge'
duration number
currentTime number
seeking boolean

Data attributes

Attribute Type
data-seeking

CSS custom properties

Variable
--media-slider-fill
--media-slider-pointer
--media-slider-buffer

Buffer

Displays the buffered range on the slider track.

Data attributes

Attribute Type
data-dragging
data-pointing
data-interactive
data-orientation 'horizontal' | 'vertical'
data-disabled

Fill

Displays the filled portion from start to the current value.

Data attributes

Attribute Type
data-dragging
data-pointing
data-interactive
data-orientation 'horizontal' | 'vertical'
data-disabled

Thumb

Draggable handle for setting the slider value. Receives focus and handles keyboard interaction.

Data attributes

Attribute Type
data-dragging
data-pointing
data-interactive
data-orientation 'horizontal' | 'vertical'
data-disabled

Track

Contains the slider's visual track and interactive hit zone.

Data attributes

Attribute Type
data-dragging
data-pointing
data-interactive
data-orientation 'horizontal' | 'vertical'
data-disabled

Value

Displays a formatted text representation of the slider value. Renders an <output> element.

Props

Prop Type Default
format ((value: number) => string)
type "current" | "pointer"

Data attributes

Attribute Type
data-dragging
data-pointing
data-interactive
data-orientation 'horizontal' | 'vertical'
data-disabled
VideoJS