Infinity x Infinity

useWindowSize

Reactive window size

Usage

import { useWindowSize } from '@vueuse/core'

const { width, height } = useWindowSize()

Component

<UseWindowSize v-slot="{ width, height }">
  Width: {{ width }}
  Height: {{ height }}
</UseWindowSize>
Learn more about component usage

Type Declarations

export interface WindowSizeOptions extends ConfigurableWindow {
  initialWidth?: number
  initialHeight?: number
}
/**
 * Reactive window size.
 *
 * @see /useWindowSize
 * @param options
 */
export declare function useWindowSize({
  window,
  initialWidth,
  initialHeight,
}?: WindowSizeOptions): {
  width: Ref<number>
  height: Ref<number>
}
export declare type UseWindowSizeReturn = ReturnType<typeof useWindowSize>

Source

SourceDemoDocs