Components
useWindowSize is a custom React hook that tracks the current dimensions of the browser window (width and height) in real time. It listens for the resize event and updates whenever the window size changes. This is particularly useful for responsive UI adjustments, conditional rendering based on viewport width, or dynamic layout calculations.
Loading preview...
import { useWindowSize } from "@/components/ui/use-window-size";
export default function DemoOne() {
const window = useWindowSize();
return <pre>{JSON.stringify(window)}</pre>;
}