Margin and padding
Assign responsive-friendly margin
or padding
values to an element or a subset of its sides with shorthand classes. Includes support for individual properties, all properties, and vertical and horizontal properties. Classes are built from a default Sass map ranging from .25rem
to 3rem
.
Using the CSS Grid layout module? Consider using the gap utility instead.
Notation
The classes are named using the format {property}-{sides}-{size}
.
Where property is one of:
m
- for classes that setmargin
p
- for classes that setpadding
Where sides is one of:
t
- for classes that setmargin-top
orpadding-top
b
- for classes that setmargin-bottom
orpadding-bottom
l
- for classes that setmargin-left
orpadding-left
in LTR,margin-right
orpadding-right
in RTLr
- for classes that setmargin-right
orpadding-right
in LTR,margin-left
orpadding-left
in RTLx
- for classes that set both*-left
and*-right
y
- for classes that set both*-top
and*-bottom
- blank - for classes that set a
margin
orpadding
on all 4 sides of the element
Where size is one of:
0
- for classes that eliminate themargin
orpadding
by setting it to0
5
- (by default) for classes that set themargin
orpadding
to5px
10
- (by default) for classes that set themargin
orpadding
to10px
15
- (by default) for classes that set themargin
orpadding
to15px
20
- (by default) for classes that set themargin
orpadding
to20px
25
- (by default) for classes that set themargin
orpadding
to25px
30
- (by default) for classes that set themargin
orpadding
to30px
auto
- for classes that set themargin
to auto
Examples
Here are some representative examples of these classes:
.m-t-0 {
margin-top: 0 !important;
}
.m-l-5 {
margin-left: 5px !important;
}
.p-x-10 {
padding-left: 10px !important;
padding-right: 10px !important;
}
.p-15 {
padding: 15px !important;
}
Horizontal centering
Additionally, WUI also includes an .m-auto
class for centering fixed-width block level content—that is, content that has display: block
and a width
set—by setting the margins to auto
.
<div class="m-auto p-10 wui-bg-color--active-20 border-1 wui-border-color--active" style="width: 200px;">
Centered element
</div>
Negative margin
In CSS, margin
properties can utilize negative values (padding
cannot).
The syntax is nearly the same as the default, positive margin utilities, but with the addition of a second -
after the property abbreviation. We only support -1px
and -5px
. Here's an example class that's the opposite of .m-t-5
:
.m-t--5 {
margin-top: -5px !important;
}
Typical use cases
Generally we work in a grid with 10px spacing. The arrangement of multiple elements often involves a combination with flex utils.
Scene header
Panel header
Modal footer
- …
<h4 class="m-b-30">Scene header</h4>
<div class="d-flex justify-content-end">
<wui-button variant="link">Cancel</wui-button>
<wui-button v-w-tooltip.hover title="Delete xyz" class="m-r-10" variant="default" :outline="true">
<i class="fa-solid fa-trash"></i>
</wui-button>
<wui-button variant="primary">Primary button</wui-button>
</div>
<hr class="m-y-20">
<h4 class="m-b-30">Panel header</h4>
<div class="d-flex justify-content-end">
<wui-button variant="primary" :outline="true" class="m-r-10">Secondary button</wui-button>
<wui-quick-pagination
:limit="1"
:total-rows="5"
:change="undefined"
:update:model-value="undefined"
/>
</div>
<hr class="m-y-20">
<h4 class="m-b-30">Modal footer</h4>
<div class="d-flex justify-content-between">
<ul class="wui-pagination-v2 wui-b-pagination m-b-0">
<li role="presentation" aria-hidden="true" class="wui-page__item wui-page__item--disabled">
<span role="menuitem" aria-label="Go to previous page" aria-disabled="true" class="wui-page__link">
<i aria-hidden="true" class="fa fa-chevron-left"></i></span></li>
<li role="presentation" class="wui-page__item">
<button role="menuitemradio" type="button" aria-label="Go to page 1" aria-checked="false" aria-posinset="1" aria-setsize="10" tabindex="0" class="wui-page__link">1</button>
</li>
<li role="presentation" class="wui-page__item">
<button role="menuitemradio" type="button" aria-label="Go to page 2" aria-checked="false" aria-posinset="2" aria-setsize="10" tabindex="-1" class="wui-page__link">2</button>
</li>
<li role="presentation" class="wui-page__item">
<button role="menuitemradio" type="button" aria-label="Go to page 3" aria-checked="false" aria-posinset="3" aria-setsize="10" tabindex="-1" class="wui-page__link">3</button>
</li>
<li role="presentation" class="wui-page__item wv-d-xs-down-none">
<button role="menuitemradio" type="button" aria-label="Go to page 4" aria-checked="false" aria-posinset="4" aria-setsize="10" tabindex="-1" class="wui-page__link">4</button>
</li>
<li role="separator" class="wui-page__item wui-page__item--disabled wv-d-xs-down-none">
<span class="wui-page__link">…</span></li>
<li role="presentation" aria-hidden="true" class="wui-page__item wui-page__item--disabled">
<span role="menuitem" aria-label="Go to next page" aria-disabled="true" class="wui-page__link">
<i aria-hidden="true" class="fa fa-chevron-right"></i>
</span>
</li>
</ul>
<div>
<button type="button" class="wui-btn wui-btn--link">Cancel</button>
<button type="button" class="wui-btn wui-btn--primary">Primary button</button>
</div>
</div>