vue-screen

Reactive screen size and media query states for Vue. Integrates with most UI frameworks out of the box.
444,414 237
Install
npm install vue-screen
Latest Version:2.4.2
Vue:3
Older releases:2
License:MIT
Last Updated:Jan 21, 2025
Links: GitHub  ·  npm
Maintainer: reegodev

Build Status Build Status npm version npm downloads codecov


[!IMPORTANT] Version 2.x only supports Vue 3.
v1 docs are available here


VueScreen logo

VueScreen

Reactive screen size and media query states for Vue. Supports your favourite UI framework out of the box, and can be configured with any custom breakpoints.

Docs

https://reegodev.github.io/vue-screen

Features

  • Reactive and debounced screen size
  • Reactive media query states and device orientation
  • Detect touch screen capability
  • Breakpoints for most common ui frameworks provided out of the box: Tailwind, Bootstrap, Bulma, Foundation, Materialize, Semantic UI
  • SSR compatible

Installation

npm i vue-screen
yarn add vue-screen

Quick start

Use with composition API

import { useScreen, useGrid } from 'vue-screen'

export default {
    setup() {
        const screen = useScreen()
        const grid = useGrid('bulma')

        return {
            screen,
            grid
        }
    }
}

For advanced configurations, check out the docs website.

Use as a plugin

In main.js / main.ts:

import { createApp } from 'vue'
import VueScreen from 'vue-screen'

createApp()
  .use(VueScreen, 'bootstrap')
  .mount('#app')

In your components:

<template>
    <ul>
        <li>Current breakpoint is: {{ $grid.breakpoint }}</li>
        <li>Window width is: {{ $screen.width }}</li>
        <li>Window height is: {{ $screen.height }}</li>
    </ul>
</template>

Upgrading from v1

v2 introduces a few breaking changes both in the configuration and in the API. Read more about them in the docs section.

License

MIT

Related Packages

vue-screen-size

Get easy and reactive access to the width and height of your screen.

67,033 45
vue-next-breakpoints

Vue 3 Breakpoints using window.matchMedia and the Composition API

14,935 6
nuxt-ssr-screen-size

Get easy and reactive access to the width and height of your screen.

10,951
vue-not-visible

Vue directive for conditional rendering (like v-if) element on screen smaller th...

932 22
vue-viewports

Named, reactive, matchMedia-based viewport breakpoints for Vue 3 — a tiny plugin...

7,734 74

Version History

Version Released License
2.4.2 MIT
2.4.1 MIT
2.4.0 MIT
2.3.2 MIT
2.3.1 MIT
Pre-releases (10)
Version Released License
2.1.0-beta.1 MIT
2.1.0-alpha.5 MIT
2.0.4-alpha.4 MIT
2.0.3-alpha.3 MIT
2.0.2-alpha.3 MIT