| 1 |
--- |
| 2 |
id: Spacing |
| 3 |
section: foundations-and-styles |
| 4 |
subsection: utility-classes |
| 5 |
pf: 'test' |
| 6 |
---import './Spacing.css' |
| 7 |
|
| 8 |
## Examples |
| 9 |
|
| 10 |
<!-- {$pf} --> |
| 11 |
|
| 12 |
### Margin |
| 13 |
|
| 14 |
```html |
| 15 |
<h2 class="pf-v6-c-title pf-m-lg">Margin, marginX, marginY</h2> |
| 16 |
<div |
| 17 |
class="pf-v6-u-display-flex pf-v6-u-align-items-flex-start pf-v6-u-flex-wrap" |
| 18 |
> |
| 19 |
<div class="ws-example-flex-item pf-v6-u-m-xl">Margin - xl</div> |
| 20 |
<div class="ws-example-flex-item pf-v6-u-mx-xl">Margin x axis - pf-v6-u-mx-xl</div> |
| 21 |
<div class="ws-example-flex-item pf-v6-u-my-xl">Margin y axis - pf-v6-u-my-xl</div> |
| 22 |
</div> |
| 23 |
<br /> |
| 24 |
<h2 |
| 25 |
class="pf-v6-c-title pf-m-lg" |
| 26 |
>Margin top, margin right, margin bottom, margin left</h2> |
| 27 |
<div |
| 28 |
class="pf-v6-u-display-flex pf-v6-u-align-items-flex-start pf-v6-u-flex-wrap" |
| 29 |
> |
| 30 |
<div class="ws-example-flex-item pf-v6-u-mt-xl">Margin-top - xl</div> |
| 31 |
<div class="ws-example-flex-item pf-v6-u-mr-xl">Margin-right - xl</div> |
| 32 |
<div class="ws-example-flex-item pf-v6-u-mb-xl">Margin-bottom - xl</div> |
| 33 |
<div class="ws-example-flex-item pf-v6-u-ml-xl">Margin-left - xl</div> |
| 34 |
</div> |
| 35 |
<br /> |
| 36 |
<h2 class="pf-v6-c-title pf-m-lg">Responsive margin</h2> |
| 37 |
<div |
| 38 |
class="pf-v6-u-display-flex pf-v6-u-align-items-flex-start pf-v6-u-flex-column pf-v6-u-flex-wrap" |
| 39 |
> |
| 40 |
<div class="ws-example-flex-item pf-v6-u-mt-xl">Margin-top - xl</div> |
| 41 |
<div class="ws-example-flex-item pf-v6-u-mt-xl-on-sm">Margin-top - xl on-sm</div> |
| 42 |
<div class="ws-example-flex-item pf-v6-u-mt-xl-on-md">Margin-top - xl on-md</div> |
| 43 |
<div class="ws-example-flex-item pf-v6-u-mt-xl-on-lg">Margin-top - xl on-lg</div> |
| 44 |
<div class="ws-example-flex-item pf-v6-u-mt-xl-on-xl">Margin-top - xl on-xl</div> |
| 45 |
</div> |
| 46 |
|
| 47 |
``` |
| 48 |
|
| 49 |
### Padding |
| 50 |
|
| 51 |
```html |
| 52 |
<h2 class="pf-v6-c-title pf-m-lg">Padding, paddingX, paddingY</h2> |
| 53 |
<div |
| 54 |
class="pf-v6-u-display-flex pf-v6-u-align-items-flex-start pf-v6-u-flex-wrap" |
| 55 |
> |
| 56 |
<div class="ws-example-flex-item pf-v6-u-p-xl">Padding - xl</div> |
| 57 |
<div class="ws-example-flex-item pf-v6-u-px-xl">Padding x axis - pf-v6-u-px-xl</div> |
| 58 |
<div class="ws-example-flex-item pf-v6-u-py-xl">Padding y axis - pf-v6-u-py-xl</div> |
| 59 |
</div> |
| 60 |
<br /> |
| 61 |
<h2 |
| 62 |
class="pf-v6-c-title pf-m-lg" |
| 63 |
>Padding top, padding right, padding bottom, padding left</h2> |
| 64 |
<div |
| 65 |
class="pf-v6-u-display-flex pf-v6-u-align-items-flex-start pf-v6-u-flex-wrap" |
| 66 |
> |
| 67 |
<div class="ws-example-flex-item pf-v6-u-pt-xl">Padding-top - xl</div> |
| 68 |
<div class="ws-example-flex-item pf-v6-u-pr-xl">Padding-right - xl</div> |
| 69 |
<div class="ws-example-flex-item pf-v6-u-pb-xl">Padding-bottom - xl</div> |
| 70 |
<div class="ws-example-flex-item pf-v6-u-pl-xl">Padding-left - xl</div> |
| 71 |
</div> |
| 72 |
<br /> |
| 73 |
<h2 class="pf-v6-c-title pf-m-lg">Responsive padding</h2> |
| 74 |
<div |
| 75 |
class="pf-v6-u-display-flex pf-v6-u-align-items-flex-start pf-v6-u-flex-column pf-v6-u-flex-wrap" |
| 76 |
> |
| 77 |
<div class="ws-example-flex-item pf-v6-u-pt-xl">Padding-top</div> |
| 78 |
<div class="ws-example-flex-item pf-v6-u-pt-xl-on-sm">Padding-top - xl on-sm</div> |
| 79 |
<div class="ws-example-flex-item pf-v6-u-pt-xl-on-md">Padding-top - xl on-md</div> |
| 80 |
<div class="ws-example-flex-item pf-v6-u-pt-xl-on-lg">Padding-top - xl on-lg</div> |
| 81 |
<div class="ws-example-flex-item pf-v6-u-pt-xl-on-xl">Padding-top - xl on-xl</div> |
| 82 |
</div> |
| 83 |
|
| 84 |
``` |
| 85 |
|
| 86 |
### Combined |
| 87 |
|
| 88 |
```html |
| 89 |
<h2 class="pf-v6-c-title pf-m-lg">Combined spacers</h2> |
| 90 |
<div |
| 91 |
class="pf-v6-u-display-flex pf-v6-u-align-items-flex-start pf-v6-u-flex-wrap" |
| 92 |
> |
| 93 |
<div |
| 94 |
class="ws-example-flex-item pf-v6-u-p-lg pf-v6-u-m-lg" |
| 95 |
>Padding lg, margin lg</div> |
| 96 |
<div |
| 97 |
class="ws-example-flex-item pf-v6-u-p-lg-on-lg pf-v6-u-m-lg" |
| 98 |
>Padding lg on-lg, margin lg</div> |
| 99 |
</div> |
| 100 |
<br /> |
| 101 |
<h2 class="pf-v6-c-title pf-m-lg">Combined spacers (responsive)</h2> |
| 102 |
<div |
| 103 |
class="pf-v6-u-display-flex pf-v6-u-align-items-flex-start pf-v6-u-flex-wrap" |
| 104 |
> |
| 105 |
<div |
| 106 |
class="ws-example-flex-item pf-v6-u-p-sm pf-v6-u-p-lg-on-md pf-v6-u-mr-lg" |
| 107 |
>Item 1</div> |
| 108 |
<div |
| 109 |
class="ws-example-flex-item pf-v6-u-p-sm pf-v6-u-p-lg-on-md pf-v6-u-mr-lg" |
| 110 |
>Item 2</div> |
| 111 |
<div |
| 112 |
class="ws-example-flex-item pf-v6-u-p-sm pf-v6-u-p-lg-on-md pf-v6-u-ml-auto-on-xl" |
| 113 |
>Item 3</div> |
| 114 |
</div> |
| 115 |
|
| 116 |
``` |
| 117 |
|
| 118 |
## Documentation |
| 119 |
|
| 120 |
### Overview |
| 121 |
|
| 122 |
[Breakpoints](/foundations-and-styles/design-tokens/all-design-tokens) are optional. Breakpoint options include: base (no breakpoint value), `-on-sm`, `-on-md`, `-on-lg`, and `-on-xl`. Example: `.pf-v6-u-m-sm-on-lg` |
| 123 |
|
| 124 |
### Margin properties |
| 125 |
|
| 126 |
| Abbreviation | Property | |
| 127 |
| -- | -- | |
| 128 |
| `m` | margin | |
| 129 |
| `mt` | margin-top | |
| 130 |
| `mr` | margin-right | |
| 131 |
| `mb` | margin-bottom | |
| 132 |
| `ml` | margin-left | |
| 133 |
| `mx` | margin-left & margin-right | |
| 134 |
| `my` | margin-top & margin-bottom | |
| 135 |
|
| 136 |
### Padding properties |
| 137 |
|
| 138 |
| Abbreviation | Property | |
| 139 |
| -- | -- | |
| 140 |
| `p` | padding | |
| 141 |
| `pt` | padding-top | |
| 142 |
| `pr` | padding-right | |
| 143 |
| `pb` | padding-bottom | |
| 144 |
| `pl` | padding-left | |
| 145 |
| `px` | padding-left & padding-right | |
| 146 |
| `py` | padding-top & padding-bottom | |
| 147 |
|
| 148 |
### Size values |
| 149 |
|
| 150 |
| Abbreviation | Property | |
| 151 |
| -- | -- | |
| 152 |
| `auto` | auto | |
| 153 |
| `0` | 0 | |
| 154 |
| `xs` | var(--pf-v6-global--spacer--xs) | |
| 155 |
| `sm` | var(--pf-v6-global--spacer--sm) | |
| 156 |
| `md` | var(--pf-v6-global--spacer--md) | |
| 157 |
| `lg` | var(--pf-v6-global--spacer--lg) | |
| 158 |
| `xl` | var(--pf-v6-global--spacer--xl) | |
| 159 |
| `2xl` | var(--pf-v6-global--spacer--2xl) | |
| 160 |
| `3xl` | var(--pf-v6-global--spacer--3xl) | |
| 161 |
| `4xl` | var(--pf-v6-global--spacer--4xl) | |
| 162 |
|
| 163 |
### Usage |
| 164 |
|
| 165 |
| Class | Applied to | Outcome | |
| 166 |
| -- | -- | -- | |
| 167 |
| `.pf-v6-u-{m, mt, mr, mb, ml, mx, my}-{size}{-on-[breakpoint]}` | `*` | Sets margin top, right, bottom, left, margin-left & right, margin-top & bottom to spacer value | |
| 168 |
| `.pf-v6-u-{p, pt, pr, pb, pl, px, py}-{size}{-on-[breakpoint]}` | `*` | Sets padding top, right, bottom, left, padding-left & right, padding-top & bottom to spacer value | |