useResizeObserver
useResizeObserver
is a custom hook that tracks changes in the size and position of an element.
Import
import { useResizeObserver } from "@yamada-ui/react"
Usage
Editable example
const [flg, { toggle }] = useBoolean() const [ref, rect] = useResizeObserver<HTMLButtonElement>() return ( <> <Text>{JSON.stringify(rect)}</Text> <Button ref={ref} mt="md" onClick={toggle} w={flg ? "xl" : "sm"} h={flg ? "xl" : "sm"} > Click me to toggle the boolean value </Button> </> )
Edit this page on GitHub