Skip to content
FrameworkStyle

media-fullscreen-button

Accessible fullscreen toggle button with keyboard support and state reflection

Anatomy

<media-fullscreen-button></media-fullscreen-button>

Behavior

Toggles fullscreen mode. The button derives two state hooks from availability:

  • disabled (true until fullscreen is available, or when the disabled prop is set) — sets aria-disabled="true" and data-disabled. A prop-disabled, available button stays focusable but does not activate.
  • hidden (true while fullscreen is "unavailable" or "unsupported") — applies the native HTML hidden attribute on the custom element; the React component returns null.

Styling

You can style the button based on fullscreen state:

/* In fullscreen */
media-fullscreen-button[data-fullscreen] {
  background: red;
}

/* Non-interactive (disabled prop) */
media-fullscreen-button[data-disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

The button remains hidden until fullscreen is available. The HTML element receives the native hidden attribute, and the React component returns null. No extra CSS is required.

Accessibility

Renders a <button> with an automatic aria-label: “Enter fullscreen” or “Exit fullscreen”. Override with the label prop. Keyboard activation: Enter / Space.

Examples

Basic Usage

Exit Fullscreen Fullscreen
<video-player class="video-player">
    <media-container>
        <video
            src="https://stream.mux.com/BV3YZtogl89mg9VcNBhhnHm02Y34zI1nlMuMQfAbl3dM/highest.mp4"
            autoplay
            muted
            playsinline
            loop
        ></video>
        <media-fullscreen-button class="media-fullscreen-button">
            <span class="fullscreen">Exit Fullscreen</span>
            <span class="not-fullscreen">Fullscreen</span>
        </media-fullscreen-button>
    </media-container>
</video-player>

API Reference

Props

PropTypeDefaultDetails
disabledbooleanfalse
labelText | string | Text) | function''

State

State is reflected as data attributes for CSS styling.

PropertyTypeDetails
availability'available' | 'unavailable' | 'unsupp...
disabledboolean
hiddenboolean
fullscreenboolean
labelText | string

Data attributes

AttributeTypeDetails
data-fullscreen
data-availability'available' | 'unavailable' | 'unsupp...
data-disabled
data-hidden