FrameworkStyle

VolumeSlider

A slider component for controlling media volume

Features

  • Supports both horizontal and vertical orientations
  • Displays current volume level
  • Reflects muted state
  • Keyboard accessible (Arrow keys for volume adjustment)
  • Touch-friendly drag interaction

Example

import { VolumeSlider } from '@videojs/react';
import styles from './VolumeSlider.module.css';

/**
 * Basic VolumeSlider example demonstrating:
 * - Volume level visualization
 * - Horizontal orientation
 * - CSS Modules for scoped styling
 * - Data attribute selectors for state-based styling
 *
 * Note: This component must be used within a MediaProvider context.
 * See the usage example in the documentation.
 */
export function BasicVolumeSlider() {
  return (
    <VolumeSlider.Root className={styles.root} orientation="horizontal">
      <VolumeSlider.Track className={styles.track}>
        <VolumeSlider.Progress className={styles.progress} />
      </VolumeSlider.Track>
      <VolumeSlider.Thumb className={styles.thumb} />
    </VolumeSlider.Root>
  );
}

Compound Components

VolumeSlider is composed of multiple sub-components:

VolumeSlider.Root

The container component that manages state and interactions.

Props:

  • orientation?: 'horizontal' | 'vertical' - Slider orientation (default: ‘horizontal’)
  • All standard div props

VolumeSlider.Track

The background track element that contains the progress indicator.

VolumeSlider.Progress

Visual indicator showing the current volume level.

VolumeSlider.Thumb

The draggable handle that indicates and controls the current volume level.

Data Attributes

The VolumeSlider automatically sets data attributes:

  • data-orientation - Current orientation (‘horizontal’ or ‘vertical’)
  • data-muted - Present when volume is muted
  • data-volume-level - Volume level category: ‘high’ (>50%), ‘medium’ (25-50%), ‘low’ (1-24%), or ‘off’ (0%)

Use these attributes for state-based styling in your CSS.

CSS Variables

The component exposes CSS variables for positioning:

  • --slider-fill - Percentage of volume level (0-100%)
  • --slider-pointer - Percentage of pointer position (0-100%)

Accessibility

  • Includes proper ARIA role (slider)
  • Keyboard accessible (Arrow keys, Home, End)
  • Screen reader announcements for volume values
  • Proper aria-valuemin, aria-valuemax, aria-valuenow attributes
VideoJS