getBoundingClientRect
A browser method that returns an element size and its position relative to the visible part of the page.
In more detail
Reading it forces the browser to finish any pending layout, so call it only when needed. The values change as the page scrolls.
Example
Tooltips measure their anchor with it inside useLayoutEffect.Related terms
- useLayoutEffect — A version of useEffect that runs synchronously after React changes the DOM but before the browser paints the screen.
- layout — The rendering stage in which the browser calculates the exact position and size of every box on the page.
- tooltip — A small text label that appears when a control is hovered or focused, describing it briefly.
Taught in
- useEffect Lifecycle: Mount, Dependencies, And Cleanup Phases — React 19 & Modern Component Architecture
- useLayoutEffect vs useEffect: Painting And Synchronous Reads — React 19 & Modern Component Architecture