@reach/rect
v0.18.0
Published
Measure React elements position in the DOM
Downloads
1,058,815
Keywords
Readme
@reach/rect
Measures DOM elements (aka. bounding client rect). See also Element.getBoundingClientRect()
import { Rect, useRect } from "@reach/rect";
function Example() {
const ref = React.useRef();
const rect = useRect(ref);
return (
<div>
<pre>{JSON.stringify(rect, null, 2)}</pre>
<div
ref={ref}
contentEditable
dangerouslySetInnerHTML={{
__html: "Edit this to change the size!",
}}
/>
</div>
);
}