Home

Awesome

vue-viewports

define your custom viewports and use them in your components

Features

Installation

npm

npm install vue-viewports --save-dev

Vue's main.js

import VueViewports from 'vue-viewports'

const options = [
  {
    rule: '320px',
    label: 'mobile'
  },
  {
    rule: '768px',
    label: 'tablet'
  },
  {
    rule: '1024px',
    label: 'desktop'
  },
  {
    rule: '1920px',
    label: 'hd-desktop'
  },
  {
    rule: '2560px',
    label: 'qhd-desktop'
  },
  {
    rule: '3840px',
    label: 'uhd-desktop'
  }
]

Vue.use(VueViewports, options)

Arguments

Example

{
  if (this.$currentViewport.label === 'tablet') {
    // from 768px (included) to 1024px (excluded)
  } else {
    // anything else
  }
}

Variables

Feel free to contribute and ask questions!