ReferenceDisplay
VolumeIndicator
Display temporary visual feedback for keyboard and gesture volume actions
Import
Anatomy
Behavior
VolumeIndicator displays feedback for toggleMuted and volumeStep actions emitted by a Hotkey or Gesture in the same player 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:
Value displays the rounded percentage from 0% through 100%. Fill receives the same percentage through --media-volume-fill. Nest Value inside 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.
VolumeIndicator.Root stops rendering after its close transition.
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 the Fill part, not the Root. Read it from a Fill selector when sizing a progress treatment.
React renders standard DOM elements. Add separate className values to the Root and Fill:
Accessibility
VolumeIndicator is visual feedback and does not create a live region. Keep volume and mute available through keyboard-operable controls, and pair the player with StatusAnnouncer when state changes should be announced to screen readers. Do not make VolumeIndicator.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%