Skip to content

NPM package to use the width of screen size dynamically for responsive design

Notifications You must be signed in to change notification settings

akshitsuri/useWidth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

use-width

NPM package to use the width of screen size dynamically for responsive design

Install

npm i use-width

Import

import useWidth from 'use-width';

Usage

const [width] = useWidth();

const component = width > 600 ? <DesktopComponent> : <PhoneComponent>;

or

<div style={{ fontSize: width > 600 ? "2rem" : "1rem" }}/>

Width is in pixels.

support @akshit & @varun