Skip to content
FrameworkStyle

media-volume-popover

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

Import

import '@videojs/html/ui/volume-popover';

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

VolumePopover 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 HTML 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. HTML also receives native hidden and data-hidden when it cannot.

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

Owns volume availability and the popover interaction lifecycle.

Props

PropTypeDefaultDetails
align'start' | 'center' | 'end'
closeDelaynumber
closeOnEscapeboolean
closeOnOutsideClickboolean
defaultOpenboolean
delaynumber
modalboolean | 'trap-focus'
openboolean
openOnHoverboolean
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'
availabilityMediaFeatureAvailability
hiddenboolean

Data attributes

AttributeTypeDetails
data-open
data-side'top' | 'bottom' | 'left' | 'right'
data-align'start' | 'center' | 'end'
data-starting-style
data-ending-style
data-availabilityMediaFeatureAvailability
data-hidden

Events

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