UNPKG

@arolariu/components

Version:

🎨 60+ beautiful, accessible React components built on Radix UI. TypeScript-first, tree-shakeable, SSR-ready. Perfect for modern web apps, design systems & rapid prototyping. Zero config, maximum flexibility! ⚡

18 lines (17 loc) • 637 B
import { useEffect, useState } from "react"; const MOBILE_BREAKPOINT = 768; function useIsMobile() { const [isMobile, setIsMobile] = useState(void 0); useEffect(()=>{ const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`); const onChange = ()=>{ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT); }; mql.addEventListener("change", onChange); setIsMobile(window.innerWidth < MOBILE_BREAKPOINT); return ()=>mql.removeEventListener("change", onChange); }, []); return !!isMobile; } export { useIsMobile }; //# sourceMappingURL=use-mobile.js.map