Skip to content
FrameworkStyle

media-mute-button

Accessible mute/unmute button with keyboard support and volume state reflection

Import

import '@videojs/html/ui/mute-button';

Anatomy

<media-mute-button></media-mute-button>

Behavior

Toggles mute on and off, and exposes a derived volumeLevel based on the current volume and mute state.

Mute availability is separate from volume-level availability because some media can accept a mute command without supporting volume changes. When mute is unavailable or unsupported, the HTML custom element receives the native hidden attribute and the React component returns null. Toggling is also ignored while mute is unavailable.

Styling

Attribute Values Description
data-muted Present / absent Present when the media is muted
data-volume-level "off" | "low" | "medium" | "high" Current volume level
data-availability "available" | "unavailable" | "unsupported" Whether the media can be muted
data-hidden Present / absent Present on the HTML element while mute is unavailable or unsupported

Style the button based on muted state:

media-mute-button[data-muted] .icon-muted { display: inline; }
media-mute-button:not([data-muted]) .icon-unmuted { display: inline; }

Use data-volume-level for multi-level icon switching:

media-mute-button[data-volume-level="off"] .icon-off { display: inline; }
media-mute-button[data-volume-level="low"] .icon-low { display: inline; }
media-mute-button[data-volume-level="medium"] .icon-medium { display: inline; }
media-mute-button[data-volume-level="high"] .icon-high { display: inline; }

Unavailable and unsupported buttons are hidden automatically. No availability selector or extra hiding CSS is required.

Accessibility

Renders a <button> with an automatic aria-label: “Unmute” when muted, “Mute” when unmuted. Override with the label prop. Keyboard activation: Enter / Space.

Examples

Basic Usage

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-container>
</video-player>

Volume Levels

Off Low Medium High
<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="level-off">Off</span>
      <span class="level-low">Low</span>
      <span class="level-medium">Medium</span>
      <span class="level-high">High</span>
    </media-mute-button>
  </media-container>
</video-player>

API Reference

Props

PropTypeDefaultDetails
disabledbooleanfalse
labelobject''

State

State is reflected as data attributes for CSS styling.

PropertyTypeDetails
mutedboolean
label{ key: string; text: string } | string
volumeLevel'off' | 'low' | 'medium' | 'high'
availabilityMediaFeatureAvailability
hiddenboolean

Data attributes

AttributeTypeDetails
data-muted
data-volume-level'off' | 'low' | 'medium' | 'high'
data-availabilityMediaFeatureAvailability
data-hidden