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

3.0.0 • Public • Published

use-screen

FreePalestine.Dev

Custom React hook for screen and device information

NPM npm codecov Github FreePalestine.Dev

Install

npm install use-screen

Or with yarn:

yarn add use-screen

Usage

import useScreen from 'use-screen';

const { isMobile, isWideScreen, screenWidth } = useScreen();

// use screen width and other variables as you like

See the website to see how it works: https://alioguzhan.github.io/use-screen/

There is also a working live example as a sandbox:

Edit use-screen-hook

Return Value

interface State {
  isMobile: boolean; // < 768px
  isTablet: boolean; // < 1280px
  isComputer: boolean; // > 1280px
  isLargeScreen: boolean; // < 1920px
  isWideScreen: boolean; // > 1920px
  screenWidth: number; // current screen width (innerWidth)
  screenHeight: number; // current screen height (innerHeight)
}

License

MIT © alioguzhan

Package Sidebar

Install

npm i use-screen

Weekly Downloads

51

Version

3.0.0

License

MIT

Unpacked Size

19.5 kB

Total Files

8

Last publish

Collaborators

  • ali_oguzhan