Skip to content

ReferenceSliders

media-volume-slider

A slider component for controlling media playback volume

Import

import '@videojs/html/ui/volume-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-value';

Anatomy

<media-volume-slider>
  <media-slider-track>
    <media-slider-fill></media-slider-fill>
  </media-slider-track>
  <media-slider-thumb></media-slider-thumb>
  <media-slider-preview>
    <media-slider-value type="pointer"></media-slider-value>
  </media-slider-preview>
</media-volume-slider>

Behavior

Controls the media volume level. The slider maps its 0–100 internal range to the media’s 0–1 volume scale. When the media is muted, the fill level drops to 0 regardless of the stored volume value.

When volumeAvailability is not "available", the element receives native hidden, data-hidden, and disabled ARIA semantics. This is independent of mutedAvailability, which controls whether the mute button is shown.

Styling

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

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

Accessibility

Renders with role="slider" and an automatic aria-label that resolves to “Volume” from the active locale. Override with the label prop. Keyboard controls:

  • Arrow Left / Arrow Right: step by step increment
  • Page Up / Page Down: step by largeStep increment
  • Home: set volume to 0
  • End: set volume to max

Scroll wheel support:

  • Mouse wheel / trackpad scroll: adjusts volume by wheelStep increment (default 5)

Examples

Nest sub-components for full control over the slider’s DOM structure. This example includes a track, fill bar, draggable thumb, and a tooltip that shows the volume percentage on hover.

Unmute Mute
<video-player class="video-player">
  <media-container>
    <video src="https://stream.mux.com/BV3YZtogl89mg9VcNBhhnHm02Y34zI1nlMuMQfAbl3dM/highest.mp4" autoplay muted playsinline loop></video>
    <media-mute-button class="media-mute-button">
      <span class="muted">Unmute</span>
      <span class="unmuted">Mute</span>
    </media-mute-button>
    <media-volume-slider class="media-volume-slider">
      <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-value type="pointer" class="media-slider-value"></media-slider-value>
    </media-volume-slider>
  </media-container>
</video-player>

API Reference

media-volume-slider

Props

PropTypeDefaultDetails
disabledboolean—
labelobject''
largeStep
attribute large-step
number—
orientation'horizontal' | 'vertical'—
stepnumberDEFAULT_VOLUME_STEP
thumbAlignment
attribute thumb-alignment
'center' | 'edge'—
wheelStep
attribute wheel-step
numberDEFAULT_VOLUME_STEP

State

State is reflected as data attributes for CSS styling.

PropertyTypeDetails
valuenumber
fillPercentnumber
pointerPercentnumber
draggingboolean
pointingboolean
interactiveboolean
orientation'horizontal' | 'vertical'
disabledboolean
thumbAlignment'center' | 'edge'
volumenumber
mutedboolean
availability'available' | 'unavailable' | 'unsupp...
hiddenboolean

Data attributes

AttributeTypeDetails
data-availability'available' | 'unavailable' | 'unsupp...
data-hidden—

CSS custom properties

VariableDescription
--media-slider-fillFill level percentage (0–100), representing the current volume level.
--media-slider-pointerPointer position percentage (0–100), tracking the cursor along the slider.

Events

EventDescription
drag-endFired when a pointer drag ends.
drag-startFired when a pointer drag starts.

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—