react-viewport-height
TypeScript icon, indicating that this package has built-in type declarations

1.2.2 • Public • Published

react-viewport-height

npm Version npm downloads per week Minified size Open issues Open pull requests GitHub Stars CircleCI status Code scanning

A utility for React to set 100vh equal to the actual browser inner window height.

Since vh has troubles on mobile browsers (primarily because of the address bar), there are several tricks to fix it. This package implements the one from this article.

The solution for this was introduced in the CSS Values and Units Module Level 4 which is widely supported now. Instead of using this package, you can use the dvh unit if your project doesn't need to support older browsers. Read more about new units.

Usage

npm install react-viewport-height
// index.js
import useVH from 'react-viewport-height';
import './index.css';

const App = () => {
  useVH();

  return <div className="app" />;
};
/* index.css */
.app {
  min-height: calc(var(--vh, 1vh) * 100);
}

Read the documentation for more details. You can also play with a demo.

Support

If you like this package and want to support it, you can do it on Patreon

Package Sidebar

Install

npm i react-viewport-height

Weekly Downloads

1,019

Version

1.2.2

License

MIT

Unpacked Size

9.13 kB

Total Files

5

Last publish

Collaborators

  • dimazuien