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- appliesmarginp- appliespaddingg- appliesgap
The direction designates the side the property applies to:
t- applies the spacing formargin-topandpadding-topb- applies the spacing formargin-bottomandpadding-bottoml- applies the spacing formargin-leftandpadding-leftr- applies the spacing formargin-right,padding-right, androw-gaps- 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*-leftand*-righty- applies the spacing for margin and padding*-topand*-bottoma- applies the spacing formargin,paddingandgapin all directionsc- applies the spacing forcolumn-gap
The size controls the increment of the property in 4px intervals:
0- eliminates allmargin,paddingorgapby setting it to01- setsmargin,paddingorgapto 4px2- setsmargin,paddingorgapto 8px3- setsmargin,paddingorgapto 12px4- setsmargin,paddingorgapto 16px5- setsmargin,paddingorgapto 20px6- setsmargin,paddingorgapto 24px7- setsmargin,paddingorgapto 28px8- setsmargin,paddingorgapto 32px9- setsmargin,paddingorgapto 36px10- setsmargin,paddingorgapto 40px11- setsmargin,paddingorgapto 44px12- setsmargin,paddingorgapto 48px13- setsmargin,paddingorgapto 52px14- setsmargin,paddingorgapto 56px15- setsmargin,paddingorgapto 60px16- setsmargin,paddingorgapto 64pxn1- setsmarginto -4pxn2- setsmarginto -8pxn3- setsmarginto -12pxn4- setsmarginto -16pxn5- setsmarginto -20pxn6- setsmarginto -24pxn7- setsmarginto -28pxn8- setsmarginto -32pxn9- setsmarginto -36pxn10- setsmarginto -40pxn11- setsmarginto -44pxn12- setsmarginto -48pxn13- setsmarginto -52pxn14- setsmarginto -56pxn15- setsmarginto -60pxn16- setsmarginto -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.