
Product
Introducing Data Exports
Export Socket alert data to your own cloud storage in JSON, CSV, or Parquet, with flexible snapshot or incremental delivery.
vue3-v-resize
Advanced tools
Resize observer for Vue.
Detect size changes of DOM elements. Support Vue's directive and component.
ResizeObservable API implementationvue3npm
npm install vue3-v-resize
<template>
<div id="app">
<!-- directives -->
<div v-resize:50.immediate="onResize">
Listened to elements
</div>
<!-- Components -->
<ResizeComponent @resize="onResize" :delay="100" :disabled="disabled">
<div>Listened to elements</div>
</ResizeComponent>
</div>
</template>
<script setup>
import { ref } from 'vue'
import { ResizeComponent, resizeDirective as vResize } from 'vue3-v-resize'
const disabled = ref(false)
function onResize({ width, height }, target) {
console.log(target, width, height)
}
</script>
// main.js
import Resizer from 'vue3-v-resize'
// vue@3.x
const app = createApp(App)
app.use(Resizer, {
// Custom command names and component names
directive: 'resize',
component: 'ResizeComponent'
})
<script setup>
import { ref } from 'vue'
import {
ResizeComponent,
resizeDirective as vResizeObserver //You can change the directive name, the default: `v-resize,
} from 'vue3-v-resize'
// OR
// import Resizer from 'v-resize-observer'
// const ResizeComponent = Resizer.component
// const vResize = Resizer.directive
function onResize({ width, height }, target) {
console.log(target, width, height)
}
</script>
<template>
<div id="app">
<!-- directives -->
<div v-resize-observer:100="onResize">
Listened to elements
</div>
<!-- Components -->
<ResizeComponent @resize="onResize">
<div>Listened to elements</div>
</ResizeComponent>
</div>
</template>
立即执行一次callback
| Parameter | Type | Default | Description |
|---|---|---|---|
target | string, HTMLElement | - | Target elements to listen to |
delay | number | 150 | Delayed execution time |
immediate | boolean | false | executed immediately |
disabled | boolean | false | disable listening |
resize | function | - | Callback function to listen for changes in element size |
resize(data, target)
data : elements size { width, height }target : Listening elementsdirectiveThe directive default name is
v-resize, if you want to change it, you can specify it when you import it.
<div v-resize="onResize" />
<div v-resize:100="onResize" />
<div v-resize:100.immediate="onResize" />
<!-- No limit on trigger frequency -->
<div v-resize:0="onResize" />
Parameter:
arg: => delayvalue: => resizemodifiers.immediateComponent<ResizeComponent target="#app" :delay="0" disabled="false" @resize="onResize">
<div>Listened to elements</div>
</ResizeComponent>
target: The target element to listen to, the default current element.delay: Delay execution time, default: 150.immediate: Execute immediately, default: false.disabled: disable listening, default: false.resize: Triggered when listening for element size changes.FAQs
Vue 3 resize observer with debounce
We found that vue3-v-resize demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Export Socket alert data to your own cloud storage in JSON, CSV, or Parquet, with flexible snapshot or incremental delivery.

Research
/Security News
Bitwarden CLI 2026.4.0 was compromised in the Checkmarx supply chain campaign after attackers abused a GitHub Action in Bitwarden’s CI/CD pipeline.

Research
/Security News
Docker and Socket have uncovered malicious Checkmarx KICS images and suspicious code extension releases in a broader supply chain compromise.