FrameworkStyle

media-mute-button

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

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">
    <media-container>
        <video
            src="https://stream.mux.com/BV3YZtogl89mg9VcNBhhnHm02Y34zI1nlMuMQfAbl3dM/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>
    </media-container>
</video-player>

Volume Levels

Off Low Medium High
<video-player class="html-mute-button-volume-levels">
    <media-container>
        <video
            src="https://stream.mux.com/BV3YZtogl89mg9VcNBhhnHm02Y34zI1nlMuMQfAbl3dM/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>
    </media-container>
</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 Type
data-muted
data-volume-level 'off' | 'low' | 'medium' | 'high'