Gathering detailed insights and metrics for vue-mq
Gathering detailed insights and metrics for vue-mq
Gathering detailed insights and metrics for vue-mq
Gathering detailed insights and metrics for vue-mq
📱 💻 Define your breakpoints and build responsive design semantically and declaratively in a mobile-first way with Vue.
npm install vue-mq
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
537 Stars
37 Commits
59 Forks
6 Watchers
25 Branches
3 Contributors
Updated on May 11, 2025
Latest Version
1.0.1
Package Id
vue-mq@1.0.1
Size
294.46 kB
NPM Version
5.6.0
Node Version
9.11.2
Published on
Dec 12, 2018
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
7
Define your breakpoints and build responsive design semantically and declaratively in a mobile-first way with Vue.
_Use with vue: ^2.x.x
_
Demo: here
1npm install vue-mq
1yarn add vue-mq
Define your custom breakpoints by passing breakpoints
option. This let you name the breakpoints as you want
Eg:
{ phone: 500, tablet: 1200, other: Infinity }
{ small: 500, large: 1200, whatever: Infinity }
{ xs: 300, s: 500, m: 800, l: 1200, xl: Infinity }
1import Vue from 'vue' 2import VueMq from 'vue-mq' 3 4Vue.use(VueMq, { 5 breakpoints: { // default breakpoints - customize this 6 sm: 450, 7 md: 1250, 8 lg: Infinity, 9 } 10 defaultBreakpoint: 'sm' // customize this for SSR 11})
$mq
propertyAfter installing the plugin every instance of Vue component is given access to a reactive $mq property. Its value will be a String
which is the current breakpoint.
Eg: (with default breakpoints)
'sm'
=> 0 > screenWidth < 450
'md'
=> 450 >= screenWidth < 1250
'lg'
=> screenWidth >= 1250
1//Use it in a component
2new Vue({
3 template: `
4 <h1>current: {{$mq}}</h1>
5 `,
6})
$mq
property with the mq filterUsing the filter allow to build your responsive design in a declarative way. This can be very useful and elegant to pass down props to layout component. (eg: a grid system)
1new Vue({
2 template: `
3 <grid-component :column="$mq | mq({ sm: 1, md: 2, lg: 3 })">
4 </grid-component>
5 `,
6})
Remember that the filter design embrace mobile-first philosophy so writing $mq | mq({ sm: 1, lg: 3 })
will output 1
for md
breakpoint if omited. In short it will always fallback to the smallest breakpoint (aka mobile) if value isn't overriden by a largest breakpoint.
$mq
with a computed property$mq
property is fully reactive (like a data property) so feel free to use it in a computed.
1new Vue({ 2 computed: { 3 displayText() { 4 return this.$mq === 'sm' ? 'I am small' : 'I am large' 5 } 6 }, 7 template: ` 8 <h1>{{displayText}}</h1> 9 `, 10})
In addition to $mq
property this plugin provide a wrapper component to facilitate conditional rendering with media queries.
Usage:
<mq-layout mq="lg">
<span> Display on lg </span>
</mq-layout>
<mq-layout mq="md+">
<span> Display on md and larger </span>
</mq-layout>
<mq-layout :mq="['sm', 'lg']">
<span> Display on sm and lg </span>
</mq-layout>
Props mq => required : String | Array
Important: note that you can append a +
modifier at the end of the string to specify that the conditional rendering happens for all greater breakpoints.
v1.0+ now supports SSR. You can customize the defaultBreakpoint
which let you set the breakpoint used by the server-side-rendering
This plugin relies on matchMedia API to detect screensize change. So for older browsers and IE, you should polyfill this out: Paul Irish: matchMedia polyfill
Please open an issue for support.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 1/29 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
152 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-14
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More