Stop Rebuilding UI

Shadcn.io is not affiliated with official shadcn/ui

React useResizeObserver Hook

React useResizeObserver hook for tracking element size changes. Width/height with box model options. TypeScript ready.

Track element dimensions reactively with useResizeObserver. Pass a ref and get width/height that update whenever the element resizes. Uses the native ResizeObserver API for efficient size tracking. Supports content-box, border-box, and device-pixel-content-box measurements. Optional onResize callback for custom handling without state updates. Compares previous size to avoid unnecessary re-renders on unchanged dimensions. Perfect for responsive components, resize handles, dynamic layouts, chart containers, or any element that needs to react to its own size. SSR safe with window checks.

React useResizeObserver Hook preview

Scroll to load preview

Installation

FAQ

Was this page helpful?

Sign in to leave feedback.