FrameworkStyle

media-pip-button

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

Anatomy

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

Behavior

Toggles picture-in-picture (PiP) mode. Detects platform support through availability — when PiP is "unsupported", the toggle does nothing.

Styling

You can style the button based on PiP state:

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

Consider hiding the button when unsupported:

media-pip-button[data-availability="unsupported"] {
  display: none;
}

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="html-pip-button-basic">
    <media-container>
        <video
            src="https://stream.mux.com/BV3YZtogl89mg9VcNBhhnHm02Y34zI1nlMuMQfAbl3dM/highest.mp4"
            autoplay
            muted
            playsinline
            loop
        ></video>
        <media-pip-button class="html-pip-button-basic__button">
            <span class="show-when-pip">Exit PiP</span>
            <span class="show-when-not-pip">Enter PiP</span>
        </media-pip-button>
    </media-container>
</video-player>

API Reference

Props

Prop Type Default
disabled boolean false
label string | function ''

State

State is reflected as data attributes for CSS styling.

Property Type
availability 'available' | 'unavailable' | 'unsupp...
pip boolean

Data attributes

Attribute Type
data-pip
data-availability 'available' | 'unavailable' | 'unsupp...