Amina Semhar

Amina Semhar

1612815120

Handle Media Queries Easily & Build Responsive Design with Vue 3

Vue 3 MQ (Media Query)

Define your breakpoints and build responsive design semantically and declaratively in a mobile-first way with Vue 3.

Use with vue: ^3.x.x

Table of Contents

Migration Guide

Filter

Since Vue 3 has dropped support for filters, the previous functionality has been removed

SSR

Presently, support for SSR has been removed

Demo

See https://vue3-mq.info for a demonstration and usage guide for Vue3-MQ.

Installation

Using NPM
npm install vue3-mq

Usage

1.) Add plugin to Vue

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 }

import { createApp } from "vue";
import VueMq from "vue3-mq";

const app = createApp({});

app.use(VueMq, {
  breakpoints: { // default breakpoints - customize this
    sm: 450,
    md: 1250,
    lg: Infinity,
  }
})

app.mount('#app');

2.) Use $mq global property

After 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

<template>
  <div>{{ $mq }}</div>
</template>

3.) Use $mq with a computed property

The $mq property is fully reactive, so feel free to use it in a computed.

createApp({
  computed: {
    displayText() {
      return this.$mq === 'sm' ? 'I am small' : 'I am large'
    }
  },
  template: `
    <h1>{{displayText}}</h1>
  `,
})

4.) Update breakpoints

A function is available via Vue’s provide method which allows you to dynamically change the breakpoints which are responded to. Simply inject it into any component where it’s needed.

import { inject, onMounted } from "vue";

setup() {
    const updateBreakpoints = inject("updateBreakpoints");

    onMounted() {
      updateBreakpoints({
            xs: 576,
            sm: 768,
            md: 992,
            lg: 1200,
            xl: 1400,
            xxl: Infinity
        })
    }
}

5.) MqLayout component

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']" tag="span">
  Display on sm and lg
</mq-layout>

Props

mq => required : [String,Array] - see below

tag => optional : String - sets the HTML tag to use for the rendered component (default ‘div’)

MQ prop: plus modifier

Appending a + to your mq property will make the component render on that breakpoint and any above

<mq-layout mq="lg+" tag="span">I will render on large and above screen sizes</mq-layout>
MQ prop: minus modifier

Appending a - to your mq property will make the component render on that breakpoint and any below

<mq-layout mq="md-" tag="span">I will render on medium and below screen sizes</mq-layout>
MQ prop: range modifier

Placing a - between two breakpoints in your mq property will make the component render on any breakpoints in that range

<mq-layout mq="sm-lg">I will render on small, medium and large screen sizes</mq-layout>

Browser Support

This plugin relies on matchMedia API to detect screen size change. So for older browsers and IE, you should polyfill this out: Paul Irish: matchMedia polyfill

Support

Please open an issue for support.

Download Details:

Author: craigrileyuk

Demo: https://craigriley.uk/

Source Code: https://github.com/craigrileyuk/vue3-mq

#vue #vuejs #javascript

What is GEEK

Buddha Community

Handle Media Queries Easily & Build Responsive Design with Vue 3

Mobile Responsive Web Design

Mobile responsive website design will make your site mobile-friendly, improve the way it looks on devices with both large and small screens, increase the amount of time that visitors spend on your site and help you improve your rankings in search engines.

Contact now to Get the best website design services at a reasonable price from Skenix Infotech.

#responsive web design company in india #responsive web design services #hire web designer #mobile responsive design #responsive web design #mobile web design

Luna  Mosciski

Luna Mosciski

1600583123

8 Popular Websites That Use The Vue.JS Framework

In this article, we are going to list out the most popular websites using Vue JS as their frontend framework.

Vue JS is one of those elite progressive JavaScript frameworks that has huge demand in the web development industry. Many popular websites are developed using Vue in their frontend development because of its imperative features.

This framework was created by Evan You and still it is maintained by his private team members. Vue is of course an open-source framework which is based on MVVM concept (Model-view view-Model) and used extensively in building sublime user-interfaces and also considered a prime choice for developing single-page heavy applications.

Released in February 2014, Vue JS has gained 64,828 stars on Github, making it very popular in recent times.

Evan used Angular JS on many operations while working for Google and integrated many features in Vue to cover the flaws of Angular.

“I figured, what if I could just extract the part that I really liked about Angular and build something really lightweight." - Evan You

#vuejs #vue #vue-with-laravel #vue-top-story #vue-3 #build-vue-frontend #vue-in-laravel #vue.js

Hire Dedicated Responsive Web Designers - Hire Web Designer

With the different sizes of smartphones and tablets used today, it has become necessary that a business website or app should be able to adjust its size accordingly.

Want to create a responsive web design that adjusts to the screen size itself?

Hire Dedicated Responsive Web Designers from WebClues Infotech that can create magic with their skills. Your Web Applications will adjust to all screen and resolution sizes from the lowest to the highest to offer a good user experience.

Get your responsive design developers based on your project requirement.

Get in touch with us!!

Share your requirements here https://www.webcluesinfotech.com/contact-us/

Book Free Interview with Responsive Web Designers: https://bit.ly/3dDShFg

View Portfolio https://www.webcluesinfotech.com/portfolio/

#hire web designer #hire dedicated responsive web designers #hire dedicated responsive web designer usa #hire web designers #hire dedicated website designers #hire responsive web designers

Amina Semhar

Amina Semhar

1612815120

Handle Media Queries Easily & Build Responsive Design with Vue 3

Vue 3 MQ (Media Query)

Define your breakpoints and build responsive design semantically and declaratively in a mobile-first way with Vue 3.

Use with vue: ^3.x.x

Table of Contents

Migration Guide

Filter

Since Vue 3 has dropped support for filters, the previous functionality has been removed

SSR

Presently, support for SSR has been removed

Demo

See https://vue3-mq.info for a demonstration and usage guide for Vue3-MQ.

Installation

Using NPM
npm install vue3-mq

Usage

1.) Add plugin to Vue

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 }

import { createApp } from "vue";
import VueMq from "vue3-mq";

const app = createApp({});

app.use(VueMq, {
  breakpoints: { // default breakpoints - customize this
    sm: 450,
    md: 1250,
    lg: Infinity,
  }
})

app.mount('#app');

2.) Use $mq global property

After 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

<template>
  <div>{{ $mq }}</div>
</template>

3.) Use $mq with a computed property

The $mq property is fully reactive, so feel free to use it in a computed.

createApp({
  computed: {
    displayText() {
      return this.$mq === 'sm' ? 'I am small' : 'I am large'
    }
  },
  template: `
    <h1>{{displayText}}</h1>
  `,
})

4.) Update breakpoints

A function is available via Vue’s provide method which allows you to dynamically change the breakpoints which are responded to. Simply inject it into any component where it’s needed.

import { inject, onMounted } from "vue";

setup() {
    const updateBreakpoints = inject("updateBreakpoints");

    onMounted() {
      updateBreakpoints({
            xs: 576,
            sm: 768,
            md: 992,
            lg: 1200,
            xl: 1400,
            xxl: Infinity
        })
    }
}

5.) MqLayout component

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']" tag="span">
  Display on sm and lg
</mq-layout>

Props

mq => required : [String,Array] - see below

tag => optional : String - sets the HTML tag to use for the rendered component (default ‘div’)

MQ prop: plus modifier

Appending a + to your mq property will make the component render on that breakpoint and any above

<mq-layout mq="lg+" tag="span">I will render on large and above screen sizes</mq-layout>
MQ prop: minus modifier

Appending a - to your mq property will make the component render on that breakpoint and any below

<mq-layout mq="md-" tag="span">I will render on medium and below screen sizes</mq-layout>
MQ prop: range modifier

Placing a - between two breakpoints in your mq property will make the component render on any breakpoints in that range

<mq-layout mq="sm-lg">I will render on small, medium and large screen sizes</mq-layout>

Browser Support

This plugin relies on matchMedia API to detect screen size change. So for older browsers and IE, you should polyfill this out: Paul Irish: matchMedia polyfill

Support

Please open an issue for support.

Download Details:

Author: craigrileyuk

Demo: https://craigriley.uk/

Source Code: https://github.com/craigrileyuk/vue3-mq

#vue #vuejs #javascript

CSS Media Queries in 15 Minutes | Responsive Design | CSS Tutorial for Beginners

#css #media #15 minutes #design #responsive design #tutorial