Skip to content

Latest commit

 

History

History
57 lines (39 loc) · 1.71 KB

README.md

File metadata and controls

57 lines (39 loc) · 1.71 KB

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