Spacing scale

The cloud.gov spacing scale is based on a base grid of 8px. Use even multiples of this base grid when setting the height, width, padding, and margin of blocks and components. When possible, any spacing value should be a multiple of this base grid.

Sass variables

Our spacing grid sass variables provide an easy way to access grid multiples. The variable outputs the final value in terms of rem but these are meant to directly correspond to a pixel multiplier.

$grid-05:            0.5 * base     4px
$grid-1:             1 * base       8px
$grid-105:           1.5 * base     12px
$grid-2:             2 * base       16px
$grid-3:             3 * base       24px
$grid-4:             4 * base       32px
$grid-5:             5 * base       40px
$grid-6:             6 * base       48px
$grid-7:             7 * base       56px
$grid-8:             8 * base       64px
$grid-9:             9 * base       72px
$grid-10:            10 * base       80px

Utility classes

There are basic utility classes for a subset of spacing classing. We can use utility classes to add positive spacing multiples to height, width, margin, and padding.

The class constructor pattern is:

[rule][variation]-[multiplier]

with the following rule codes:

w: width
h: height
p: padding
m: margin

and these variation codes for padding and margin:

[none]: all sides
h:      horizontal (left and right)
v:      vertical (top and bottom)
t:      top
r:      right
b:      bottom
l:      left

and the same multiplier codes from the grid variables:

05:        0.5x     4px
1:         1x       8px
105:       1.5x     12px
2:         2x       16px
3:         3x       24px
4:         4x       32px
5:         5x       40px
6:         6x       48px
7:         7x       56px
8:         8x       64px
9:         9x       72px
10:        10x      80px

Examples:

  • a full margin of 64px: m8
  • 8px padding on top and bottom: py1
  • height of 48px: h6
<!-- Default -->
<div class="pattern float-left mx1 mb4">
    <div class="pattern-example sq10 row row-center-x">
        <div class="col sq05 bg-blue"></div>
    </div>
    <div class="h10 pt2">
        <div class="pattern-title sans-s5 fw700">4px</div>
        <div class="pattern-vars sans-s2 fw700">$grid-05</div>
        <div class="pattern-code mono-s3 fw300">.sq05</div>
    </div>
</div>

<!-- Grid 1 -->
<div class="pattern float-left mx1 mb4">
    <div class="pattern-example sq10 row row-center-x">
        <div class="col sq1 bg-blue"></div>
    </div>
    <div class="h10 pt2">
        <div class="pattern-title sans-s5 fw700">8px</div>
        <div class="pattern-vars sans-s2 fw700">$grid-1</div>
        <div class="pattern-code mono-s3 fw300">.sq1</div>
    </div>
</div>

<!-- Grid 105 -->
<div class="pattern float-left mx1 mb4">
    <div class="pattern-example sq10 row row-center-x">
        <div class="col sq105 bg-blue"></div>
    </div>
    <div class="h10 pt2">
        <div class="pattern-title sans-s5 fw700">12px</div>
        <div class="pattern-vars sans-s2 fw700">$grid-105</div>
        <div class="pattern-code mono-s3 fw300">.sq105</div>
    </div>
</div>

<!-- Grid 2 -->
<div class="pattern float-left mx1 mb4">
    <div class="pattern-example sq10 row row-center-x">
        <div class="col sq2 bg-blue"></div>
    </div>
    <div class="h10 pt2">
        <div class="pattern-title sans-s5 fw700">16px</div>
        <div class="pattern-vars sans-s2 fw700">$grid-2</div>
        <div class="pattern-code mono-s3 fw300">.sq2</div>
    </div>
</div>

<!-- Grid 3 -->
<div class="pattern float-left mx1 mb4">
    <div class="pattern-example sq10 row row-center-x">
        <div class="col sq3 bg-blue"></div>
    </div>
    <div class="h10 pt2">
        <div class="pattern-title sans-s5 fw700">24px</div>
        <div class="pattern-vars sans-s2 fw700">$grid-3</div>
        <div class="pattern-code mono-s3 fw300">.sq3</div>
    </div>
</div>

<!-- Grid 4 -->
<div class="pattern float-left mx1 mb4">
    <div class="pattern-example sq10 row row-center-x">
        <div class="col sq4 bg-blue"></div>
    </div>
    <div class="h10 pt2">
        <div class="pattern-title sans-s5 fw700">32px</div>
        <div class="pattern-vars sans-s2 fw700">$grid-4</div>
        <div class="pattern-code mono-s3 fw300">.sq4</div>
    </div>
</div>

<!-- Grid 5 -->
<div class="pattern float-left mx1 mb4">
    <div class="pattern-example sq10 row row-center-x">
        <div class="col sq5 bg-blue"></div>
    </div>
    <div class="h10 pt2">
        <div class="pattern-title sans-s5 fw700">40px</div>
        <div class="pattern-vars sans-s2 fw700">$grid-5</div>
        <div class="pattern-code mono-s3 fw300">.sq5</div>
    </div>
</div>

<!-- Grid 6 -->
<div class="pattern float-left mx1 mb4">
    <div class="pattern-example sq10 row row-center-x">
        <div class="col sq6 bg-blue"></div>
    </div>
    <div class="h10 pt2">
        <div class="pattern-title sans-s5 fw700">48px</div>
        <div class="pattern-vars sans-s2 fw700">$grid-6</div>
        <div class="pattern-code mono-s3 fw300">.sq6</div>
    </div>
</div>

<!-- Grid 7 -->
<div class="pattern float-left mx1 mb4">
    <div class="pattern-example sq10 row row-center-x">
        <div class="col sq7 bg-blue"></div>
    </div>
    <div class="h10 pt2">
        <div class="pattern-title sans-s5 fw700">56px</div>
        <div class="pattern-vars sans-s2 fw700">$grid-7</div>
        <div class="pattern-code mono-s3 fw300">.sq7</div>
    </div>
</div>

<!-- Grid 8 -->
<div class="pattern float-left mx1 mb4">
    <div class="pattern-example sq10 row row-center-x">
        <div class="col sq8 bg-blue"></div>
    </div>
    <div class="h10 pt2">
        <div class="pattern-title sans-s5 fw700">64px</div>
        <div class="pattern-vars sans-s2 fw700">$grid-8</div>
        <div class="pattern-code mono-s3 fw300">.sq8</div>
    </div>
</div>

<!-- Grid 9 -->
<div class="pattern float-left mx1 mb4">
    <div class="pattern-example sq10 row row-center-x">
        <div class="col sq9 bg-blue"></div>
    </div>
    <div class="h10 pt2">
        <div class="pattern-title sans-s5 fw700">72px</div>
        <div class="pattern-vars sans-s2 fw700">$grid-9</div>
        <div class="pattern-code mono-s3 fw300">.sq9</div>
    </div>
</div>

<!-- Grid 10 -->
<div class="pattern float-left mx1 mb4">
    <div class="pattern-example sq10 row row-center-x">
        <div class="col sq10 bg-blue"></div>
    </div>
    <div class="h10 pt2">
        <div class="pattern-title sans-s5 fw700">80px</div>
        <div class="pattern-vars sans-s2 fw700">$grid-10</div>
        <div class="pattern-code mono-s3 fw300">.sq10</div>
    </div>
</div>

<!-- Large Values -->
<h2 class="sans-st fw300 lh-hed textblack pt5 mb2 clear">Large values</h2>
<p class="sans-s6 fw700 lh-cap textblack mb4">
    These large values are typically used only for fixed height or width.
</p>

<div class="mb4 clear">
    <div class="h3 w15 bg-blue"></div>
    <div class="h10 pt2">
        <div class="pattern-title sans-s5 fw700">120px</div>
        <div class="pattern-vars sans-s2 fw700">$grid-15</div>
        <div class="pattern-code mono-s3 fw300">.w15</div>
    </div>
</div>

<div class="mb4 clear">
    <div class="h3 w20 bg-blue"></div>
    <div class="h10 pt2">
        <div class="pattern-title sans-s5 fw700">160px</div>
        <div class="pattern-vars sans-s2 fw700">$grid-20</div>
        <div class="pattern-code mono-s3 fw300">.w20</div>
    </div>
</div>

<div class="mb4 clear">
    <div class="h3 w25 bg-blue"></div>
    <div class="h10 pt2">
        <div class="pattern-title sans-s5 fw700">200px</div>
        <div class="pattern-vars sans-s2 fw700">$grid-25</div>
        <div class="pattern-code mono-s3 fw300">.w25</div>
    </div>
</div>

<div class="mb4 clear">
    <div class="h3 w30 bg-blue"></div>
    <div class="h10 pt2">
        <div class="pattern-title sans-s5 fw700">240px</div>
        <div class="pattern-vars sans-s2 fw700">$grid-30</div>
        <div class="pattern-code mono-s3 fw300">.w30</div>
    </div>
</div>

<div class="mb4 clear">
    <div class="h3 w40 bg-blue"></div>
    <div class="h10 pt2">
        <div class="pattern-title sans-s5 fw700">320px</div>
        <div class="pattern-vars sans-s2 fw700">$grid-40</div>
        <div class="pattern-code mono-s3 fw300">.w40</div>
    </div>
</div>

<div class="mb4 clear">
    <div class="h3 w50 bg-blue"></div>
    <div class="h10 pt2">
        <div class="pattern-title sans-s5 fw700">400px</div>
        <div class="pattern-vars sans-s2 fw700">$grid-50</div>
        <div class="pattern-code mono-s3 fw300">.w50</div>
    </div>
</div>

<!-- Default -->
<div class="pattern float-left mx1 mb4">
  <div class="pattern-example sq10 row row-center-x">
    <div class="col sq{{ patternMultiplier }} bg-blue"></div>
  </div>
  <div class="h10 pt2">
    <div class="pattern-title sans-s5 fw700">{{ patternValue }}</div>
    <div class="pattern-vars sans-s2 fw700">$grid-{{ patternMultiplier }}</div>
    <div class="pattern-code mono-s3 fw300">.sq{{ patternMultiplier }}</div>
  </div>
</div>

<!-- Grid 1 -->
<div class="pattern float-left mx1 mb4">
  <div class="pattern-example sq10 row row-center-x">
    <div class="col sq{{ patternMultiplier }} bg-blue"></div>
  </div>
  <div class="h10 pt2">
    <div class="pattern-title sans-s5 fw700">{{ patternValue }}</div>
    <div class="pattern-vars sans-s2 fw700">$grid-{{ patternMultiplier }}</div>
    <div class="pattern-code mono-s3 fw300">.sq{{ patternMultiplier }}</div>
  </div>
</div>

<!-- Grid 105 -->
<div class="pattern float-left mx1 mb4">
  <div class="pattern-example sq10 row row-center-x">
    <div class="col sq{{ patternMultiplier }} bg-blue"></div>
  </div>
  <div class="h10 pt2">
    <div class="pattern-title sans-s5 fw700">{{ patternValue }}</div>
    <div class="pattern-vars sans-s2 fw700">$grid-{{ patternMultiplier }}</div>
    <div class="pattern-code mono-s3 fw300">.sq{{ patternMultiplier }}</div>
  </div>
</div>

<!-- Grid 2 -->
<div class="pattern float-left mx1 mb4">
  <div class="pattern-example sq10 row row-center-x">
    <div class="col sq{{ patternMultiplier }} bg-blue"></div>
  </div>
  <div class="h10 pt2">
    <div class="pattern-title sans-s5 fw700">{{ patternValue }}</div>
    <div class="pattern-vars sans-s2 fw700">$grid-{{ patternMultiplier }}</div>
    <div class="pattern-code mono-s3 fw300">.sq{{ patternMultiplier }}</div>
  </div>
</div>

<!-- Grid 3 -->
<div class="pattern float-left mx1 mb4">
  <div class="pattern-example sq10 row row-center-x">
    <div class="col sq{{ patternMultiplier }} bg-blue"></div>
  </div>
  <div class="h10 pt2">
    <div class="pattern-title sans-s5 fw700">{{ patternValue }}</div>
    <div class="pattern-vars sans-s2 fw700">$grid-{{ patternMultiplier }}</div>
    <div class="pattern-code mono-s3 fw300">.sq{{ patternMultiplier }}</div>
  </div>
</div>

<!-- Grid 4 -->
<div class="pattern float-left mx1 mb4">
  <div class="pattern-example sq10 row row-center-x">
    <div class="col sq{{ patternMultiplier }} bg-blue"></div>
  </div>
  <div class="h10 pt2">
    <div class="pattern-title sans-s5 fw700">{{ patternValue }}</div>
    <div class="pattern-vars sans-s2 fw700">$grid-{{ patternMultiplier }}</div>
    <div class="pattern-code mono-s3 fw300">.sq{{ patternMultiplier }}</div>
  </div>
</div>

<!-- Grid 5 -->
<div class="pattern float-left mx1 mb4">
  <div class="pattern-example sq10 row row-center-x">
    <div class="col sq{{ patternMultiplier }} bg-blue"></div>
  </div>
  <div class="h10 pt2">
    <div class="pattern-title sans-s5 fw700">{{ patternValue }}</div>
    <div class="pattern-vars sans-s2 fw700">$grid-{{ patternMultiplier }}</div>
    <div class="pattern-code mono-s3 fw300">.sq{{ patternMultiplier }}</div>
  </div>
</div>

<!-- Grid 6 -->
<div class="pattern float-left mx1 mb4">
  <div class="pattern-example sq10 row row-center-x">
    <div class="col sq{{ patternMultiplier }} bg-blue"></div>
  </div>
  <div class="h10 pt2">
    <div class="pattern-title sans-s5 fw700">{{ patternValue }}</div>
    <div class="pattern-vars sans-s2 fw700">$grid-{{ patternMultiplier }}</div>
    <div class="pattern-code mono-s3 fw300">.sq{{ patternMultiplier }}</div>
  </div>
</div>

<!-- Grid 7 -->
<div class="pattern float-left mx1 mb4">
  <div class="pattern-example sq10 row row-center-x">
    <div class="col sq{{ patternMultiplier }} bg-blue"></div>
  </div>
  <div class="h10 pt2">
    <div class="pattern-title sans-s5 fw700">{{ patternValue }}</div>
    <div class="pattern-vars sans-s2 fw700">$grid-{{ patternMultiplier }}</div>
    <div class="pattern-code mono-s3 fw300">.sq{{ patternMultiplier }}</div>
  </div>
</div>

<!-- Grid 8 -->
<div class="pattern float-left mx1 mb4">
  <div class="pattern-example sq10 row row-center-x">
    <div class="col sq{{ patternMultiplier }} bg-blue"></div>
  </div>
  <div class="h10 pt2">
    <div class="pattern-title sans-s5 fw700">{{ patternValue }}</div>
    <div class="pattern-vars sans-s2 fw700">$grid-{{ patternMultiplier }}</div>
    <div class="pattern-code mono-s3 fw300">.sq{{ patternMultiplier }}</div>
  </div>
</div>

<!-- Grid 9 -->
<div class="pattern float-left mx1 mb4">
  <div class="pattern-example sq10 row row-center-x">
    <div class="col sq{{ patternMultiplier }} bg-blue"></div>
  </div>
  <div class="h10 pt2">
    <div class="pattern-title sans-s5 fw700">{{ patternValue }}</div>
    <div class="pattern-vars sans-s2 fw700">$grid-{{ patternMultiplier }}</div>
    <div class="pattern-code mono-s3 fw300">.sq{{ patternMultiplier }}</div>
  </div>
</div>

<!-- Grid 10 -->
<div class="pattern float-left mx1 mb4">
  <div class="pattern-example sq10 row row-center-x">
    <div class="col sq{{ patternMultiplier }} bg-blue"></div>
  </div>
  <div class="h10 pt2">
    <div class="pattern-title sans-s5 fw700">{{ patternValue }}</div>
    <div class="pattern-vars sans-s2 fw700">$grid-{{ patternMultiplier }}</div>
    <div class="pattern-code mono-s3 fw300">.sq{{ patternMultiplier }}</div>
  </div>
</div>

<!-- Large Values -->
<h2 class="sans-st fw300 lh-hed textblack pt5 mb2 clear">Large values</h2>
<p class="sans-s6 fw700 lh-cap textblack mb4">
  These large values are typically used only for fixed height or width.
</p>

<div class="mb4 clear">
  <div class="h3 w15 bg-blue"></div>
  <div class="h10 pt2">
    <div class="pattern-title sans-s5 fw700">120px</div>
    <div class="pattern-vars sans-s2 fw700">$grid-15</div>
    <div class="pattern-code mono-s3 fw300">.w15</div>
  </div>
</div>

<div class="mb4 clear">
  <div class="h3 w20 bg-blue"></div>
  <div class="h10 pt2">
    <div class="pattern-title sans-s5 fw700">160px</div>
    <div class="pattern-vars sans-s2 fw700">$grid-20</div>
    <div class="pattern-code mono-s3 fw300">.w20</div>
  </div>
</div>

<div class="mb4 clear">
  <div class="h3 w25 bg-blue"></div>
  <div class="h10 pt2">
    <div class="pattern-title sans-s5 fw700">200px</div>
    <div class="pattern-vars sans-s2 fw700">$grid-25</div>
    <div class="pattern-code mono-s3 fw300">.w25</div>
  </div>
</div>

<div class="mb4 clear">
  <div class="h3 w30 bg-blue"></div>
  <div class="h10 pt2">
    <div class="pattern-title sans-s5 fw700">240px</div>
    <div class="pattern-vars sans-s2 fw700">$grid-30</div>
    <div class="pattern-code mono-s3 fw300">.w30</div>
  </div>
</div>

<div class="mb4 clear">
  <div class="h3 w40 bg-blue"></div>
  <div class="h10 pt2">
    <div class="pattern-title sans-s5 fw700">320px</div>
    <div class="pattern-vars sans-s2 fw700">$grid-40</div>
    <div class="pattern-code mono-s3 fw300">.w40</div>
  </div>
</div>

<div class="mb4 clear">
  <div class="h3 w50 bg-blue"></div>
  <div class="h10 pt2">
    <div class="pattern-title sans-s5 fw700">400px</div>
    <div class="pattern-vars sans-s2 fw700">$grid-50</div>
    <div class="pattern-code mono-s3 fw300">.w50</div>
  </div>
</div>
/* Default */
{
  "patternMultiplier": "05",
  "patternValue": "4px"
}

/* Grid 1 */
{
  "patternMultiplier": 1,
  "patternValue": "8px"
}

/* Grid 105 */
{
  "patternMultiplier": 105,
  "patternValue": "12px"
}

/* Grid 2 */
{
  "patternMultiplier": 2,
  "patternValue": "16px"
}

/* Grid 3 */
{
  "patternMultiplier": 3,
  "patternValue": "24px"
}

/* Grid 4 */
{
  "patternMultiplier": 4,
  "patternValue": "32px"
}

/* Grid 5 */
{
  "patternMultiplier": 5,
  "patternValue": "40px"
}

/* Grid 6 */
{
  "patternMultiplier": 6,
  "patternValue": "48px"
}

/* Grid 7 */
{
  "patternMultiplier": 7,
  "patternValue": "56px"
}

/* Grid 8 */
{
  "patternMultiplier": 8,
  "patternValue": "64px"
}

/* Grid 9 */
{
  "patternMultiplier": 9,
  "patternValue": "72px"
}

/* Grid 10 */
{
  "patternMultiplier": 10,
  "patternValue": "80px"
}

/* Large Values */
{
  "patternMultiplier": "05",
  "patternValue": "4px"
}