FrameworkStyle

media-poster

Poster image component that displays a thumbnail until video playback starts

Anatomy

Import the component:

<media-poster>
  <img src="poster.jpg" alt="Video preview" />
</media-poster>

Behavior

The poster is visible before playback starts. Once the user plays or seeks, the poster hides permanently — pausing does not bring it back. The poster reappears when a new source is loaded.

Styling

Style the poster with the [data-visible] attribute:

media-poster:not([data-visible]) {
  display: none;
}

You control the child <img> — this means srcset, sizes, loading="lazy", and framework image components all work naturally.

Accessibility

Unlike the native <video poster> attribute, this component allows you to provide accessible text alternatives for screen readers via the alt attribute on your child <img>. This means you can describe the poster image (e.g., alt="Keynote speaker at a conference") or mark it as decorative with alt="" if it doesn’t convey meaningful information.

Examples

Basic Usage

Video thumbnail Play Pause
<!-- biome-ignore-all lint/a11y/useMediaCaption: TODO -->
<video-player class="html-poster-basic">
    <media-container>
        <video
            src="https://stream.mux.com/BV3YZtogl89mg9VcNBhhnHm02Y34zI1nlMuMQfAbl3dM/highest.mp4"
            playsinline
        ></video>

        <media-poster class="html-poster-basic__poster">
            <img
                src="https://image.mux.com/BV3YZtogl89mg9VcNBhhnHm02Y34zI1nlMuMQfAbl3dM/thumbnail.jpg"
                alt="Video thumbnail"
                />
            </media-poster>

            <media-play-button class="html-poster-basic__button">
                <span class="show-when-paused">Play</span>
                <span class="show-when-playing">Pause</span>
            </media-play-button>
    </media-container>
</video-player>

API Reference

State

State is reflected as data attributes for CSS styling.

Property Type
visible boolean

Data attributes

Attribute Type
data-visible