Vue MQ is a Vue.js plugin designed to simplify responsive web design by providing a declarative and semantic approach to handling media queries. It integrates directly into Vue instances, exposing a reactive `$mq` property that reflects the current breakpoint. Additionally, it offers a `MqLayout` component for conditional rendering of content based on specified breakpoints, including support for ranges (e.g., `md+`) and multiple specific breakpoints. The current stable version is 1.0.1, with significant updates like Server-Side Rendering (SSR) support introduced in v1.0.0. Releases appear to be infrequent, focusing on stability and key features. A core differentiator is its mobile-first design philosophy, particularly evident in its filter utility, allowing developers to define breakpoints centrally and manage responsive behavior directly within Vue templates and component logic, rather than relying solely on CSS media queries. This abstraction aims to streamline the development of responsive user interfaces.
npm install vue-mqVerified import paths — ran on the pinned version, not inferred.
Demonstrates Vue MQ installation, reactive `$mq` property usage, the `MqLayout` component for conditional rendering, and the `mq` filter for dynamic values based on breakpoints.
For Vue 3 projects, install `vue3-mq` (e.g., `npm install vue3-mq`) and consult its documentation for usage. Do not attempt to use `vue-mq`.
Include a `matchMedia` polyfill (e.g., from github.com/paulirish/matchMedia.js) to ensure broader browser compatibility, especially for legacy browsers and IE.
Always define explicit values for all breakpoints where behavior should differ, or be aware that unspecified breakpoints will inherit values from smaller defined breakpoints in a mobile-first cascade.
Ensure `import VueMq from 'vue-mq'; Vue.use(VueMq, { breakpoints: {...} });` is executed before your Vue application or components are mounted.Verify that `Vue.use(VueMq, ...)` is called once and correctly at your application's entry point. Ensure `$mq` is only accessed within Vue component instances (e.g., in `template`, `computed`, `methods`).
Integrate a `matchMedia` polyfill into your project to provide the necessary API for older browsers. Common polyfills are available on GitHub.