Utilities

Padding

Adjust whitespace by applying horizontal and vertical padding helpers.

About Padding#

The base unit of all of our spacing metrics is 4.

Before using

  • Most components already come with spacing included. These utility classes are for added convenience in laying out components.
  • Classes prefixed by slds-p- are used for adding padding. Classes prefixed in slds-m- are used for adding margin
  • The directions available for the spacing classes are top, right, bottom, and left.
  • You can use the vertical shortcut for both top and bottom, horizontal for both right and left, and around for all sides.
  • Use the _xxx-small through _xx-large scale to choose the size needed.
  • You can also use none as the size on any of the directions to enforce zero padding.
  • Where vertical centering is required, check out our centered media object instead of applying extra padding or margin.

Examples#

Location - Top#

<div class="slds-p-top_none"></div>
<div class="slds-p-top_xxx-small"></div>
<div class="slds-p-top_xx-small"></div>
<div class="slds-p-top_x-small"></div>
<div class="slds-p-top_small"></div>
<div class="slds-p-top_medium"></div>
<div class="slds-p-top_large"></div>
<div class="slds-p-top_x-large"></div>
<div class="slds-p-top_xx-large"></div>

Location - Left#

<div class="slds-p-left_none"></div>
<div class="slds-p-left_xxx-small"></div>
<div class="slds-p-left_xx-small"></div>
<div class="slds-p-left_x-small"></div>
<div class="slds-p-left_small"></div>
<div class="slds-p-left_medium"></div>
<div class="slds-p-left_large"></div>
<div class="slds-p-left_x-large"></div>
<div class="slds-p-left_xx-large"></div>

Location - Bottom#

<div class="slds-p-bottom_none"></div>
<div class="slds-p-bottom_xxx-small"></div>
<div class="slds-p-bottom_xx-small"></div>
<div class="slds-p-bottom_x-small"></div>
<div class="slds-p-bottom_small"></div>
<div class="slds-p-bottom_medium"></div>
<div class="slds-p-bottom_large"></div>
<div class="slds-p-bottom_x-large"></div>
<div class="slds-p-bottom_xx-large"></div>

Location - Right#

<div class="slds-p-right_none"></div>
<div class="slds-p-right_xxx-small"></div>
<div class="slds-p-right_xx-small"></div>
<div class="slds-p-right_x-small"></div>
<div class="slds-p-right_small"></div>
<div class="slds-p-right_medium"></div>
<div class="slds-p-right_large"></div>
<div class="slds-p-right_x-large"></div>
<div class="slds-p-right_xx-large"></div>

Location - Horizontal#

<div class="slds-p-horizontal_none"></div>
<div class="slds-p-horizontal_xxx-small"></div>
<div class="slds-p-horizontal_xx-small"></div>
<div class="slds-p-horizontal_x-small"></div>
<div class="slds-p-horizontal_small"></div>
<div class="slds-p-horizontal_medium"></div>
<div class="slds-p-horizontal_large"></div>
<div class="slds-p-horizontal_x-large"></div>
<div class="slds-p-horizontal_xx-large"></div>

Location - Vertical#

<div class="slds-p-vertical_none"></div>
<div class="slds-p-vertical_xxx-small"></div>
<div class="slds-p-vertical_xx-small"></div>
<div class="slds-p-vertical_x-small"></div>
<div class="slds-p-vertical_small"></div>
<div class="slds-p-vertical_medium"></div>
<div class="slds-p-vertical_large"></div>
<div class="slds-p-vertical_x-large"></div>
<div class="slds-p-vertical_xx-large"></div>

Location - Around#

<div class="slds-p-around_none"></div>
<div class="slds-p-around_xxx-small"></div>
<div class="slds-p-around_xx-small"></div>
<div class="slds-p-around_x-small"></div>
<div class="slds-p-around_small"></div>
<div class="slds-p-around_medium"></div>
<div class="slds-p-around_large"></div>
<div class="slds-p-around_x-large"></div>
<div class="slds-p-around_xx-large"></div>

Variable Density Classes#

In addition to the tokens we've created to support the new density settings, we have also created variable density classes for both padding and margin. The tables below show how the values change between the Comfy and Compact settings.

Around#

Class NameComfy ValueCompact Value
slds-var-p-around_xxx-small0.125rem0.125rem
slds-var-p-around_xx-small0.25rem0.125rem
slds-var-p-around_x-small0.5rem0.125rem
slds-var-p-around_small0.75rem0.25rem
slds-var-p-around_medium1rem0.5rem
slds-var-p-around_large1.5rem0.75rem
slds-var-p-around_x-large2rem1rem
slds-var-p-around_xx-large3rem1.5rem

Left, Right, Horizontal#

Class NameComfy ValueCompact Value
slds-var-p-*_xxx-small0.125rem0.125rem
slds-var-p-*_xx-small0.25rem0.125rem
slds-var-p-*_x-small0.5rem0.25rem
slds-var-p-*_small0.75rem0.5rem
slds-var-p-*_medium1rem0.75rem
slds-var-p-*_large1.5rem0.75rem
slds-var-p-*_x-large2rem1rem
slds-var-p-*_xx-large3rem1.5rem

Top, Bottom, Vertical#

Class NameComfy ValueCompact Value
slds-var-p-*_xxx-small0.125rem0.125rem
slds-var-p-*_xx-small0.25rem0.125rem
slds-var-p-*_x-small0.5rem0.25rem
slds-var-p-*_small0.75rem0.5rem
slds-var-p-*_medium1rem0.5rem
slds-var-p-*_large1.5rem0.75rem
slds-var-p-*_x-large2rem1rem
slds-var-p-*_xx-large3rem1.5rem

Overview of CSS Classes#

Selector.slds-p-*_xxx-small, .slds-var-p-*_xxx-small
Summary

Adds .125rem padding to the side specified

Restrict*
ModifierTrue
Selector.slds-p-*_xx-small, .slds-var-p-*_xx-small
Summary

Adds .25rem padding to the side specified

Restrict*
ModifierTrue
Selector.slds-p-*_x-small, .slds-var-p-*_x-small
Summary

Adds .5rem padding to the side specified

Restrict*
ModifierTrue
Selector.slds-p-*_small, .slds-var-p-*_small
Summary

Adds .75rem padding to the side specified

Restrict*
ModifierTrue
Selector.slds-p-*_medium, .slds-var-p-*_medium
Summary

Adds 1rem padding to the side specified

Restrict*
ModifierTrue
Selector.slds-p-*_large, .slds-var-p-*_large
Summary

Adds 1.5rem padding to the side specified

Restrict*
ModifierTrue
Selector.slds-p-*_x-large, .slds-var-p-*_x-large
Summary

Adds 2rem padding to the side specified

Restrict*
ModifierTrue
Selector.slds-p-*_xx-large, .slds-var-p-*_xx-large
Summary

Adds 3rem padding to the side specified

Restrict*
ModifierTrue
Selector.slds-p-*-vertical_*, .slds-var-p-*-vertical_*
Summary

Adds the specified padding to both top and bottom

Restrict*
ModifierTrue
Selector.slds-p-*-horizontal_*, .slds-var-p-*-horizontal_*
Summary

Adds the specified padding to both sides

Restrict*
ModifierTrue
Selector.slds-p-*-around_*, .slds-var-p-*-around_*
Summary

Adds the specified padding all the way around the element

Restrict*
ModifierTrue

Padding Utility Release Notes

2.8.0

Added

  • Added documentation detailing the values of the variable density classes in Comfy and Compact modes