Skip to content
FrameworkStyle

PiPButton

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

Anatomy

<PiPButton />

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:

React renders a <button> element. Add a className to style it:

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

Consider hiding the button when unsupported:

.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

import { createPlayer, PiPButton } from '@videojs/react';
import { Video, videoFeatures } from '@videojs/react/video';

const Player = createPlayer({ features: videoFeatures });

export default function BasicUsage() {
  return (
    <Player.Provider>
      <Player.Container className="media-container">
        <Video
          src="https://stream.mux.com/BV3YZtogl89mg9VcNBhhnHm02Y34zI1nlMuMQfAbl3dM/highest.mp4"
          autoPlay
          muted
          playsInline
          loop
        />
        <PiPButton
          className="media-pip-button"
          render={(props, state) => <button {...props}>{state.pip ? 'Exit PiP' : 'Enter PiP'}</button>}
        />
      </Player.Container>
    </Player.Provider>
  );
}

API Reference

Props

Prop Type Default Details
disabled boolean false
label 'play' | 'pause' | 'replay' | 'mute' | 'unmute' | 'seekForward' | 'seekBackward' | 'enterFullscreen' | 'exitFullscreen' | 'enableCaptions' | 'disableCaptions' | 'enterPictureInPicture' | 'exitPictureInPicture' | 'playingLive' | 'seekToLiveEdge' | 'liveBadge' | 'startCasting' | 'stopCasting' | 'connectingCast' | 'seek' | 'volume' | 'timeCurrent' | 'timeDuration' | 'timeRemaining' | 'timeRemainingPhrase' | 'playbackRateAria' | 'timeSliderValueTextRange' | 'volumeSliderValueTextMuted' | 'indicatorMuted' | 'indicatorVolume' | 'indicatorVolumeWithValue' | 'indicatorCaptionsOn' | 'indicatorCaptionsOff' | 'indicatorPaused' | 'indicatorPlaying' | 'indicatorFullscreen' | 'indicatorExitFullscreen' | 'indicatorPictureInPicture' | 'indicatorExitPictureInPicture' | 'mediaErrorAborted' | 'mediaErrorNetwork' | 'mediaErrorDecode' | 'mediaErrorSrcNotSupported' | 'mediaErrorEncrypted' | 'mediaErrorCustom' | 'errorDialogTitle' | 'errorDialogDismiss' | 'mediaErrorFallback' | string & object | function ''

State

State is accessible via the render, className, and style props.

Property Type Details
availability 'available' | 'unavailable' | 'unsupp...
pip boolean
label 'play' | 'pause' | 'replay' | 'mute' ...

Data attributes

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