BlogPlaygroundOne

Grid system

Vuetify comes with a 12 point grid system built using flexbox.

The grid is used to create specific layouts within an application’s content. It contains 5 types of media breakpoints that are used for targeting specific screen sizes or orientations: xs, sm, md, lg and xl. These breakpoints are defined below in the Viewport Breakpoints table and can be modified by customizing the Breakpoint service.

Usage

The Vuetify grid is heavily inspired by the Bootstrap grid. It is implemented by using a series of containers, rows, and columns to layout and align content. If you are new to flexbox, read the CSS Tricks flexbox guide for background, terminology, guidelines, and code snippets.

One of three columns
One of three columns
One of three columns
DeviceCodeTypeRange
Extra smallxsSmall to large phone< 600px
SmallsmSmall to medium tablet600px > < 840px
MediummdLarge tablet to laptop840px > < 1145px
LargelgLaptop to desktop1145px > < 1545px
Extra largexl1080p to 1440p desktop1545px > < 2138px
Extra extra largexxl4k and ultra-wide> 2138px
Specification

API

ComponentDescription
v-containerThe container component.
v-rowSub-component used to create rows.
v-colSub-component used to create columns.
v-spacerA component often used in grid scenarios.
Toggle Inline API

Sub-components

v-container

v-container provides the ability to center and horizontally pad your site’s contents. You can also use the fluid prop to fully extend the container across all viewport and device sizes. Maintains previous 1.x functionality in which props are passed through as classes on v-container allowing for the application of helper classes (such as ma-#/pa-#/fill-height) to easily be applied.

v-col

v-col is a content holder that must be a direct child of v-row. This is the 2.x replacement for v-flex in 1.x.

v-row

v-row is a wrapper component for v-col. It utilizes flex properties to control the layout and flow of its inner columns. It uses a standard gutter of 24px. This can be modified using the density prop - use comfortable for reduced gutters or compact to remove them completely. This is the 2.x replacement for v-layout in 1.x.

v-spacer

v-spacer is a basic yet versatile spacing component used to distribute remaining width in-between a parents child components. When placing a single v-spacer before or after the child components, the components will push to the right and left of its container. When more than one v-spacer’s are used between multiple components, the remaining width is evenly distributed between each spacer.

Helper Classes

The class fill-height applies height: 100% to an element. When applied to v-container it will also set align-items: center.

Caveats

Examples

Props

Size

The size prop on v-row defines the number of columns for the columns placed directly within. The example below sets it to 5 instead of 12.

Align

Change the vertical alignment of flex items and their parents using the align and align-self utility classes.

align-start
align-start
align-start
align-center
align-center
align-center
align-end
align-end
align-end
align-self-start
align-self-center
align-self-end

Breakpoint sizing

Columns will automatically take up an equal amount of space within their parent container. This can be modified using the cols prop. You can also utilize the sm, md, lg, and xl props to further define how the column will be sized in different viewport sizes.

v-col-auto
v-col-auto
v-col-auto
v-col-auto
v-col-auto
v-col-2
v-col-auto
v-col-2
v-col-1
v-col-2

Justify

Change the horizontal alignment of flex items using the justify utility classes.

justify-start
justify-start
justify-center
justify-center
justify-end
justify-end
justify-space-around
justify-space-around
justify-space-between
justify-space-between

No gutters

You can remove the negative margins from v-row and the padding from its direct v-col children using the density property.

v-col-12
v-col-6

Offset

Offsets are useful for compensating for elements that may not be visible yet, or to control the position of content. Just as with breakpoints, you can set an offset for any available sizes. This allows you to fine tune your application layout precisely to your needs.

.v-col-4
.v-col-4 .offset-4
.v-col-3 .offset-3
.v-col-3 .offset-3
.v-col-6 .offset-3

Offset breakpoint

Offset can also be applied on a per breakpoint basis.

v-col-sm-5 v-col-md-6
v-col-sm-5 offset-sm-2 v-col-md-6 offset-md-0
sm-6 md-5 lg-6
v-col-sm-6 md-5 offset-md-2 v-col-lg-6 offset-lg-0

Order

You can control the ordering of grid items. As with offsets, you can set different orders for different sizes using the order utility classes. Design specialized screen layouts that accommodate to any application.

First in markup, but middle in row
Second in markup, but last in row
Third in markup, but first in row

Order first and last

You can also designate explicitly first or last using the order-first and order-last utility classes.

First, but last
Second, but unordered
Third, but first

Misc

Column wrapping

When more than 12 columns are placed within a given row (that is not using the .flex-nowrap utility class), each group of extra columns will wrap onto a new line.

In the example below, the first and second v-col components are a total of 13 columns wide, which means the second v-col gets wrapped to a new line.

v-col-9
v-col-4
v-col-6

Equal width columns

You can break equal width columns into multiple lines using v-responsive.

v-col
v-col
v-col
v-col

Grow and Shrink

By default, flex components will automatically fill the available space in a row or column. They will also shrink relative to the rest of the flex items in the flex container when a specific size is not designated. You can define the column width of the v-col by using the cols prop and providing a value from 1 to 12.

v-col-auto
v-col-auto
v-col-auto
v-col-auto
v-col-8
v-col-4

Margin helpers

Using the auto margin helper utilities you can force sibling columns away from each other.

v-col-md-4
v-col-md-4 .ms-auto
v-col-md-4 .ms-md-auto
v-col-md-4 .ms-md-auto
v-col-auto .me-auto
v-col-auto

Nested grid

Grids can be nested, similar to other frameworks, in order to achieve very custom layouts.

Level 1: v-col-8
Level 2: v-col-8
Level 2: v-col-4
Level 1: v-col-4

One column width

When using the auto-layout, you can define the width of only one column and still have its siblings to automatically resize around it.

v-col-auto
v-col-6
v-col-auto
v-col-auto
v-col-2
v-col-auto

Row and column breakpoints

Dynamically change your layout based upon resolution. Resize your screen and watch the row layout change on sm, md, and lg breakpoints.

v-col-3
v-col-9

Size overrides

The v-col component can override the row’s size using a fraction syntax like cols="2/5". This means the column takes 2 parts of a 5-column grid. You can also use responsive props like md and lg or offset with the same syntax.

2/5
1/2
1/10
grow | offset:1/2
grow | offset-md:1/3
grow | offset-lg:0
1/2
md:1/3
lg:1/4
1/4 | offset:1/8
md:1/3 | offset-md:1/6
lg:1/2 | offset-lg:0

Spacers

The v-spacer component is useful when you want to fill available space or make space between two components.

v-col-auto
v-col-auto
v-col-auto
v-col-auto
v-col-auto

Ready for more?

Continue your learning with related content selected by the Team or move between pages by using the navigation links below.