Spacing
Use a consistent spacing scale to make relationships clear.
Use the Camden spacing scales to create consistent relationships between elements.
Responsive spacing
Responsive spacing changes at larger screen sizes.
| Spacing unit | Small screen | Large screen |
|---|---|---|
| 0 | 0 | 0 |
| 1 | 5px | 5px |
| 2 | 10px | 10px |
| 3 | 15px | 15px |
| 4 | 15px | 20px |
| 5 | 20px | 25px |
| 6 | 25px | 30px |
| 7 | 30px | 40px |
| 8 | 35px | 50px |
| 9 | 45px | 60px |
| 10 | 55px | 70px |
Static spacing
Static spacing stays the same at every screen size and uses the large-screen values from the responsive scale.
| Spacing unit | All screens |
|---|---|
| 0 | 0 |
| 1 | 5px |
| 2 | 10px |
| 3 | 15px |
| 4 | 20px |
| 5 | 25px |
| 6 | 30px |
| 7 | 40px |
| 8 | 50px |
| 9 | 60px |
Applying spacing in SCSS
If you want to reference the spacing scale in your SCSS, use the spacing helpers.
Using the responsive spacing helper
To use the responsive spacing scale, include the govuk-responsive-margin or govuk-responsive-padding mixins.
For example, to apply spacing unit 6 for 30px padding on large screens and 20px on small screens, use:
@include govuk-responsive-padding(6);
You can also add an argument to apply margin or padding in a single direction.
For example, to apply spacing unit 6 for a 30px bottom margin on large screens and a 20px bottom margin on small screens, use:
@include govuk-responsive-margin(6, "bottom");
Using the static spacing helper
For the static spacing scale, use the govuk-spacing function.
For example, to apply spacing unit 6 for 30px top padding on all screens, use:
padding-top: govuk-spacing(6);
For negative spacing, use a negative spacing unit number.
For example, to apply spacing unit -3 for a negative 15px top margin all screens, use:
Overriding spacing
You can use spacing override classes if you need to make small changes like adding or removing spacing elements of your design. You can use the spacing override classes for this.
Responsive spacing override classes
The responsive spacing override classes start with: govuk-!-, followed by either margin- or padding-, and then a spacing unit number.
To apply spacing in a single direction, include left-, right-, top-, or bottom- just before the spacing unit.
For example, use:
govuk-!-margin-9to apply a 40px margin to all sides of the element on small screens, increasing to 60px on large screensgovuk-!-padding-right-5to apply 15px of padding to the right side of the element on small screens, increasing to 25px on large screensgovuk-!-margin-0to remove all margins at all screen sizes
Static spacing override classes
The static spacing override classes start with `govuk-!-static``. Use them the same way as the responsive spacing override classes.
For example, use:
govuk-!-static-margin-9to apply a 60px margin to all sides of the element at all screen sizesgovuk-!-static-padding-right-5to apply 25px of padding to the right side of the element at all screen sizesgovuk-!-static-margin-0to remove all margins at all screen sizes, same asgovuk-!-margin-0