Skip to content
FrameworkStyle

media-pip-button

Accessible picture-in-picture toggle button with keyboard support and state reflection

Import

import '@videojs/html/ui/pip-button';

Anatomy

<media-pip-button></media-pip-button>

Behavior

Toggles picture-in-picture (PiP) mode. The button derives two state hooks from availability:

  • disabled (true until PiP 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 PiP 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 PiP state:

/* In PiP mode */
media-pip-button[data-pip] {
  background: red;
}

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

The button remains hidden until picture-in-picture 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 PiP” or “Exit PiP”. Override with the label prop. Keyboard activation: Enter / Space.

Examples

Basic Usage

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

API Reference

Props

PropTypeDefaultDetails
disabledbooleanfalse
labelobject''

State

State is reflected as data attributes for CSS styling.

PropertyTypeDetails
pipboolean
label{ key: string; text: string } | string
availabilityMediaPictureInPictureState['pipAvailability']
disabledboolean
hiddenboolean

Data attributes

AttributeTypeDetails
data-pip
data-availabilityMediaPictureInPictureState['pipAvailability']
data-disabled
data-hidden