Skip to content
GaudiGaudi Design System home

Search documentation

Search every page, heading and paragraph.

useWindowSize

Track layout viewport width and height in CSS pixels.

HooksEnvironment@gaudi/design-system/hooks/environment/use-window-sizeView in StorybookSource

Reads the window after mount and updates on resize. Unchanged dimensions keep the same result object. The server and first client render use the supplied initial dimensions.

Usage

import { useWindowSize } from '@gaudi/design-system/hooks';
const { width, height } = useWindowSize();

Examples

Playground

Storybook

API

2 options
1 return value

Accessibility

Prefer CSS responsive layout or useMediaQuery for breakpoints. Avoid hiding essential content based only on viewport size.