Skip to content

useElementSize ​

Category
Elements

Hook that observes and returns the width and height of element

typescript
import { useElementSize } from '@siberiacancode/reactuse';

Usage ​

typescript
const { value } = useElementSize(elementRef);

Demo ​

Api ​

Parameters

NameTypeDefaultNote
targetUseElementSizeTarget-The target element to observe.
initialValue?UseElementSizeValue{ width: 0, height: 0 }

Parameters

NameTypeDefaultNote
initialValue?UseElementSizeValue{ width: 0, height: 0 }The initial size of the element.

Contributors ​

Source • Demo