0.1.6 • Published 5 years ago

vue-breakpointer v0.1.6

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

Vue Breakpointer

A simple Vue plugin/mixin to augment your Vue instance with breakpoint helpers

Install

NPM/Yarn

npm install vue-breakpointer --save

or

yarn add vue-breakpointer --save

Browser

<script src="https://unpkg.com/vue-breakpointer"></script>

Plugin

import VueBreakpointer from 'vue-breakpointer'
...
Vue.use(VueBreakpointer, {
  // defaults
  breakpoints: {
    sm: 576,
    md: 768,
    lg: 992,
    xl: 1200
  }
})
...

Mixin

import { VueBreakpointerMixin } from 'vue-breakpointer'
...
export default {
  ...
  mixins: [ VueBreakpointerMixin ],
  data () {
    return {
      // defaults
      breakpoints: {
        sm: 576,
        md: 768,
        lg: 992,
        xl: 1200
      }
    }
  }
  ...
}
...

Data & Computed Properties

PropertyTypeDescription
windowDimensionsObjectOn object containing both the current window width & height (in pixels)
xsBoolean< sm
smBoolean>= sm && < md
mdBoolean>= md && < lg
lgBoolean>= lg && < xl
xlBoolean>= xl

Example usage

<template>
  <div>
    <!-- an object showing both width and height of window -->
    <pre>{{windowDimensions}}</pre>

    <!-- the current breakpoint -->
    <pre>{{breakpoint}}</pre>

    <!-- use to determine visibility of elements and components at certain breakpoints -->
    <div v-if="xs">I am visible only on xs screens</div>
    <div v-if="sm">I am visible only on sm screens</div>
    <div v-if="md">I am visible only on md screens</div>
    <div v-if="lg">I am visible only on lg screens</div>
    <div v-if="xl">I am visible only on xl screens</div>
  </div>
</template>

Example

https://jsfiddle.net/5k6v07br/

0.1.6

5 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago