use-screen-size
This helps you write conditional code based on screen size, or get the screen size value
Install
npm install --save use-screen-size
yarn add use-screen-size
Example
This shows a quick example of displaying your screen width, screen height and current screen mode
Helpful Methods
size.screen
is used to get the quick current size mode of the screen
Name | Size | property |
---|---|---|
Extra small | <576px | xs |
Small | ≥576px | s |
Medium | ≥768px | m |
Large | ≥992px | l |
Large | ≥1200px | xl |
-
size.width
its is used to get the width of the screen in pixels -
size.height
its is used to get the height of the screen in pixels
Advanced Example
This shows an advanced example of running conditional actions based on the screen size
License
Follow on Twitter @mrflamez_
MIT © kingflamez