Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/netzo/deps/usehooks-ts.ts>useElementSize

Full-stack Deno framework for building business web apps like internal tools, dashboards, admin panels and automated workflows.
Go to Latest
function useElementSize
Deprecated
Deprecated
  • Use useResizeObserver instead. A hook for tracking the size of a DOM element.
import { useElementSize } from "https://deno.land/x/netzo@0.5.66/deps/usehooks-ts.ts";

Examples

const [ref, { width = 0, height = 0 }] = useElementSize(); // or const { ref, width = 0, height = 0 } = useElementSize();

return (

Type Parameters

optional
T extends HTMLElement = HTMLDivElement
  • The type of the DOM element. Defaults to HTMLDivElement.

Parameters

optional
options: UseElementSizeOptions
  • The options for customizing the behavior of the hook (optional).

Returns

UseElementSizeResult

The ref-setting function and the size of the element. Either as an tuple [ref, size] or as an object { ref, width, height }.