Seitu
Web

Element Size

Tracks an element's width and height through ResizeObserver.

createElementSize()

Sizes ignore CSS transforms. A null element and the server snapshot are 0 × 0.

Vanilla

import {  } from 'seitu/web'

const  = ({
  : .('.container'),
})

.(({ ,  }) => {
  .(, )
})

const {  } = .()
.()

React (callback ref)

page.tsx
'use client'

import * as React from 'react'
import {  } from 'seitu/web'
import {  } from 'seitu/react'

function () {
  const [, ] = React.<HTMLDivElement | null>(null)
  const  = (() => ({
    : ,
  }), { : [] })

  return (
    < ={}>
      {.} × {.}
    </>
  )
}
Edit on GitHub

Last updated on

On this page