Spacing refers to the negative areas between elements and components. In code, it is controlled using margins and padding. Shell DS provides guidance so that incorporating spacing in design is simple and consistent.
The Shell DS spacing scale aligns with the 4x grid and uses increments of four (eight, twelve, sixteen and so on). Each level of the scale has its own token that can be used for building within components as well as for layout spacing between components.
| Token | px | Example |
|---|---|---|
$spacing-01 | 4 | |
$spacing-02 | 8 | |
$spacing-03 | 12 | |
$spacing-04 | 16 | |
$spacing-05 | 20 | |
$spacing-06 | 24 | 24 |
$spacing-07 | 32 | 32 |
$spacing-08 | 40 | 40 |
$spacing-09 | 48 | 48 |
$spacing-10 | 64 | 64 |
$spacing-11 | 80 | 80 |
$spacing-12 | 96 | 96 |
$spacing-13 | 128 | 128 |
$spacing-14 | 160 | 160 |
Do use a 4px unit base (4, 8, 12, 16).
Don’t use another base system.
The spacing token replaces the values usually given to margin and padding. In the example shown below, spacing is used to create a visual hierarchy between the title, the designer quote and spacer for the body copy underneath.
<p class="label">Designer quote</p> <h1 class="heading">Paul Rand</h1> <p class="paragraph"> The public is more familiar with bad design than good design. It is, in effect, conditioned to prefer bad design, because that is what it lives with. The new becomes threatening, the old reassuring. </p> .p:first-of-type { margin-top: $spacing-7; margin-bottom: $spacing-1; } .h1 { margin-bottom: $spacing-5; } .p:last-of-type { margin-bottom: $spacing-9; }
Stacking is a form of spacing that creates equal distance between components or a group of items.
Designing with space and creating negative areas between elements consciously communicates their respective relationships and hierarchy, and is integral in a UI.
Space is a powerful design tool in suggesting relationships between elements in UI for several reasons.
Spacing affects users’ perception of the relative importance of UI elements. In simple terms, greater areas of negative space denote importance of a particular element, whereas less important elements attract less focus if there is less space around them.
Essential to good UI – white space allows a user’s eye to rest and avoids overcrowding of information on a page. Overly dense page content with insufficient spacing can contribute to cognitive load for your user, leading to poor user experience.
Use whitespace to create a visual hierarchy in page layout and improve readability of content.
Too little whitespace leads to a cluttered layout which is difficult to read.
Is this page useful for you?
Your feedback helps to improve our documentation.