useWindowSize
Reactive composable to track the current size of the browser window.
Installation
bash
npx kuro-ui add useWindowSizebash
npx github:Bartek-Nowak/Kuro add useWindowSizeUsage
ts
import { useWindowSize } from '@/composables/kuro/useWindowSize'
const { width, height } = useWindowSize()Returns
| Name | Type | Description |
|---|---|---|
| width | Ref<number> | Reactive value of the current window width (px). |
| height | Ref<number> | Reactive value of the current window height (px). |
Details
widthandheightare initialized withwindow.innerWidthandwindow.innerHeight.- The values update reactively whenever the window is resized.
- The
resizeevent listener is registered on component mount and properly removed on unmount to prevent memory leaks.