Files
controller-v2/client/src/hooks/useIsLgUp.ts
T
2026-05-08 18:15:52 +08:00

21 lines
579 B
TypeScript

import { useEffect, useState } from "react";
/** Matches Tailwind `lg:` (1024px). Used for desktop-only UI such as the AI split panel. */
export function useIsLgUp() {
const [lgUp, setLgUp] = useState(
() =>
typeof window !== "undefined" &&
window.matchMedia("(min-width: 1024px)").matches,
);
useEffect(() => {
const mql = window.matchMedia("(min-width: 1024px)");
const sync = () => setLgUp(mql.matches);
mql.addEventListener("change", sync);
sync();
return () => mql.removeEventListener("change", sync);
}, []);
return lgUp;
}