Gathering detailed insights and metrics for vue-container-query-2
Gathering detailed insights and metrics for vue-container-query-2
Gathering detailed insights and metrics for vue-container-query-2
Gathering detailed insights and metrics for vue-container-query-2
npm install vue-container-query-2
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
7 Stars
17 Commits
2 Forks
1 Watchers
21 Branches
1 Contributors
Updated on Jul 30, 2020
Latest Version
0.2.6
Package Id
vue-container-query-2@0.2.6
Unpacked Size
180.30 kB
Size
44.36 kB
File Count
10
NPM Version
6.12.0
Node Version
13.0.1
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
2
1
22
🧐 Because vue-container-query
was taken, and API is a little like vue-container-query
package. So, thank you the maintainer.
Vue plugin for working with css container query as easy as possible.
💥 This is the beta version. It's safe for production, but keep an eye on documentations if you wanted to upgrade the package. There probably will be breaking changes in first major release
1npm install vue-container-query-2 2// or 3yarn add vue-container-query-2
This is also available on jsdeliver and unpkg.
Import and register the vue-container-query-2
plugin first.
1import VueContainerQuery from 'vue-container-query-2'; 2Vue.use(VueContainerQuery, options);
And :tada: voila, now you have a cq
option in every SFCs like below
1export default { 2 name: 'SearchField', 3 cq: { 4 large: { minWidth: 900 }, 5 medium: { maxWidth: 600 }, 6 small: { maxWidth: 460 } 7 }, 8 data() { 9 return {} 10 }, 11 ...
:warning: for maxWidth
you get <=
, but for minWidth
it's >
and no =
. So the behavior is not quite like CSS Media Queries. Although it's a little bit more well formatted. But it may change during next major release. so, heads up.
After defining breakpoints, you'll have reactive $cq
variable in your component. You can use this anyhow you need. Maybe dynamic classes, maybe show/hide other element or components, whatever.
1<div 2 :class="{ 3 'search--small': $eq.small 4 } 5> 6 <span v-if="$eq.large"> 7 Yo. I only get rendered if the componenet is 900px or wider 8 </span> 9</div>
This is a sample of how $eq
object looks like in the instance's context:
1{ 2 contentRect: { 3 x:0, 4 y: 0, 5 width:1300, 6 height: 2124, 7 top: 0, 8 right: 1300, 9 bottom: 2124, 10 left:0 11 }, 12 breakpoints: { 13 large: { minWidth: 900 } 14 medium: { maxWidth: 600 }, 15 small: { maxWidth: 460 } 16 }, 17 resizeObserver: [object ResizeObserver], 18 large: true 19 medium: true, 20 small: false 21}
This is default options:
1{ 2 classNames: { 3 sizes: { 4 xsmall: 'xsmall', 5 small: 'small', 6 medium: 'medium', 7 large: 'large', 8 xlarge: 'xlarge' 9 }, 10 prepend: '' 11 }, 12 useBEM: true, 13 utilityClassNamesRegex: /$^/, 14 ignoredClasses: [''] 15}
You can override these when registering the plugin:
1Vue.use(VueContainerQuery, { 2 classNames: { 3 sizes: { 4 xsmall: 'size:xsmall', 5 small: 'size:small', 6 medium: 'size:medium', 7 large: 'size:large', 8 xlarge: 'size:xlarge' 9 } 10 }, 11 useBEM: true, 12 utilityClassNamesRegex: /u-/g, 13});
☝ All options are only useful when you are using v-cq
directive. the core works fine without any provided option
useBEM
If this set as true
, the classes will respect the BEM convention. Say your element has search
class, then when small condition is on, a search--small
class adds to element. VCQ is smart enough to ignore --
classes when generating new class names. But if your element has multiple classes like search
header
, you will get both search--small
and header--small
. so if you are using useBEM
make sure you implement the true BEM. otherwise this plugin won't work that nice.
utilityClassNamesRegex
You can set a regex to ignore any sort of utility class that you don't want to consider as semantic class.
You can set an array to ignore any sort of class that you don't want to consider as semantic class.
This may be the best feature of thin package. There also is a handy v-cq
directive available to automate the process of setting size classes. so, all you need to make the element to get size classes is like below:
1<div 2 v-cq 3 class="card" 4> 5 ... 6></div> 7 8<!-- <div class="card card--small"><div> --> 9<!-- <div class="card card--medium"><div> --> 10<!-- <div class="card card--large"><div> -->
See there? no :class
and checking for $cq.small
or anything. size classes will automatically get calculated and attached to element. remember that size classes are based on what you did set in options, if not, default ones as fallback.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 1/16 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
license file not detected
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
125 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