How it works
Use the margin or padding property and choose a direction. Then add size, ranging from 0 to 16.
The properties:
m- for classes that setmarginp- for classes that setpadding
The direction property applies to:
t- formargin-toporpadding-topb- formargin-bottomorpadding-bottoml- formargin-leftorpadding-leftr- formargin-rightorpadding-rights- 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-leftandmargin-right/padding-righty- formargin-top/padding-topandmargin-bottom/padding-bottoma- for all 4 sides.
Size
The size changes with an interval of 4 pixels.
Positive
0setsmarginorpaddingto01setsmarginorpaddingto4px2setsmarginorpaddingto8px3setsmarginorpaddingto12px4setsmarginorpaddingto16px5setsmarginorpaddingto20px6setsmarginorpaddingto24px7setsmarginorpaddingto28px8setsmarginorpaddingto32px9setsmarginorpaddingto36px10setsmarginorpaddingto40px11setsmarginorpaddingto44px12setsmarginorpaddingto48px13setsmarginorpaddingto52px14setsmarginorpaddingto56px15setsmarginorpaddingto60px16setsmarginorpaddingto64pxautosets the spacing toauto
Negative
n1setsmarginto-4pxn2setsmarginto-8pxn3setsmarginto-12pxn4setsmarginto-16pxn5setsmarginto-20pxn6setsmarginto-24pxn7setsmarginto-28pxn8setsmarginto-32pxn9setsmarginto-36pxn10setsmarginto-40pxn11setsmarginto-44pxn12setsmarginto-48pxn13setsmarginto-52pxn14setsmarginto-56pxn15setsmarginto-60pxn16setsmarginto-64px
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>