New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

react-styled-pip

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-styled-pip

This is a simple utility package for document picture in picture with styled components

latest
Source
npmnpm
Version
0.0.3
Version published
Maintainers
1
Created
Source

React Document Picture-in-Picture

A React component library for creating Picture-in-Picture windows using the Document Picture-in-Picture API with styled-components support.

React PIP Demo

Browser Support

  • This feature may not work in some browsers. Browser compatibility can be checked at CanIUse.

  • This feature is only available in Secure Contexts (HTTPS or localhost).

Installation

npm install react-document-pip

Usage

Basic Example

import { useState } from "react";
import DocumentPip from "react-document-pip";

function App() {
  const pipWindowRef = useRef<Window | null>(null);
  const [isPipOpen, setIsPipOpen] = useState(false);

  const togglePip = () => {
    setIsPipOpen(!isPipOpen);
  };

  const handleClose = () => {
    setIsPipOpen(false);
  };

  return (
    <>
      <DocumentPip
        ref={pipWindowRef}
        isPipOpen={isPipOpen}
        size={{ width: 500, height: 400 }}
        className="dark"
        onClose={handleClose}
      >
        <MyComponent />
      </DocumentPip>
      <button onClick={togglePip}>Toggle PIP</button>
    </>
  );
}

API Reference

DocumentPIP ForwardedRef

TypeDescription
Window | nullPIP window

DocumentPIP Props

PropTypeDefaultDescription
childrenReact.ReactNode-The content to display in the PIP window
isPipOpenboolean-Controls whether the PIP window is open
sizePartial<PIPWindowSize>-Size of the PIP window
mode'clone' | 'transfer' | 'transfer-only''transfer'Content display mode
clone: keep original + copy
transfer: move to PIP
transfer-only: move to PIP without original
copyAllStylesbooleantrueWhether to copy all styles to PIP window
disallowReturnToOpenerbooleanfalseWhether to disallow returning to the opener window
preferInitialWindowPlacementbooleanfalseWhether to prefer initial window placement
classNamestring''pip window documentElement classname
onEnter() => void-Callback function when the PIP window is successfully opened
onClose() => void-Callback function when the PIP window is closed

Types

interface PIPWindowSize {
  width: number;
  height: number;
}

type PIPMode = "clone" | "transfer" | "transfer-only";

interface DocumentPIPProps {
  children: React.ReactNode;
  isPipOpen: boolean;
  size?: Partial<PIPWindowSize>;
  mode?: PIPMode;
  copyAllStyles?: boolean;
  disallowReturnToOpener?: boolean;
  preferInitialWindowPlacement?: boolean;
  className?: string;

  onEnter?: (e: DocumentPictureInPictureEvent) => void;
  onClose: () => void;
}

Browser Support

This library uses the Document Picture-in-Picture API, which is currently supported in:

  • Chrome 116+
  • Edge 116+
  • Opera 102+

License

MIT

Keywords

react

FAQs

Package last updated on 17 Sep 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts