Vuetify is a popular UI component library for VueJs. It is an open-source library and provides a wide range of pre-designed responsive components. It provides a comprehensive set of components for building front-end web applications that include the following:
Layout grids
Vavigation bars
Forms
Buttons
Datatables
In this Answer, we'll learn about the basic grid system of Vuetify.
To create a basic responsive layout using Vuetify's grid system, we'll follow the following steps:
Install Vuetify in our VueJs project using the following command:
npm install vuetify
Import Vuetify and its CSS in your main application file, i.e., main.js
.
import Vue from 'vue';import Vuetify from 'vuetify';import 'vuetify/dist/vuetify.css';Vue.use(Vuetify);new Vue({// Your app configuration}).$mount('#app');
Now, we can use Vuetify in our project, since it is mounted with our all components.
To create a grid system, we first have to learn about the following components of a grid system:
v-container
v-row
v-col
v-container
The v-container
component is part of Vuetify's layout system and serves as a wrapper for content within a page or a section of a page. It helps in creating a responsive and centered container for your content.
v-row
The v-row
component is another part of Vuetify's layout system and is used to create a row within a v-container
or any other container element. It helps in organizing and aligning columns or other content within a horizontal row.
v-col
The v-col
component is a crucial part of Vuetify's layout system and is used to create columns within a v-row
or any other container element. It helps in organizing and controlling the width and behavior of columns in a grid layout.
Cols
We can specify the width of a column using the cols
prop. The value of cols
represents the number of grid columns that a column should occupy. By default, each column occupies 12 columns, which means that setting cols="6"
will make the column occupy half of the available width and so on.
There is also a further breakdown of the cols
prop; let's discuss that:
sm="6"
: This specifies that the column should span 6 columns on small screens and larger.
md="6"
: This specifies that the column should span 6 columns on medium screens and larger.
lg="6"
: This specifies that the column should span 6 columns on large screens.
xs="6"
: This specifies that the column should span 6 columns on extra-small screens.
xl="6"
: This specifies that the column should span 6 columns on extra-large screens.
¨( @ ¸A¸A¸A¸A¸A¸A¸A3¸A3¸A¸A¸A¸A¸A±¸A±¸A¸A¸A¸A¸AZ¸A÷¸A÷¸AZ¸A¸A¸A¸A¸AɸAÿ¸Aÿ¸AɸA¸A¸A¸A¸Az¸Aþ¸Aÿ¸Aÿ¸Aþ¸Az¸A¸A¸A¸A¸A.¸A߸Aÿ¸Aÿ¸Aÿ¸Aÿ¸A߸A.¸A¸A¸A¸A¸A¸Aÿ¸Aÿ¸Aÿ¸Aÿ¸Aÿ¸Aÿ¸A¸A¸A¸A¸A¸AH¸Að¸Aÿ¸Aÿ¸Aÿ¸Aÿ¸Aÿ¸Aÿ¸Að¸AH¸A¸A¸A¸A¸A¸¸Aÿ¸Aÿ¸Aÿ¸Aÿ¸Aÿ¸Aÿ¸Aÿ¸Aÿ¸A¸¸A¸A¸A¸A¸Af¸Aú¸Aÿ¸Aÿ¸Aÿ¸Aÿ¸Aÿ¸Aÿ¸Aÿ¸Aÿ¸Aú¸Af¸A¸A¸A¸A ¸AÒ¸Aÿ¸Aÿ¸Aÿ¸Aÿ¹Aÿ¹Aÿ¸Aÿ¸Aÿ¸Aÿ¸Aÿ¸AÒ¸A ¸A¸A¸A¸A¸Aÿ¸Aÿ¸Aÿ¸Aÿ¹Aÿ|¤?ÿ|¤?ÿ¹Aÿ¸Aÿ¸Aÿ¸Aÿ¸Aÿ¸A¸A¸A¸A¸A¸A7¸Aæ¸Aÿ¸Aÿ¸Aÿ¸Aÿ´Aÿjl9ÿjl9ÿ´Aÿ¸Aÿ¸Aÿ¸Aÿ¸Aÿ¸Aæ¸A7¸A¸A¸A¸A ¸A¦¸Aÿ¸Aÿ¸Aÿ¸Aÿ¹Aÿw=ÿ_L5ÿ_L5ÿw=ÿ¹Aÿ¸Aÿ¸Aÿ¸Aÿ¸Aÿ¸A¦¸A ¸A¸A¸A¸AR¸Aô¸Aÿ¸Aÿ¸Aÿ¹Aÿ®@ÿfa8ÿ^H5ÿ^H5ÿfa8ÿ®@ÿ¹Aÿ¸Aÿ¸Aÿ¸Aÿ¸Aô¸AR¸A¸A¸A¸A¸A¸Aÿ¸Aÿ¸Aÿ¸Aÿ¹Aÿr <ÿ^I5ÿ^I5ÿ^I5ÿ^I5ÿr <ÿ¹Aÿ¸Aÿ¸Aÿ¸Aÿ¸Aÿ¸A¸A¸A¸A¸A¸Aq¸Aü¸Aÿ¸Aÿ¸Aÿ¹Aÿ}¦?ÿcW7ÿ^H5ÿ^I5ÿ^I5ÿ^H5ÿcW7ÿ}¦?ÿ¹Aÿ¸Aÿ¸Aÿ¸Aÿ¸Aü¸Aq¸A¸A¸A¸A(¸AÚ¸Aÿ¸Aÿ¸Aÿ¸Aÿ·Aÿmv:ÿ^H5ÿ^I5ÿ^I5ÿ^I5ÿ^I5ÿ^H5ÿmv:ÿ·Aÿ¸Aÿ¸Aÿ¸Aÿ¸Aÿ¸AÚ¸A(¸A¸A¸A¸A¸Aÿ¸Aÿ¸Aÿ¸Aÿ¹Aÿy>ÿ`P6ÿ^H5ÿ^I5ÿ^I5ÿ^I5ÿ^I5ÿ^H5ÿ`P6ÿy>ÿ¹Aÿ¸Aÿ¸Aÿ¸Aÿ¸Aÿ¸A¸A¸A¸A¸A¸A@¸Aì¸Aÿ¸Aÿ¸Aÿ¸Aÿ²@ÿii9ÿ]G5ÿ^I5ÿ^I5ÿ^I5ÿ^I5ÿ^I5ÿ^I5ÿ]G5ÿii9ÿ²@ÿ¸Aÿ¸Aÿ¸Aÿ¸Aÿ¸Aì¸A@¸A¸A¸A¸A ¸A±¸Aÿ¸Aÿ¸Aÿ¸Aÿ¹Aÿu=ÿ_K5ÿ^I5ÿ^I5ÿ^I5ÿ^I5ÿ^I5ÿ^I5ÿ^I5ÿ^I5ÿ_K5ÿu=ÿ¹Aÿ¸Aÿ¸Aÿ¸Aÿ¸Aÿ¸A±¸A ¸A¸A¸A¸A]¸Aø¸Aÿ¸Aÿ¸Aÿ¹Aÿ¬@ÿe]7ÿ^H5ÿ^I5ÿ^I5ÿ^I5ÿ^J5å^J5å^I5ÿ^I5ÿ^I5ÿ^H5ÿe]7ÿ¬@ÿ¹Aÿ¸Aÿ¸Aÿ¸Aÿ¸Aø¸A]¸A¸A¸A¸A¸A̸Aÿ¸Aÿ¸Aÿ¸Aÿ¸Aÿp;ÿ^I5ÿ^I5ÿ^I5ÿ^I5ÿ^I5ü_L5n_L5n^I5ü^I5ÿ^I5ÿ^I5ÿ^I5ÿp;ÿ¸Aÿ¸Aÿ¸Aÿ¸Aÿ¸Aÿ¸A̸A¸A¸A¸A¸A}¸Aþ¸Aÿ¸Aÿ¸Aÿ¹Aÿ|¢?ÿbT6ÿ^H5ÿ^I5ÿ^I5ÿ^I5ÿ_J5ÁaP6aP6_J5Á^I5ÿ^I5ÿ^I5ÿ^H5ÿbT6ÿ|¢?ÿ¹Aÿ¸Aÿ¸Aÿ¸Aÿ¸Aþ¸A}¸A¸A¸A¸A/¸Aá¸Aÿ¸Aÿ¸Aÿ¸AÿµAÿlq9ÿ^H5ÿ^I5ÿ^I5ÿ^I5ÿ^I5ó_L5P^H5^H5_L5P^I5ó^I5ÿ^I5ÿ^I5ÿ^H5ÿlq9ÿµAÿ¸Aÿ¸Aÿ¸Aÿ¸Aÿ¸Aá¸A/¸A¸A¸A¸Aÿ¸Aÿ¸Aÿ¸AÿºAÿx=ÿ`N6ÿ^I5ÿ^I5ÿ^I5ÿ^I5ÿ_K5¤bT7aQ6aQ6bT7_K5¤^I5ÿ^I5ÿ^I5ÿ^I5ÿ`N6ÿx=ÿºAÿ¸Aÿ¸Aÿ¸Aÿ¸Aÿ¸A¸A¸AW¸Að¸Aÿ¸Aÿ¸Aÿ¹Aÿ¯@ÿgd8ÿ^H5ÿ^I5ÿ^I5ÿ^I5ÿ^J5å`M65_K5jf9jf9_K5`M65^J5å^I5ÿ^I5ÿ^I5ÿ^H5ÿgd8ÿ¯@ÿ¹Aÿ¸Aÿ¸Aÿ¸Aÿ¸Að¸AW¸A¸AȸAƸAƸAƺAÆv=Æ_K5Æ^I5Æ^I5Æ^I5Æ^I5É_K5uha9bS7bS7ha9_K5u^I5É^I5Æ^I5Æ^I5Æ_K5Æv=ƺAƸAƸAƸAƸAȸA¸A¸A ¸A ¸A ¸A ¹A lr: \D4 ^I5 ^I5 ^I5 ^I5 `M6^H5^H5`M6^I5 ^I5 ^I5 ^I5 \D4 lr9 ¹A ¸A ¸A ¸A ¸A ¸Aÿÿÿÿÿÿÿÿÿþÿÿü?ÿÿü?ÿÿøÿÿøÿÿðÿÿàÿÿàÿÿÀÿÿÀÿÿÿÿÿÿÿþþü?ü?øððààÀÀÀÀàÿÿÿÿ
By defining different values for the cols
prop at different breakpoints, we create a responsive layout. On medium screens, the columns will stack vertically, each occupying the full width of the screen (12 columns). On small screens, the columns will be displayed side by side, each occupying 6 columns. On large screens, each grid column will occupy 4 columns.
By clicking on the link as shown in the following image, we can see the changes mentioned in the above paragraph:
Following are the screen sizes associated with each breakpoint in Vuetify's grid system:
Breakpoint | Screen Size |
xs | less than 600px |
sm | 600px to 959px |
md | 960px to 1263px |
lg | 1264px to 1903px |
xl | 1904px and above |
Note: We are using Vuetify 3.0 version in this Answer.
Free Resources