FrameworkStyle

media-mute-button

A button component for muting and unmuting audio playback

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.

Styling

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; }

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="html-mute-button-basic">
    <video
        src="https://stream.mux.com/lhnU49l1VGi3zrTAZhDm9LUUxSjpaPW9BL4jY25Kwo4/highest.mp4"
        autoplay
        muted
        playsinline
        loop
    ></video>
    <media-mute-button class="html-mute-button-basic__button">
        <span class="show-when-muted">Unmute</span>
        <span class="show-when-unmuted">Mute</span>
    </media-mute-button>
</video-player>

Volume Levels

Off Low Medium High
<video-player class="html-mute-button-volume-levels">
    <video
        src="https://stream.mux.com/lhnU49l1VGi3zrTAZhDm9LUUxSjpaPW9BL4jY25Kwo4/highest.mp4"
        autoplay
        muted
        playsinline
        loop
    ></video>
    <media-mute-button class="html-mute-button-volume-levels__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>
</video-player>

API Reference

Props

Prop Type Default
disabled boolean false
label string | function ''

State

State is reflected as data attributes for CSS styling.

Property Type
volumeLevel 'off' | 'low' | 'medium' | 'high'
muted boolean

Data attributes

Attribute Description
data-muted Present when the media is muted.
data-volume-level Indicates the volume level.
VideoJS