Skip to content

ReferenceSliders

media-slider

A composable slider component with track, fill, thumb, preview, and value parts

Import

import '@videojs/html/ui/slider';
import '@videojs/html/ui/slider-track';
import '@videojs/html/ui/slider-fill';
import '@videojs/html/ui/slider-thumb';
import '@videojs/html/ui/slider-preview';
import '@videojs/html/ui/slider-thumbnail';
import '@videojs/html/ui/slider-value';

Anatomy

<media-slider>
  <media-slider-track>
    <media-slider-fill></media-slider-fill>
  </media-slider-track>
  <media-slider-thumb></media-slider-thumb>
  <media-slider-preview>
    <media-slider-thumbnail>
      <img alt="" decoding="async" />
    </media-slider-thumbnail>
    <media-slider-value type="pointer"></media-slider-value>
  </media-slider-preview>
</media-slider>

Behavior

The base slider provides a generic range input. It manages value, pointer tracking, and drag interactions. The time slider and volume slider add media-specific bindings. The time slider also provides parts for rendering chapter ranges and the chapter at the current interaction position.

media-slider-thumbnail supplies the pointer value and draws the image in its shadow DOM. Supply an <img> child to replace it: the element controls src and srcset on your image, and other children can provide loading indicators or overlays.

The slider supports vertical orientation via the orientation prop (defaults to "horizontal").

Styling

Use CSS custom properties to position fill, thumb, and preview elements:

media-slider-fill {
  width: var(--media-slider-fill);
}

media-slider-thumb {
  left: var(--media-slider-fill);
}

Style based on interaction state:

media-slider[data-interactive] media-slider-track {
  height: 6px;
}
media-slider[data-pointing] media-slider-preview {
  opacity: 1;
}

Accessibility

Renders with role="slider" and automatic ARIA attributes (aria-valuemin, aria-valuemax, aria-valuenow, aria-valuetext). Override the label with the label prop. Keyboard controls:

  • Arrow Left / Arrow Right: step by step increment
  • Page Up / Page Down: step by largeStep increment
  • Home: jump to minimum
  • End: jump to maximum

Examples

Basic

A slider with track, fill, and thumb.

<div class="demo">
  <media-slider class="media-slider" value="50">
    <media-slider-track class="media-slider-track">
      <media-slider-fill class="media-slider-fill"></media-slider-fill>
    </media-slider-track>
    <media-slider-thumb class="media-slider-thumb"></media-slider-thumb>
  </media-slider>
</div>

With Preview

A slider with a pointer-tracking preview that displays the value at the current pointer position.

<div class="demo">
  <media-slider class="media-slider" value="50">
    <media-slider-track class="media-slider-track">
      <media-slider-fill class="media-slider-fill"></media-slider-fill>
    </media-slider-track>
    <media-slider-thumb class="media-slider-thumb"></media-slider-thumb>
    <media-slider-preview class="preview">
      <media-slider-value type="pointer" class="media-slider-value"></media-slider-value>
    </media-slider-preview>
  </media-slider>
</div>

API Reference

media-slider

Props

PropTypeDefaultDetails
disabledbooleanfalse
labelobject''
largeStep
attribute large-step
number10
maxnumber100
minnumber0
orientation'horizontal' | 'vertical''horizontal'
stepnumber1
thumbAlignment
attribute thumb-alignment
'center' | 'edge''center'
valuenumber0

State

State is reflected as data attributes for CSS styling.

PropertyTypeDetails
valuenumber
fillPercentnumber
pointerPercentnumber
draggingboolean
pointingboolean
interactiveboolean
orientation'horizontal' | 'vertical'
disabledboolean
thumbAlignment'center' | 'edge'

Data attributes

AttributeTypeDetails
data-dragging—
data-pointing—
data-interactive—
data-orientation'horizontal' | 'vertical'
data-disabled—

CSS custom properties

VariableDescription
--media-slider-fillFill level percentage (0–100).
--media-slider-pointerPointer position percentage (0–100).
--media-slider-bufferBuffer level percentage (0–100).

Events

EventDescription
drag-endFired when a pointer drag ends.
drag-startFired when a pointer drag starts.
value-changeFired while the slider value changes during an interaction.
value-commitFired when an interaction commits the slider value.

media-slider-buffer

Displays the buffered range on the slider track.

media-slider-fill

Displays the filled portion from start to the current value.

media-slider-preview

Positioning container for preview content that tracks the pointer along the slider.

Props

PropTypeDefaultDetails
overflow'clamp' | 'visible'—

Data attributes

AttributeTypeDetails
data-dragging—
data-pointing—
data-interactive—
data-orientation'horizontal' | 'vertical'
data-disabled—

media-slider-thumb

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

Data attributes

AttributeTypeDetails
data-dragging—
data-pointing—
data-interactive—
data-orientation'horizontal' | 'vertical'
data-disabled—

media-slider-track

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

media-slider-value

Writes the formatted current or pointer slider value into its own text content, replacing any children.

Props

PropTypeDefaultDetails
type'current' | 'pointer'—

Data attributes

AttributeTypeDetails
data-dragging—
data-pointing—
data-interactive—
data-orientation'horizontal' | 'vertical'
data-disabled—

media-slider-thumbnail

<media-thumbnail> whose time follows the slider pointer. Left empty, it draws an image of its own; supply an <img> child to compose overlays or loading indicators beside the image it controls.