React hooks for element-based media queries
npm install use-container-query> React hook for element-based media queries.
 
``bash`
yarn add use-container-query
`tsx
import useContainerQuery from 'use-container-query';
function LandscapeOnly() {
const ref = useRef(null);
const isLandscape = useContainerQuery(ref, {
type: 'orientation',
value: 'landscape',
});
return (
$3
-
aspect-ratio
- max-aspect-ratio
- min-aspect-ratio
- width
- max-width
- min-width
- height
- max-height
- min-height
- orientation
- value must be either 'portrait' or 'landscape'`MIT © lxsmnsyc