useResponsive
React hook for responsive design.
API
useResponsive
Hook
The Use useResponsive
to get responsive info in components.
{ const info = // info is {"xs":true,"sm":true,"md":true,"lg":false,"xl":false} return <div> infomd && <p>Window width >= middle</p> infolg && <p>Window width >= large</p> </div> }
Config
The default responsive config is the same as Bootstrap's breakpoints:
'xs': 0 'sm': 576 'md': 768 'lg': 992 'xl': 1200
If you wish to config your own breakpoints, you can use configResponsive
:
(Attention: You only need to set your config once, so don't call this function in components.)