Spacing
Update your layout without creating new classes. Spacing helpers are useful for modifying the padding and margin of an element.
Use the playground to get a feel for what the different helper classes can do. For an explanation of how they work, see the How it works section below.
How it works
The helper classes apply margin, padding, or gap to an element ranging from 0 to 16. Each size increment was designed to align with common Material Design spacings. These classes can be applied using the following format {property}{direction}-{size}
.
The property applies the type of spacing:
m
- appliesmargin
p
- appliespadding
g
- appliesgap
The direction designates the side the property applies to:
t
- applies the spacing formargin-top
andpadding-top
b
- applies the spacing formargin-bottom
andpadding-bottom
l
- applies the spacing formargin-left
andpadding-left
r
- applies the spacing formargin-right
,padding-right
, androw-gap
s
- applies the spacing formargin-left
/padding-left
(in LTR mode) andmargin-right
/padding-right
(in RTL mode)e
- applies the spacing formargin-right
/padding-right
(in LTR mode) andmargin-left
/padding-left
(in RTL mode)x
- applies the spacing for margin and padding*-left
and*-right
y
- applies the spacing for margin and padding*-top
and*-bottom
a
- applies the spacing formargin
,padding
andgap
in all directionsc
- applies the spacing forcolumn-gap
The size controls the increment of the property in 4px intervals:
0
- eliminates allmargin
,padding
orgap
by setting it to0
1
- setsmargin
,padding
orgap
to 4px2
- setsmargin
,padding
orgap
to 8px3
- setsmargin
,padding
orgap
to 12px4
- setsmargin
,padding
orgap
to 16px5
- setsmargin
,padding
orgap
to 20px6
- setsmargin
,padding
orgap
to 24px7
- setsmargin
,padding
orgap
to 28px8
- setsmargin
,padding
orgap
to 32px9
- setsmargin
,padding
orgap
to 36px10
- setsmargin
,padding
orgap
to 40px11
- setsmargin
,padding
orgap
to 44px12
- setsmargin
,padding
orgap
to 48px13
- setsmargin
,padding
orgap
to 52px14
- setsmargin
,padding
orgap
to 56px15
- setsmargin
,padding
orgap
to 60px16
- setsmargin
,padding
orgap
to 64pxn1
- setsmargin
to -4pxn2
- setsmargin
to -8pxn3
- setsmargin
to -12pxn4
- setsmargin
to -16pxn5
- setsmargin
to -20pxn6
- setsmargin
to -24pxn7
- setsmargin
to -28pxn8
- setsmargin
to -32pxn9
- setsmargin
to -36pxn10
- setsmargin
to -40pxn11
- setsmargin
to -44pxn12
- setsmargin
to -48pxn13
- setsmargin
to -52pxn14
- setsmargin
to -56pxn15
- setsmargin
to -60pxn16
- setsmargin
to -64pxauto
- sets the spacing to auto
Examples
Breakpoints
Vuetify comes with a 12 point grid system built using Flexbox. Spacing is used to create specific layouts within an application's content. It consists of 5 media breakpoints used to target specific screen sizes or orientations: xs, sm, md, lg and xl. The default resolutions are defined below in the Viewport Breakpoints table and can be modified by customizing the breakpoint service config.
Device | Code | Type | Range |
---|---|---|---|
Extra small | xs | Small to large phone | < 600px |
Small | sm | Small to medium tablet | 600px > < 960px |
Medium | md | Large tablet to laptop | 960px > < 1280px |
Large | lg | Laptop to desktop | 1280px > < 1920px |
Extra large | xl | 1080p to 1440p desktop | 1920px > < 2560px |
Extra extra large | xxl | 4k and ultra-wide | > 2560px |
Specification |
The helper classes apply margin or padding at a given breakpoint. These classes can be applied using the following format: {property}{direction}-{breakpoint}-{size}
. This does not apply to xs as it is inferred; e.g. ma-xs-2
equals ma-2
.
Horizontal
Margin helper classes let you easily center content horizontally.
Gap
Use the gap helper classes to easily apply a gap between content.
Negative margin
Margin can also be applied negatively at the same 1 to 16 intervals.