@reach/window-size

Measure the window size in React

Usage no npm install needed!

<script type="module">
  import reachWindowSize from 'https://cdn.skypack.dev/@reach/window-size';
</script>

README

@reach/window-size

Stable release MIT license

Docs | Source

Measure the current window dimensions.

import WindowSize, { useWindowSize } from "@reach/window-size";

function Example() {
  const { width, height } = useWindowSize();
  return (
    <div>
      <p>
        Looks like a pretty{" "}
        {width <= 400 ? "small" : width >= 1000 ? "large" : "normal"} screen!
      </p>
    </div>
  );
}