# useRect ### Intro Get the size of an element and its position relative to the viewport, equivalent to [Element.getBoundingClientRect](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect). ## Usage ### Basic Usage ```html
``` ```js import { ref, onMounted } from 'vue'; import { useRect } from '@vant/use'; export default { setup() { const root = ref(); onMounted(() => { const rect = useRect(root); console.log(rect); // -> the size of an element and its position relative to the viewport }); return { root }; }, }; ``` ## API ### Type Declarations ```ts function useRect( element: Element | Window | Ref