Skip to content

ReferenceMenus

media-volume-popover

A volume-aware popover that keeps mute available when volume level controls are unavailable

Import

import '@videojs/html/ui/volume-popover';
import '@videojs/html/ui/mute-button';
import '@videojs/html/ui/volume-slider';
import '@videojs/html/ui/slider-track';
import '@videojs/html/ui/slider-fill';
import '@videojs/html/ui/slider-thumb';

Anatomy

<media-mute-button commandfor="volume-popup"></media-mute-button>
<media-volume-popover id="volume-popup">
  <media-volume-slider></media-volume-slider>
</media-volume-popover>

Behavior

<media-volume-popover> combines popover behavior with volume availability. When volume level controls are unavailable, it closes and omits the popup while keeping the mute trigger rendered. This lets media with fixed volume keep mute control without exposing a nonfunctional slider.

The trigger can target the popup with commandfor. An immediately adjacent trigger is linked automatically when neither element has an authored ID.

Styling

The popup reflects data-availability="available" while it can render volume controls.

When it cannot, the element also receives native hidden and data-hidden.

media-volume-popover[data-open] {
  opacity: 1;
}

Accessibility

The trigger receives aria-haspopup, aria-expanded, and aria-controls while the volume popup is available. When only mute is available, the trigger keeps the mute button’s own accessible name and behavior without popup ARIA.

Examples

Basic usage

Unmute Mute
<video-player class="html-volume-popover-basic">
  <media-container>
    <video src="https://stream.mux.com/BV3YZtogl89mg9VcNBhhnHm02Y34zI1nlMuMQfAbl3dM/highest.mp4" autoplay muted playsinline loop></video>
    <div class="html-volume-popover-basic__controls">
      <media-mute-button commandfor="volume-popover-demo" class="html-volume-popover-basic__trigger">
        <span class="muted">Unmute</span>
        <span class="unmuted">Mute</span>
      </media-mute-button>
      <media-volume-popover id="volume-popover-demo" open-on-hover side="top" class="html-volume-popover-basic__popup">
        <media-volume-slider orientation="vertical" class="html-volume-popover-basic__slider">
          <media-slider-track class="html-volume-popover-basic__track">
            <media-slider-fill class="html-volume-popover-basic__fill"></media-slider-fill>
          </media-slider-track>
          <media-slider-thumb class="html-volume-popover-basic__thumb"></media-slider-thumb>
        </media-volume-slider>
      </media-volume-popover>
    </div>
  </media-container>
</video-player>

API Reference

media-volume-popover

A volume-aware popover that keeps its adjacent mute trigger available as a fallback.

Props

PropTypeDefaultDetails
align'start' | 'center' | 'end'—
boundary'viewport' | 'container' | string & {}—
closeDelay
attribute close-delay
number—
closeOnEscape
attribute close-on-escape
boolean—
closeOnOutsideClick
attribute close-on-outside-click
boolean—
defaultOpen
attribute default-open
boolean—
delaynumber—
modalboolean | 'trap-focus'—
openboolean—
openOnHover
attribute open-on-hover
boolean—
side'top' | 'bottom' | 'left' | 'right'—

State

State is reflected as data attributes for CSS styling.

PropertyTypeDetails
transitionStartingboolean
transitionEndingboolean
openboolean
status'idle' | 'starting' | 'ending'
side'top' | 'bottom' | 'left' | 'right'
align'start' | 'center' | 'end'
modalboolean | 'trap-focus'
availability'available' | 'unavailable' | 'unsupp...
hiddenboolean

Data attributes

AttributeTypeDetails
data-open—
data-side'top' | 'bottom' | 'left' | 'right'
data-align'start' | 'center' | 'end'
data-starting-style—
data-ending-style—
data-availability'available' | 'unavailable' | 'unsupp...
data-hidden—

Events

EventDescription
open-changeFired when the popover's open state changes.