1.2.2 • Published 9 months ago

react-viewport-height v1.2.2

Weekly downloads
184
License
MIT
Repository
github
Last release
9 months ago

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

1.2.2

9 months ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.1

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.0

3 years ago

1.0.0

4 years ago