Skip to content
On this page

useSize

A hook that observes size change of an element.

Code demonstration

Default usage

Pass in the DOM element

API

const size = useSize(target)
const size = useSize(target)

Params

PropertyDescriptionTypeDefault
targetDOM element or ref objectElement | (() => Element) | JSX.Element-

Result

PropertyDescriptionType
sizeSize of the elementReadonly《Ref<{ width: number, height: number } | undefined>>

Source

SourceDocsDemo