use-resize-observer
Subscribe to element size and position changes with ResizeObserver
Import
Source
Docs
Package
Usage
Resize textarea by dragging its right bottom corner
Rect:
{
"x": 0,
"y": 0,
"width": 0,
"height": 0,
"top": 0,
"left": 0,
"bottom": 0,
"right": 0
}
API
Hook returns ref object that should be passed to the observed element, and the current element content rect, as returned by ResizeObserver
's callback entry.contentRect
.
See Resize Observer API documentation to learn more.
On the first render (as well as during SSR), or when no element is being observed, all of the properties are equal to 0
.
See also use-element-size hook in case you need to subscribe only to width and height.
Definition
Feedback
Your feedback is most valuable contribution to the project, please share how you use Mantine, what features are missing and what is done good
Leave feedback