Pulled ALL skills from 15 source repositories: - anthropics/skills: 16 (docs, design, MCP, testing) - obra/superpowers: 14 (TDD, debugging, agents, planning) - coreyhaines31/marketingskills: 25 (marketing, CRO, SEO, growth) - better-auth/skills: 5 (auth patterns) - vercel-labs/agent-skills: 5 (React, design, Vercel) - antfu/skills: 16 (Vue, Vite, Vitest, pnpm, Turborepo) - Plus 13 individual skills from various repos Mosaic Stack is not limited to coding — the Orchestrator and subagents serve coding, business, design, marketing, writing, logistics, analysis, and more. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
111 lines
2.6 KiB
Markdown
111 lines
2.6 KiB
Markdown
---
|
|
category: Elements
|
|
---
|
|
|
|
# useResizeObserver
|
|
|
|
Reports changes to the dimensions of an Element's content or the border-box
|
|
|
|
## Usage
|
|
|
|
```vue
|
|
<script setup lang="ts">
|
|
import { useResizeObserver } from '@vueuse/core'
|
|
import { ref, useTemplateRef } from 'vue'
|
|
|
|
const el = useTemplateRef('el')
|
|
const text = ref('')
|
|
|
|
useResizeObserver(el, (entries) => {
|
|
const entry = entries[0]
|
|
const { width, height } = entry.contentRect
|
|
text.value = `width: ${width}, height: ${height}`
|
|
})
|
|
</script>
|
|
|
|
<template>
|
|
<div ref="el">
|
|
{{ text }}
|
|
</div>
|
|
</template>
|
|
```
|
|
|
|
## Directive Usage
|
|
|
|
```vue
|
|
<script setup lang="ts">
|
|
import { vResizeObserver } from '@vueuse/components'
|
|
|
|
const text = ref('')
|
|
|
|
function onResizeObserver(entries) {
|
|
const [entry] = entries
|
|
const { width, height } = entry.contentRect
|
|
text.value = `width: ${width}, height: ${height}`
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<div v-resize-observer="onResizeObserver">
|
|
{{ text }}
|
|
</div>
|
|
</template>
|
|
```
|
|
|
|
[ResizeObserver MDN](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver)
|
|
|
|
## Type Declarations
|
|
|
|
```ts
|
|
/**
|
|
* @deprecated This interface is now available in the DOM lib.
|
|
* Use the global {@link globalThis.ResizeObserverSize} instead.
|
|
*/
|
|
export interface ResizeObserverSize {
|
|
readonly inlineSize: number
|
|
readonly blockSize: number
|
|
}
|
|
/**
|
|
* @deprecated This interface is now available in the DOM lib.
|
|
* Use the global {@link globalThis.ResizeObserverEntry} instead.
|
|
*/
|
|
export interface ResizeObserverEntry {
|
|
readonly target: Element
|
|
readonly contentRect: DOMRectReadOnly
|
|
readonly borderBoxSize: ReadonlyArray<ResizeObserverSize>
|
|
readonly contentBoxSize: ReadonlyArray<ResizeObserverSize>
|
|
readonly devicePixelContentBoxSize: ReadonlyArray<ResizeObserverSize>
|
|
}
|
|
/**
|
|
* @deprecated This interface is now available in the DOM lib.
|
|
* Use the global {@link globalThis.ResizeObserverCallback} instead.
|
|
*/
|
|
export type ResizeObserverCallback = (
|
|
entries: ReadonlyArray<ResizeObserverEntry>,
|
|
observer: ResizeObserver,
|
|
) => void
|
|
export interface UseResizeObserverOptions
|
|
extends ResizeObserverOptions,
|
|
ConfigurableWindow {}
|
|
/**
|
|
* Reports changes to the dimensions of an Element's content or the border-box
|
|
*
|
|
* @see https://vueuse.org/useResizeObserver
|
|
* @param target
|
|
* @param callback
|
|
* @param options
|
|
*/
|
|
export declare function useResizeObserver(
|
|
target:
|
|
| MaybeComputedElementRef
|
|
| MaybeComputedElementRef[]
|
|
| MaybeRefOrGetter<MaybeElement[]>,
|
|
callback: globalThis.ResizeObserverCallback,
|
|
options?: UseResizeObserverOptions,
|
|
): {
|
|
isSupported: ComputedRef<boolean>
|
|
stop: () => void
|
|
}
|
|
export type UseResizeObserverReturn = ReturnType<typeof useResizeObserver>
|
|
```
|