This version of Clarity is no longer supported. We recommend that you update to the latest version of Clarity.
A grid provides a structure of rows and columns for aligning content. Grids are useful because they help create a familiar and easily navigable structure for content.

Clarity uses the Bootstrap 4 Flex Grid. This is a 12-column, responsive grid, per the Bootstrap documentation shown below:

Extra Small Small Medium Large Extra Large
Grid behavior Horizontal Collapsed to start, horizontal above breakpoints
Container width <544px ≥544px ≥768px ≥992px ≥1200px
Class prefix .col-xs- .col-sm- .col-md- .col-lg- .col-xl-
Number of columns 12
Gutter width 24px (12px on the left and right of column)
Nestable Yes
Offsets Yes
Column order Yes

Grid Behavior
Horizontal for extra-small (xs). All other breakpoints are collapsed to start, then horizontal above the breakpoint.

Common Properties

  • Number of columns: 12
  • Gutter width: 24px (12px on the left and right of column)
  • All columns support nesting, offsets, and column order
Extra small
< 544px
.col-xs-
Small
≥ 544px
.col-sm-
Medium
≥ 768px
.col-md-
Large
≥ 992px
.col-lg-
Extra large
≥ 1200px
.col-xl-

Rows

A .row is a horizontal group of 12 columns. When the number of columns exceeds 12, the extra columns wrap to the next line.

Columns

The column classes specify the number of columns per row.  The value appended to the class prefix must be between 1 and 12.

4
6
2
<div class="row">
    <div class="col-xs-4">
        <span>4</span>
    </div>
    <div class="col-xs-6">
        <span>6</span>
    </div>
    <div class="col-xs-2">
        <span>2</span>
    </div>
</div>
1
11
2
10
3
9
4
8
5
7
6
6
12

Column Stacking

Grid columns can occupy different widths on different device sizes.

In the example below, if the device size is ≥ 768px (medium or above), the grid has two columns of equal width and a third column that occupies the entire width of the row.  For device sizes < 768px, each column occupies the entire width of the row and the columns are stacked. Resize your browser to see how this works.

.col-sm-12 .col-md-6
.col-sm-12 .col-md-6
.col-sm-12 .col-md-12
<div class="row">
    <div class="col-sm-12 col-md-6">
        <span>.col-sm-12 .col-md-6</span>
    </div>
    <div class="col-sm-12 col-md-6">
        <span>.col-sm-12 .col-md-6</span>
    </div>
    <div class="col-sm-12 col-md-12">
        <span>.col-sm-12 .col-md-12</span>
    </div>
</div>

Column Offsets

The <class-prefix>-offset-* classes increase a column’s left margin by the width occupied by * number of columns.

.col-sm-4
.col-sm-6.offset-sm-2
<div class="row">
    <div class="col-sm-4">
        <span>.col-sm-4</span>
    </div>
    <div class="col-sm-6 offset-sm-2">
        <span>.col-sm-6.offset-sm-2</span>
    </div>
</div>

Column Ordering

The push and pull modifiers change the order of columns.

Push

.col-md-4.push-md-8
.col-md-2
<div class="row">
    <div class="col-md-4 push-md-8">
        <span>.col-md-4.push-md-8</span>
    </div>
    <div class="col-md-2">
        <span>.col-md-2</span>
    </div>
</div>

Pull

.col-xs-4 .offset-xs-5
.col-xs-3.pull-xs-9
<div class="row">
    <div class="col-xs-4 offset-xs-5">
        <span>.col-xs-4.offset-xs-5</span>
    </div>
    <div class="col-xs-3 pull-xs-9">
        <span>.col-xs-3.pull-xs-9</span>
    </div>
</div>

Flexbox Grid Auto Layout

Using the .col-<breakpoint> class divides the row into equal width columns.

1/5
1/5
1/5
1/5
1/5
1/3
1/3
1/3
<div class="row">
    <div class="col-xs">
        <span>1/5</span>
    </div>
    <div class="col-xs">
        <span>1/5</span>
    </div>
    <div class="col-xs">
        <span>1/5</span>
    </div>
    <div class="col-xs">
        <span>1/5</span>
    </div>
    <div class="col-xs">
        <span>1/5</span>
    </div>
</div>
<div class="row">
    <div class="col-xs">
        <span>1/3</span>
    </div>
    <div class="col-xs">
        <span>1/3</span>
    </div>
    <div class="col-xs">
        <span>1/3</span>
    </div>
</div>
4
Remaining
<div class="row">
    <div class="col-xs-4">
        <span>4</span>
    </div>
    <div class="col-xs">
        <span>Remaining</span>
    </div>
</div>
1/4
1/2
1/4
<div class="row">
    <div class="col-xs">
        <span>1/4</span>
    </div>
    <div class="col-xs-6">
        <span>1/2</span>
    </div>
    <div class="col-xs">
        <span>1/4</span>
    </div>
</div>

Vertical Alignment in Rows

Columns within a row can be vertically aligned using the following classes:

  • flex-items-xs-top
  • flex-items-xs-middle
  • flex-items-xs-bottom
Top
1/2
1/2
<div class="row flex-items-xs-top">
    <div class="col-xs">
        <span>1/2</span>
    </div>
    <div class="col-xs">
        <span>1/2</span>
    </div>
</div>
Middle
1/2
1/2
<div class="row flex-items-xs-middle">
    <div class="col-xs">
        <span>1/2</span>
    </div>
    <div class="col-xs">
        <span>1/2</span>
    </div>
</div>
Bottom
1/2
1/2
<div class="row flex-items-xs-bottom">
    <div class="col-xs">
        <span>1/2</span>
    </div>
    <div class="col-xs">
        <span>1/2</span>
    </div>
</div>

A column can individually be vertically aligned in a row using the following classes:

  • flex-xs-top
  • flex-xs-middle
  • flex-xs-bottom
1/3
1/3
1/3
<div class="row">
    <div class="col-xs flex-xs-top">
        <span>1/3</span>
    </div>
    <div class="col-xs flex-xs-middle">
        <span>1/3</span>
    </div>
    <div class="col-xs flex-xs-bottom">
        <span>1/3</span>
    </div>
</div>

Horizontal Alignment in Rows

To align columns horizontally within a row, extend the row with one of the following classes:

  • flex-items-xs-left
  • flex-items-xs-center
  • flex-items-xs-right
  • flex-items-xs-around
  • flex-items-xs-between
Left
.col-xs-4
.col-xs-4
<div class="row flex-items-xs-left">
    <div class="col-xs-4">
        <span class="clr-example-col-value">
            .col-xs-4
        </span>
    </div>
    <div class="col-xs-4">
        <span class="clr-example-col-value">
            .col-xs-4
        </span>
    </div>
</div>
Center
.col-xs-4
.col-xs-4
<div class="row flex-items-xs-center">
    <div class="col-xs-4">
        <span class="clr-example-col-value">
            .col-xs-4
        </span>
    </div>
    <div class="col-xs-4">
        <span class="clr-example-col-value">
            .col-xs-4
        </span>
    </div>
</div>
Right
.col-xs-4
.col-xs-4
<div class="row flex-items-xs-right">
    <div class="col-xs-4">
        <span class="clr-example-col-value">
            .col-xs-4
        </span>
    </div>
    <div class="col-xs-4">
        <span class="clr-example-col-value">
            .col-xs-4
        </span>
    </div>
</div>
Space Around
.col-xs-4
.col-xs-4
<div class="row flex-items-xs-around">
    <div class="col-xs-4">
        <span class="clr-example-col-value">
            .col-xs-4
        </span>
    </div>
    <div class="col-xs-4">
        <span class="clr-example-col-value">
            .col-xs-4
        </span>
    </div>
</div>
Space Between
.col-xs-4
.col-xs-4
<div class="row flex-items-xs-between">
    <div class="col-xs-4">
        <span class="clr-example-col-value">
            .col-xs-4
        </span>
    </div>
    <div class="col-xs-4">
        <span class="clr-example-col-value">
            .col-xs-4
        </span>
    </div>
</div>

Usage

Clarity recommends that your application layout stay on the grid. A grid-based approach:

  • Aligns content consistently
  • Establishes a foundation that can be easily built upon for future designs
  • Simplifies layout decisions required of a designer
  • Coordinates the efforts of multiple designers

Applying the Grid

Apply the grid with consideration of content. Some pages might benefit from a three-column layout, where other pages might work best with a two-column layout.

You can vary the column layout within the same page. This strategy works well for presenting content that scrolls vertically.

Don’t lock your design into a layout optimized for a large window.

Grids and Card Layouts

Designing to a grid is especially important for card layouts. Cards contains blocks of content and their height and width can vary. The grid aligns the cards in a way that is easy for users to navigate.

If You Decide Not to Conform to the Grid

Do so with intent. Find a balance between aesthetics and conformity. Keep in mind that elements that are not aligned to the grid draw attention in the same way as color, contrast, and iconography and require more cognitive effort on the part of the user.