Registry / web-framework / vue3-mq

vue3-mq

JSON →
library4.1.0jsnpmunverified

Vue3-MQ is a robust Vue 3 plugin designed to simplify responsive design implementation in web applications by providing reactive access to media query states. It allows developers to define custom breakpoints or utilize a variety of built-in presets, including Bootstrap 4/5, Tailwind, Vuetify 3/4, MUI, and Bulma. The current stable version is 4.1.0, which introduced new presets and a `mergeBreakpoints` configuration option. The library maintains an active release cadence, with consistent minor and patch updates following significant major versions like v3 ("The Reimagining") and v4 (ESM-first, modern stack updates). Its key differentiators include the `<MqLayout>` component, which supports various selectors (single, array, range, plus, minus, and breakpoint slots) for declarative conditional rendering, and a reactive environment analysis object that can also detect user preferences for light/dark themes, screen orientation, and reduced motion. It provides a comprehensive, component-driven approach to adapting application UI to diverse browser environments effectively.

npm install vue3-mq
INSTALL
IMPORT
SIG · VUE3-MQ
V
vue3-mq
web-frameworkjavascriptv4.1.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

createMq
import { createMq } from 'vue3-mq';
const createMq = require('vue3-mq').createMq;
For plugin installation. While the package exports multiple formats, it is ESM-first since v4.0.0. Use `import` statements.
MqLayout
import { MqLayout } from 'vue3-mq';
const MqLayout = require('vue3-mq').MqLayout;
The primary component for conditional rendering based on media queries. Register globally or import locally.
useMq
import { useMq } from 'vue3-mq';
import { mq } from 'vue3-mq';
A composable for programmatic access to the reactive media query state within Vue components.

Demonstrates plugin installation, global breakpoint configuration, and basic usage of the `MqLayout` component and `useMq` composable for responsive rendering based on screen size.

import { createApp } from 'vue'; import App from './App.vue'; import { createMq, useMq, MqLayout } from 'vue3-mq'; const app = createApp(App); app.use(createMq, { defaultBreakpoint: 'lg', // Optional, set a default breakpoint breakpoints: { // Optional, custom breakpoints sm: 640, md: 768, lg: 1024, xl: 1280, xxl: 1536 }, // Alternatively, use a preset: // preset: 'bootstrap5', mergeBreakpoints: { 'custom-large': 1920 } }); app.mount('#app'); // In a Vue component (e.g., App.vue): // <script setup lang="ts"> // import { MqLayout, useMq } from 'vue3-mq'; // const mq = useMq(); // // Reactive check for current breakpoint // console.log('Current breakpoint:', mq.current.value); // </script> // <template> // <div> // <h1>Vue3-MQ Demo</h1> // <!-- Conditional rendering with MqLayout component --> // <mq-layout mq="sm"> // <p>This content is visible only on small screens (sm).</p> // </mq-layout> // <mq-layout mq="md+"> // <p>This content is visible on medium screens (md) and larger.</p> // </mq-layout> // <!-- Using slots for more complex rendering --> // <mq-layout group> // <template #sm> // <p>Using a slot for small screens.</p> // </template> // <template #md-xl> // <p>Using a slot for medium to extra-large screens.</p> // </template> // </mq-layout> // <!-- Programmatic access to media query state --> // <p v-if="mq.current.value === 'sm'">Current screen is small (programmatic check).</p> // <p v-else-if="mq.mdPlus.value">Current screen is medium or larger (programmatic check).</p> // </div> // </template>
Debug
Known issues
breakingVersion 4.0.0 changed the package type to 'module', making it ESM-first. While CJS exports are still available, direct `require()` statements might lead to issues or require specific bundler configurations.
fix
Ensure you are using ESM `import` statements for `vue3-mq` throughout your project. Update bundler configurations if necessary to handle ESM modules correctly.
affects: >=4.0.0
breakingVersion 3.0.0 was a complete rewrite of the plugin, referred to as 'The Reimagining'. This likely introduced significant breaking changes in the API and configuration compared to versions 2.x.
fix
Refer to the official documentation for Vue3-MQ v3 for updated API usage, component props, and configuration options when upgrading from v2.x.
affects: >=3.0.0
gotchaVersions of `vue3-mq` prior to 4.0.3 contained a bug where the global type declaration would incorrectly overwrite Vue's own global types, potentially causing type conflicts in TypeScript projects.
fix
Upgrade to `vue3-mq@4.0.3` or a newer version to resolve the global type declaration conflict.
affects: >=4.0.0 <4.0.3
gotchaIn versions prior to 3.1.1, attempting to dynamically update breakpoints at runtime could lead to errors or unexpected behavior related to preset emissions.
fix
Upgrade to `vue3-mq@3.1.1` or a newer version to ensure proper handling of runtime breakpoint updates without errors.
affects: <3.1.1
Errors
Common errors & fixes
TypeError: (0 , vue3_mq__WEBPACK_IMPORTED_MODULE_2__.createMq) is not a function
This typically occurs in a CommonJS environment or when a bundler struggles with ESM-first packages, attempting to access named exports incorrectly via `require()` syntax or improper configuration.
fix
Ensure your project is configured for ESM, and you are consistently using `import { createMq } from 'vue3-mq';` for plugin instantiation, especially since v4.0.0.
Property 'someVueType' does not exist on type 'GlobalComponents'
This error or similar type conflicts in TypeScript can arise from the global type declaration bug present in `vue3-mq` versions between 4.0.0 and 4.0.2.
fix
Upgrade your `vue3-mq` package to version `4.0.3` or higher to fix the global type declaration issue that was overwriting Vue's types.
[Vue warn]: Failed to resolve component: MqLayout
The `<MqLayout>` component was not properly registered with your Vue application, either globally during plugin installation or locally within the component where it is used.
fix
Ensure `app.use(createMq, { ... })` is correctly called in your `main.ts`/`main.js` file, and `MqLayout` is explicitly imported and added to the `components` option in your component if not globally registered.
Upgrade
Version history
4.1.0latest on npm
Audit
Dependencies
vuerequiredVue 3 is a peer dependency for the plugin to function.
Agent activity
9 hits · last 30 days
node
8
OpenAI (training)
1
Resources
vue3-mq — npm install vue3-mq · libregistry