FrameworkStyle

media-controls

Container component for composing and auto-hiding video player controls on user interaction

Anatomy

Import the component and assemble its parts:

<media-controls>
  <media-controls-group></media-controls-group>
</media-controls>

Behavior

If the user is active, or if the video is paused, this component will show controls. Otherwise, it will hide them after a short delay.

User activity is tracked via pointer movement, keyboard input, and focus events on the player container. On touch devices, a quick tap toggles visibility. mouseleave immediately sets the user as inactive.

Styling

By default, controls have the following styles:

/* Click-through: clicks pass through controls to video beneath */
media-controls {
  pointer-events: none;
}

media-controls-group {
  pointer-events: auto;
}

/* Fade transition */
media-controls {
  transition: opacity 0.25s;
}

media-controls:not([data-visible]) {
  opacity: 0;
}

Accessibility

No ARIA role is applied to <media-controls> — it is a layout wrapper, not a landmark. <media-controls-group> automatically receives role="group" when an aria-label or aria-labelledby attribute is provided; otherwise no role is assigned.

Examples

Basic Usage

Play Pause
<video-player class="html-controls-basic">
    <media-container>
        <video
            src="https://stream.mux.com/BV3YZtogl89mg9VcNBhhnHm02Y34zI1nlMuMQfAbl3dM/highest.mp4"
            autoplay
            muted
            playsinline
            loop
        ></video>

        <media-controls class="html-controls-basic__root">
            <media-controls-group class="html-controls-basic__bottom" aria-label="Playback controls">
                <media-play-button class="html-controls-basic__button html-controls-basic__play">
                    <span class="show-when-paused">Play</span>
                    <span class="show-when-playing">Pause</span>
                </media-play-button>
                <media-time class="html-controls-basic__time" type="current"></media-time>
            </media-controls-group>
        </media-controls>
    </media-container>
</video-player>

API Reference

media-controls

Root container for player controls state and rendered control content.

State

State is reflected as data attributes for CSS styling.

Property Type
visible boolean
userActive boolean

Data attributes

Attribute Type
data-visible
data-user-active

media-controls-group

Layout group for related controls; sets role="group" when labeled.

Data attributes

Attribute Type
data-visible
data-user-active