Docs
useWindowSize
Track the dimensions of the browser window with useWindowSize.
Loading...
Installation
pnpm dlx shadcn@latest add https://usekit.kiron.dev/k/use-window-size
Usage
"use client"
import { useWindowSize } from "@/hooks/use-window-size"
const WindowSizeDisplay = () => {
const { width, height } = useWindowSize()
return (
<div>
<p>Window Width: {width}px</p>
<p>Window Height: {height}px</p>
</div>
)
}
API Reference
Return Values
Name | Type | Description |
---|---|---|
width | number | The current width of the window, in pixels. |
height | number | The current height of the window, in pixels. |