use-fullscreen
TypeScript icon, indicating that this package has built-in type declarations

0.0.5 • Public • Published

React hook for the fullscreen API

A React hook that gives you the current fullscreen state, and a toggle function if fullscreen is available and enabled in the browser.

Works in modern browsers and IE11.

import useFullscreen from 'use-fullscreen';

function Example() {
  const [isFullscreen, toggleFullscreen] = useFullscreen();
  return (
    <div>
      <h1>Is {!isFullscreen && <i>not</i>} fullscreen</h1>
      {toggleFullscreen ? (
        <button onClick={() => toggleFullscreen()}>Toggle fullscreen</button>
      ) : (
        <b>Fullscreen not supported :(</b>
      )}
    </div>
  );
}

Fullscreen example

Package Sidebar

Install

npm i use-fullscreen

Weekly Downloads

1

Version

0.0.5

License

ISC

Unpacked Size

7.99 kB

Total Files

7

Last publish

Collaborators

  • jacobrask