How it works
Use the margin
or padding
property and choose a direction. Then add size, ranging from 0 to 20.
The properties:
m
- for classes that setmargin
p
- for classes that setpadding
The direction property applies to:
t
- formargin-top
orpadding-top
b
- formargin-bottom
orpadding-bottom
l
- formargin-left
orpadding-left
r
- formargin-right
orpadding-right
s
- formargin-left/padding-left
(in LTR mode) andmargin-right/padding-right
(in RTL mode)e
- formargin-right/padding-right
(in LTR mode) andmargin-left/padding-left
(in RTL mode)x
- formargin-left/padding-left
andmargin-right/padding-right
y
- formargin-top/padding-top
andmargin-bottom/padding-bottom
a
- for all 4 sides.
Size
The size changes with an interval of 4 pixels.
Positive
0
setsmargin
orpadding
to0
1
setsmargin
orpadding
to4px
2
setsmargin
orpadding
to8px
3
setsmargin
orpadding
to12px
4
setsmargin
orpadding
to16px
5
setsmargin
orpadding
to20px
6
setsmargin
orpadding
to24px
7
setsmargin
orpadding
to28px
8
setsmargin
orpadding
to32px
9
setsmargin
orpadding
to36px
10
setsmargin
orpadding
to40px
11
setsmargin
orpadding
to44px
12
setsmargin
orpadding
to48px
13
setsmargin
orpadding
to52px
14
setsmargin
orpadding
to56px
15
setsmargin
orpadding
to60px
16
setsmargin
orpadding
to64px
17
setsmargin
orpadding
to68px
18
setsmargin
orpadding
to72px
19
setsmargin
orpadding
to76px
20
setsmargin
orpadding
to80px
auto
sets the spacing toauto
Negative
n1
setsmargin
to-4px
n2
setsmargin
to-8px
n3
setsmargin
to-12px
n4
setsmargin
to-16px
n5
setsmargin
to-20px
n6
setsmargin
to-24px
n7
setsmargin
to-28px
n8
setsmargin
to-32px
n9
setsmargin
to-36px
n10
setsmargin
to-40px
n11
setsmargin
to-44px
n12
setsmargin
to-48px
n13
setsmargin
to-52px
n14
setsmargin
to-56px
n15
setsmargin
to-60px
n16
setsmargin
to-64px
n17
setsmargin
to-68px
n18
setsmargin
to-72px
n19
setsmargin
to-76px
n20
setsmargin
to-80px
Examples
pa-4 mr-16
pa-4
pa-4 ml-8
<MudPaper Class="pa-4 mr-16"> <MudText Typo="Typo.subtitle2">pa-4 mr-16</MudText> </MudPaper> <MudPaper Class="pa-4"> <MudText Typo="Typo.subtitle2">pa-4</MudText> </MudPaper> <MudPaper Class="pa-4 ml-8"> <MudText Typo="Typo.subtitle2">pa-4 ml-8</MudText> </MudPaper>
Breakpoints
You can combine the spacing system with MudBlazor's breakpoints to target specific screen sizes.
Adjust screen size to see the changes.
<MudPaper Class="pa-md-6 mx-lg-auto mud-theme-secondary"> <MudText Typo="Typo.body1">Adjust screen size to see the changes.</MudText> </MudPaper>
Centering Horizontal
Centered!
<MudPaper Class="mx-auto pa-6 mud-theme-success"> <MudText Typo="Typo.body1">Centered!</MudText> </MudPaper>
Negative Margins
This card uses negative top margin!
<MudPaper Class="mx-auto pa-4 mud-theme-secondary" Style="height:100px; width:150px;"> </MudPaper> <MudPaper Class="mt-n12 mx-auto pa-6 mud-theme-primary" Elevation="12" Style="width: 350px;"> <MudText Typo="Typo.body1">This card uses negative top margin!</MudText> </MudPaper>