Utilities

Shoelace provides a number of helpful utility classes that make prototyping easier.

Text Utilities

Text utility classes can be applied to change an element’s text.

Class Example
text-primary This is primary text
text-secondary This is secondary text
text-success This is success text
text-info This is info text
text-warning This is warning text
text-danger This is danger text
text-light This is light text
text-dark This is dark text
text-small This is small text
text-bold This is bold text
text-italic This is italic text
text-left This is left-aligned text
text-center This is centered text
text-right This is right-aligned text
text-justify This is justified text
text-nowrap This is text that won’t wrap
text-lowercase This is lowercase text
text-uppercase This is uppercase text
text-capitalize This is capitalized text

Background Utilities

Background utility classes can be applied to change an element’s background color.

<div class="bg-primary">Primary</div>
<div class="bg-secondary">Secondary</div>
<div class="bg-success">Success</div>
<div class="bg-info">Info</div>
<div class="bg-warning">Warning</div>
<div class="bg-danger">Danger</div>
<div class="bg-light">Light</div>
<div class="bg-dark">Dark</div>
Primary
Secondary
Success
Info
Warning
Danger
Light
Dark

Float Utilities

Float utilities are provided to easily float elements to the left or right. Just apply the float-left or float-right class to an element to float it left or right.

A clearfix utility is also available to clear floated elements. Just apply the clearfix class to the appropriate element.

Sizing Utilities

Sizing utilities can be used to set a relative width or height on any element. Just apply a w-* or h-* class and the appropriate element will be sized accordingly. Sizes are available as percentages from 0 – 100 in multiples of five.

You can also use the w-max-100 and h-max-100 classes to set a max width and height of 100%.

<div class="w-25">25%</div>
<div class="w-50">50%</div>
<div class="w-75">75%</div>
<div class="w-100">100%</div>

<div class="h-25">25%</div>
<div class="h-50">50%</div>
<div class="h-75">75%</div>
<div class="h-100">100%</div>
25%
50%
75%
100%
25%
50%
75%
100%

Spacing Utilities

Spacing utilities can be used to add or remove paddings and margins to any element. Just apply the desired class and the appropriate element will receive the respective padding/margin.

Class names are prefixed with pad- or mar- for padding and margin, respectively. To apply spacing to all sides of an element, use the following classes.

pad-[0|xs|sm|md|lg|xl]
mar-[0|xs|sm|md|lg|xl]

Example:

<div class="pad-0 mar-xl">

To apply spacing to a specific side of an element, use one or more of the following classes.

pad-[t|r|b|l|x|y]-[0|xs|sm|md|lg|xl]
mar-[t|r|b|l|x|y]-[0|xs|sm|md|lg|xl]

Example:

<div class="pad-l-md mar-b-0">

You can also use mar-[x|y|xy]-auto to set automatic margins horizontally and/or vertically.