@reach/rect
TypeScript icon, indicating that this package has built-in type declarations

0.18.0 • Public • Published

@reach/rect

Stable release MIT license

Docs | Source

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>
	);
}

Readme

Keywords

none

Package Sidebar

Install

npm i @reach/rect

Weekly Downloads

291,023

Version

0.18.0

License

MIT

Unpacked Size

24.4 kB

Total Files

10

Last publish

Collaborators

  • ryanflorence
  • mjackson
  • chancestrickland
  • blainekasten