Something went wrong. Try again.
UIKit a SolidJS component library inspired by Google's Material 3 Expressive
Something went wrong. Try again.
1234567891011121314151617import {createSignal, onCleanup, onMount} from "solid-js";
export default function useIsMobile(breakpoint = 768) { const query = `(max-width: ${breakpoint}px)`; const [ isMobile, setIsMobile ] = createSignal(window.matchMedia(query).matches);
onMount(() => { const media = window.matchMedia(query); const listener = (e: {matches: boolean}) => setIsMobile(e.matches); media.addEventListener("change", listener);
onCleanup(() => media.removeEventListener("change", listener)); });
return isMobile;}