Skip to main content

Interface: UseElementSizeOptions

Defined in: use-element-size.ts:12

Options for useElementSize.

Properties​

box?​

optional box?: "content-box" | "border-box"

Defined in: use-element-size.ts:19

Which box to measure.

  • "content-box" (default): the content area, excluding padding and border.
  • "border-box": the content plus padding and border.

defaultSize?​

optional defaultSize?: ElementSize

Defined in: use-element-size.ts:24

Size reported on the server and until the element has been measured. Only read on the first render. Defaults to { width: 0, height: 0 }.


onResize?​

optional onResize?: (size, entry) => void

Defined in: use-element-size.ts:31

Called from the resize observer whenever the measured size changes, including the first measurement. Receives the new size and the raw ResizeObserverEntry, for example to read contentRect or the other boxes. The latest callback is always used.

Parameters​

size​

ElementSize

entry​

ResizeObserverEntry

Returns​

void