Skip to content
aq-ui
Back to HooksHook

Use Element Size

Open-code aq-ui React hook for Use Element Size.

Installation

pnpm dlx aq-ui@alpha add use-element-size

API reference

Client module

Import the parts you need, then jump to an export for its contract.

View full source

Quick start

"use client"

import { useElementSize } from "@/hooks/use-element-size"

ElementSize

interfaceSource L6

Type contract for ElementSize.

interface ElementSize

Members

NameType
widthnumber
heightnumber

useElementSize

functionSource L11

Open-code aq-ui React hook for Use Element Size.

function useElementSize<T extends Element>(target: Target<T>, initialSize: ElementSize = { width: 0, height: 0 }): ElementSize
Returns
ElementSize

Parameters

NameTypeDefault
targetTarget<T>—
initialSize?ElementSize{ width: 0, height: 0 }

Registry dependencies

hook-target, use-resize-observer

Files

  • hooks/use-element-size.ts

Source