ReferenceDisplay
media-volume-indicator
Display temporary visual feedback for keyboard and gesture volume actions
Import
Anatomy
Behavior
<media-volume-indicator> displays feedback for toggleMuted and volumeStep actions emitted by a <media-hotkey> or <media-gesture> in the same player <media-container>. It does not react to mute buttons, volume sliders, direct player-store changes, or volume changes on their own.
The input event arrives before its action is resolved. The indicator uses the media snapshot from that moment to predict the next mute state and volume. toggleMuted predicts the opposite mute state. volumeStep adds its value to the snapshot volume and clamps the result from 0 to 1. A step whose clamped result is above 0 also predicts that mute will clear.
The root exposes the predicted level:
<media-volume-indicator-value> displays the rounded percentage from 0% through 100%. <media-volume-indicator-fill> receives the same percentage through --media-volume-fill. Nest the value inside the fill so the progress treatment and text form one visual unit.
The indicator closes after closeDelay, which defaults to 800 milliseconds. Repeated handled actions update the current value and restart that close timer without replaying the entry transition. Each update uses the latest media snapshot; the component does not independently accumulate volume steps.
The element remains in the document with hidden until the next handled action.
When a nonzero volumeStep cannot move past an already-clamped edge, data-min or data-max is present for 300 milliseconds. Hitting the same edge again briefly clears the attribute, then restores it on the next task so a CSS boundary animation can restart. Merely reaching 0% or 100% does not trigger the boundary attribute until another step tries to move farther.
Styling
--media-volume-fill is set on <media-volume-indicator-fill>, not <media-volume-indicator>. Read it from a fill selector when sizing a progress treatment.
Accessibility
<media-volume-indicator> is visual feedback and does not create a live region. Keep volume and mute available through keyboard-operable controls, and pair the player with <media-status-announcer> when state changes should be announced to screen readers. Do not make <media-volume-indicator-value> a live region.
Examples
Basic Usage
Focus the player, then press M to mute or unmute. Use Arrow Up and Arrow Down to adjust volume by 5%.
Focus the player · M: mute · ↑/↓: volume ±5%