v-pip.

Video state

docked

Picture-in-picture for Vue 3.

One component around the native Picture-in-Picture Web API. Pop the video out, switch tabs, and it keeps playing on top of every window.

exposed method

events

  1. Toggle the video to see events.

Install

Vue 3 is the only peer dependency. The component ships no styles: pass your own classes through the option objects.

pnpm add v-pip
<script setup lang="ts">
  import { ref } from 'vue';
  import { VPip } from 'v-pip';

  const floating = ref(false);
</script>

<template>
  <VPip
    :video-options="{ src: '/clip.mp4', poster: '/clip.jpg' }"
    :button-options="{ label: 'Pop out' }"
    @video-in-pip="floating = $event"
  />
</template>

Props

Call togglePip() on a template ref to drive the video from your own controls.

proptypewhat it does
video-options{ src, poster?, class?, wrapper?, width?, height? }Attributes for the video element and its wrapper.
button-options{ label, type?, class?, wrapper? }The toggle button. Hidden when the browser has no PiP API.
wrapperstringClass on the outer element.

Events

eventpayloadwhen
video-in-pipbooleantrue on enter, false on leave.
requesting-pip-failureunknownrequestPictureInPicture() rejected.
exiting-pip-failureunknownexitPictureInPicture() rejected.