Components / Button
variables
govuk-button-background-colour
$govuk-button-background-colour: govuk-colour("green") !default;Description
Button component background colour
Type
Colour
govuk-button-text-colour
$govuk-button-text-colour: govuk-colour("white") !default;Description
Button component text colour
Type
Colour
govuk-inverse-button-background-colour
$govuk-inverse-button-background-colour: govuk-colour("white") !default;Description
Inverted button component background colour
Type
Colour
govuk-inverse-button-text-colour
$govuk-inverse-button-text-colour: govuk-functional-colour(brand) !default;Description
Inverted button component text colour
Type
Colour
components/tag
functions
[private] _govuk-tag-text-colour
@function _govuk-tag-text-colour($colour) { ... }Description
Get tag text colour Almost all tags should use the 50% shade of their colour for their text
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$colour | name of colour from the colour palette | String | — none |
Returns
Colour —Representation of the named colour for use in tags
Requires
- [function]
govuk-colour
Used by
- [mixin]
_govuk-tag-colours
[private] _govuk-tag-background-colour
@function _govuk-tag-background-colour($colour) { ... }Description
Get tag background colour Almost all tags should use the 80% tint of their colour for their background
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$colour | name of colour from the colour palette | String | — none |
Returns
Colour —Representation of the named colour for use in tags
Requires
- [function]
govuk-colour
Used by
- [mixin]
_govuk-tag-colours
mixins
[private] _govuk-tag-colours
@mixin _govuk-tag-colours($colour) { ... }Description
Generate colour CSS for tag and tag modifiers Applies standard rules from the tag colour functions
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$colour | name of colour from the colour palette | String | — none |
Requires
- [function]
_govuk-tag-text-colour - [function]
_govuk-tag-background-colour
Helpers
mixins
govuk-device-pixel-ratio
@mixin govuk-device-pixel-ratio($ratio: 2) { ... }Description
Media query for retina images (device-pixel-ratio)
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$ratio | Device pixel ratio | Number | 2 |
Example
Providing a @2x image for screens that support it
background-image: govuk-image-url("my-image.png");
@include govuk-device-pixel-ratio {
background-image: govuk-image-url("my-image-2x.png");
}Using a custom ratio
background-image: govuk-image-url("my-image.png");
@include govuk-device-pixel-ratio {
background-image: govuk-image-url("my-image-2x.png");
}
@include govuk-device-pixel-ratio(3) {
background-image: govuk-image-url("my-image-3x.png");
}[private] _govuk-font-face-gds-transport
@mixin _govuk-font-face-gds-transport() { ... }Description
Font Face - GDS Transport
Outputs the font-face declaration for GDS Transport at the root of the CSS document the first time it is called.
Parameters
None.
Requires
- [mixin]
govuk-exports - [function]
govuk-font-url - [function]
govuk-font-url - [function]
govuk-font-url - [function]
govuk-font-url
Used by
- [mixin]
govuk-typography-common
Helpers / Accessibility
mixins
govuk-focused-text
@mixin govuk-focused-text() { ... }Description
Focused text
Provides an outline to clearly indicate when the target element is focused. Used for interactive text-based elements.
Parameters
None.
Example
Styling the focus state for a link
.govuk-link:focus {
@include govuk-focused-text;
}Requires
- [function]
govuk-functional-colour - [function]
govuk-functional-colour - [function]
govuk-functional-colour - [function]
govuk-functional-colour - [variable]
govuk-focus-width
Used by
- [mixin]
govuk-link-common
govuk-focused-box
@mixin govuk-focused-box() { ... }Description
Focused box
Provides an outline to clearly indicate when the target element is focused. Unlike govuk-focused-text, which only draws an underline below the element, govuk-focused-box draws an outline around all sides of the element. Best used for non-text content contained within links.
Parameters
None.
Example
Styling the focus state for a linked image
.govuk-link-image:focus {
@include govuk-focused-box;
}Requires
- [function]
govuk-functional-colour - [function]
govuk-functional-colour - [variable]
govuk-focus-width
Used by
- [mixin]
govuk-link-image
govuk-focused-form-input
@mixin govuk-focused-form-input() { ... }Description
Focused form input
Provides an outline to clearly indicate when the target element is focused. Used for form inputs.
Parameters
None.
Example
Styling the focus state for a form input
.govuk-input:focus {
@include govuk-focused-form-input;
}Requires
- [function]
govuk-functional-colour - [variable]
govuk-focus-width - [variable]
govuk-border-width-form-element
[private] _govuk-visually-hide-content
@mixin _govuk-visually-hide-content($important: true) { ... }Description
Helper function containing the common code for the following two mixins
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$important | Whether to mark as | Boolean | true |
Used by
- [mixin]
govuk-visually-hidden - [mixin]
govuk-visually-hidden-focusable
Links
Helpers / Colour
functions
govuk-colour
@function govuk-colour($colour, $variant) { ... }Description
Get a colour from the palette
Before using this function, check if there is a functional colour that matches your use case. For example, you should use the link functional colour for links rather than using this function to get blue from the palette.
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$colour | Name of colour from the colour palette ( | String or Colour | — none |
$variant | Name of the variant from the colour palette ( | String or Colour | — none |
Returns
Colour —Representation of named colour
Example
Getting the primary variant of a colour
.my-component {
color: govuk-colour("blue");
}Getting a 50% shade of blue
.my-component {
color: govuk-colour("blue", $variant: "shade-50")
}Throws
Unknown colour
#{$colour}(available colours: #{map-keys($colours)})Colour
#{$colour}should either be amaporcolor, not a#{type-of($colour-variants)}Unknown variant
#{$variant}for colour#{$colour}(available variants: #{map-keys($colour-variants)})
Requires
- [variable]
_govuk-palette
Used by
- [function]
_govuk-tag-text-colour - [function]
_govuk-tag-background-colour - [function]
_govuk-resolve-colour - [mixin]
govuk-link-style-error - [mixin]
govuk-link-style-success - [mixin]
govuk-link-style-inverse
govuk-functional-colour
@function govuk-functional-colour($colour) { ... }Description
Get a functional colour
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$colour | Name of the colour amongst the functional colours colours | String or Colour | — none |
Returns
String —A reference to the functional colour's custom property wrapped in a var function, with the functional colour's hex value as a fallback value.
Example
Getting a functional colour
.branded-element {
color: govuk-functional-colour('brand');
}Output from getting a functional colour
.branded-element {
/* Assuming the 'brand' colour is hotpink */
color: var(--_govuk-brand-colour, hotpink);
}Throws
Unknown colour
#{$colour}(available colours: #{map-keys($govuk-functional-colours)})
Requires
- [function]
_govuk-resolve-colour - [variable]
govuk-functional-colours - [variable]
govuk-functional-colours - [variable]
govuk-functional-colours
Used by
- [mixin]
govuk-focused-text - [mixin]
govuk-focused-text - [mixin]
govuk-focused-text - [mixin]
govuk-focused-text - [mixin]
govuk-focused-box - [mixin]
govuk-focused-box - [mixin]
govuk-focused-form-input - [mixin]
govuk-link-style-default - [mixin]
govuk-link-style-default - [mixin]
govuk-link-style-default - [mixin]
govuk-link-style-default - [mixin]
govuk-link-style-default - [mixin]
govuk-link-style-error - [mixin]
govuk-link-style-error - [mixin]
govuk-link-style-error - [mixin]
govuk-link-style-success - [mixin]
govuk-link-style-success - [mixin]
govuk-link-style-success - [mixin]
govuk-link-style-muted - [mixin]
govuk-link-style-muted - [mixin]
govuk-link-style-muted - [mixin]
govuk-link-style-inverse - [mixin]
govuk-link-style-no-visited-state - [mixin]
govuk-link-style-no-visited-state - [mixin]
govuk-link-style-no-visited-state - [mixin]
govuk-link-style-no-visited-state - [mixin]
govuk-link-style-no-visited-state - [mixin]
govuk-text-colour - [mixin]
govuk-text-colour
See
- [variable]
govuk-functional-colours
[private] _govuk-resolve-colour
@function _govuk-resolve-colour($colour-reference) { ... }Description
Resolves the given reference to a colour in the palette
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$colour-reference | A map with the | Map or Colour | — none |
Returns
Colour —The colour
Throws
Colour reference should be a Sass colour or a Sass map
Colour reference
nameshouldnColour reference
variantshouldn
Requires
- [function]
govuk-colour
Used by
- [function]
govuk-functional-colour
govuk-organisation-colour
@function govuk-organisation-colour($organisation, $contrast-safe: true) { ... }Description
Get the colour for a government organisation
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$organisation | Organisation name, lowercase, hyphenated | String | — none |
$contrast-safe | By default a version of the colour will be returned which has a minimum 4.5:1 contrast ratio when used with white, as per the WCAG 2.1 Level AA guidelines. If you want to use the non-contrast safe version you can set this to | Boolean | true |
Returns
Colour —Representation of colour for organisation
Throws
Unknown organisation
#{$organisation}
Requires
- [function]
_should-warn - [function]
_warning-text - [variable]
govuk-colours-organisations - [variable]
govuk-colours-organisations
[private] _as-hexadecimal
@function _as-hexadecimal($colour) { ... }Description
Converts a colour with potential float values for its RGB channels into hexadecimal notation
This ensures the colour is rendered properly by Safari < 12
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$colour | The colour to convert | Colour | — none |
Returns
ColourHelpers / Layout
mixins
govuk-clearfix
@mixin govuk-clearfix() { ... }Description
Clear floated content within a container using a pseudo element
Parameters
None.
govuk-grid-column
@mixin govuk-grid-column($width: full, $float: left, $at: tablet) { ... }Description
Generate grid column styles
Creates a grid column with standard gutter between the columns.
Grid widths are defined in the $govuk-grid-widths map.
By default the column width changes from 100% to specified width at the 'tablet' breakpoint, but other breakpoints can be specified using the $at parameter.
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$width | name of a grid width from $govuk-grid-widths | String | full |
$float | left | right | String | left |
$at | mobile | tablet | desktop | any custom breakpoint | String | tablet |
Example
Default
.govuk-grid-column-two-thirds {
@include govuk-grid-column(two-thirds)
}Customising the breakpoint where width percentage is applied
.govuk-grid-column-one-half-from-desktop {
@include govuk-grid-column(one-half, $at: desktop);
}Customising the float direction
.govuk-grid-column-one-half-right {
@include govuk-grid-column(two-thirds, $float: right);
}Requires
- [function]
govuk-from-breakpoint - [function]
govuk-grid-width - [variable]
govuk-gutter-half
govuk-media-query
@mixin govuk-media-query($from: false, $until: false, $and: false, $media-type: all, $breakpoints: $govuk-breakpoints) { ... }Description
Media query
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$from | One of $breakpoints | String or Boolean | false |
$until | One of $breakpoints | String or Boolean | false |
$and | Additional media query parameters | String or Boolean | false |
$media-type | Override media type: screen, print… | String | all |
$breakpoints | Map of breakpoints to use | Map | $govuk-breakpoints |
Example
.element {
@include govuk-media-query($from: mobile) {
color: red;
}
@include govuk-media-query($until: tablet) {
color: blue;
}
@include govuk-media-query(mobile, tablet) {
color: green;
}
@include govuk-media-query($from: tablet, $and: '(orientation: landscape)') {
color: teal;
}
@include govuk-media-query(950px) {
color: hotpink;
}
@include govuk-media-query(tablet, $media-type: screen) {
color: rebeccapurple;
}
}Requires
- [function]
govuk-from-breakpoint - [function]
govuk-until-breakpoint
functions
govuk-grid-width
@function govuk-grid-width($key) { ... }Description
Grid width percentage
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$key | Name of grid width (e.g. two-thirds) | String | — none |
Returns
Number —Percentage width
Throws
Unknown grid width
#{$key}
Requires
- [variable]
govuk-grid-widths - [variable]
govuk-grid-widths
Used by
- [mixin]
govuk-grid-column
govuk-breakpoint-value
@function govuk-breakpoint-value($value, $breakpoints: $govuk-breakpoints) { ... }Description
Get the value of a breakpoint by name.
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$value | If a string, the name of a breakpoint in $breakpoints. If a number without units, it will convert to px. If a number with units, it will return the value unaltered. | String or Number | — none |
$breakpoints | The map to look for $value. | Map | $govuk-breakpoints |
Returns
Number —The set (minimum) value of the breakpoint
Example
.element {
width: govuk-breakpoint-value(tablet);
@media (min-width: #{govuk-breakpoint-value(desktop)}) {
color: red;
}
@media (min-width: #{govuk-breakpoint-value(400px)}) {
color: green;
}
$custom-breakpoint-map: (
small: 350px,
medium: 769px,
large: 1100px,
extra-large: 1600px
);
@media (orientation: landscape) and (min-width: #{govuk-breakpoint-value(extra-large, $custom-breakpoint-map)}) {
color: blue;
}
}Throws
Could not find a breakpoint given
#{$value}.
Used by
- [function]
govuk-from-breakpoint - [function]
govuk-until-breakpoint
govuk-from-breakpoint
@function govuk-from-breakpoint($from, $breakpoints: $govuk-breakpoints) { ... }Description
Generate the min-width segment of a media query given a breakpoint key
Pixel values are converted to ems for backwards compatibility with sass-mq. Unlike sass-mq, non-px and em values can be used as well.
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$from | If a string, expects the name of a breakpoint in $breakpoints. If a number, it will use that number. | String or Number | — none |
$breakpoints | The map to look for $from. | Map | $govuk-breakpoints |
Returns
String —A min-width media query segment
Example
.example {
@media #{govuk-from-breakpoint(tablet)} {
color: red;
}
@media #{govuk-from-breakpoint(30em)} {
color: green;
}
@media #{govuk-from-breakpoint(tablet)} and (orientation: landscape) {
color: blue;
}
$custom-breakpoint-map: (
small: 350px,
medium: 769px,
large: 1100px,
extra-large: 1600px
);
@media #{govuk-from-breakpoint(extra-large, $custom-breakpoint-map)} {
color: cyan;
}
}Requires
- [function]
govuk-breakpoint-value - [function]
govuk-em
Used by
- [mixin]
govuk-grid-column - [mixin]
govuk-media-query - [mixin]
_govuk-responsive-spacing - [mixin]
govuk-font-size - [mixin]
govuk-width-container
govuk-until-breakpoint
@function govuk-until-breakpoint($until, $breakpoints: $govuk-breakpoints) { ... }Description
Generate the max-width segment of a media query given a breakpoint key
sass-mq converted pixel values to ems, and only performed subtractions on named breakpoints. These have been retained for backwards compatibility, though unlike sass-mq, this also supports using non-px and em values.
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$until | If a string, expects the name of a breakpoint in $breakpoints. If a number, it will use that number. | String or Number | — none |
$breakpoints | The map to look for $until. | Map | $govuk-breakpoints |
Returns
String —A max-width media query segment
Example
.example {
@media #{govuk-until-breakpoint(desktop)} {
color: red;
}
@media #{govuk-until-breakpoint(40em)} {
color: green;
}
@media #{govuk-until-breakpoint(tablet)} and (orientation: landscape) {
color: blue;
}
$custom-breakpoint-map: (
small: 350px,
medium: 769px,
large: 1100px,
extra-large: 1600px
);
@media #{govuk-until-breakpoint(extra-large, $custom-breakpoint-map)} {
color: cyan;
}
}Requires
- [function]
govuk-breakpoint-value - [function]
govuk-em
Used by
- [mixin]
govuk-media-query
Helpers / Links
mixins
govuk-link-common
@mixin govuk-link-common() { ... }Description
Common link styles
Provides the typography and focus state, regardless of link style.
Parameters
None.
Requires
- [mixin]
govuk-typography-common - [mixin]
govuk-link-decoration - [mixin]
govuk-link-hover-decoration - [mixin]
govuk-focused-text
govuk-link-decoration
@mixin govuk-link-decoration() { ... }Description
Link decoration
Provides the text decoration for links, including thickness and underline offset. Use this mixin only if you cannot use the govuk-link-common mixin.
Parameters
None.
Requires
- [variable]
govuk-link-underline-thickness - [variable]
govuk-link-underline-thickness - [variable]
govuk-link-underline-offset - [variable]
govuk-link-underline-offset
Used by
- [mixin]
govuk-link-common
govuk-link-hover-decoration
@mixin govuk-link-hover-decoration() { ... }Description
Link hover decoration
Provides the text decoration for links in their hover state, for you to use within a :hover pseudo-selector. Use this mixin only if you cannot use the govuk-link-common mixin.
Parameters
None.
Requires
- [variable]
govuk-link-hover-underline-thickness - [variable]
govuk-link-hover-underline-thickness
Used by
- [mixin]
govuk-link-common
govuk-link-style-default
@mixin govuk-link-style-default() { ... }Description
Default link styles
Makes links use the default unvisited, visited, hover and active colours.
If you use this mixin in a component, you must also include the govuk-link-common mixin to get the correct focus and hover states.
Parameters
None.
Example
.govuk-component__link {
@include govuk-link-common;
@include govuk-link-style-default;
}Requires
- [function]
govuk-functional-colour - [function]
govuk-functional-colour - [function]
govuk-functional-colour - [function]
govuk-functional-colour - [function]
govuk-functional-colour
govuk-link-style-error
@mixin govuk-link-style-error() { ... }Description
Error link styles
Makes links use the error colour. The link will darken if it's active or a user hovers their cursor over it.
If you use this mixin in a component, you must also include the govuk-link-common mixin to get the correct focus and hover states.
Parameters
None.
Example
.govuk-component__link {
@include govuk-link-common;
@include govuk-link-style-error;
}Requires
- [function]
govuk-functional-colour - [function]
govuk-colour - [function]
govuk-functional-colour - [function]
govuk-functional-colour
govuk-link-style-success
@mixin govuk-link-style-success() { ... }Description
Success link styles
Makes links use the success colour. The link will darken if it's active or a user hovers their cursor over it.
If you use this mixin in a component, you must also include the govuk-link-common mixin to get the correct focus and hover states.
Parameters
None.
Example
.govuk-component__link {
@include govuk-link-common;
@include govuk-link-style-success;
}Requires
- [function]
govuk-functional-colour - [function]
govuk-colour - [function]
govuk-functional-colour - [function]
govuk-functional-colour
govuk-link-style-muted
@mixin govuk-link-style-muted() { ... }Description
Muted link styles
Makes links use the secondary text colour. The link will darken if it's active or a user hovers their cursor over it.
If you use this mixin in a component, you must also include the govuk-link-common mixin to get the correct focus and hover states.
Parameters
None.
Example
.govuk-component__link {
@include govuk-link-common;
@include govuk-link-style-muted;
}Requires
- [function]
govuk-functional-colour - [function]
govuk-functional-colour - [function]
govuk-functional-colour
govuk-link-style-text
@mixin govuk-link-style-text() { ... }Description
Text link styles
Makes links use the primary text colour, in all states. Use this mixin for navigation components, such as breadcrumbs or the back link.
If you use this mixin in a component, you must also include the govuk-link-common mixin to get the correct focus and hover states.
Parameters
None.
Example
.govuk-component__link {
@include govuk-link-common;
@include govuk-link-style-text;
}Requires
- [mixin]
govuk-text-colour - [mixin]
govuk-text-colour
govuk-link-style-inverse
@mixin govuk-link-style-inverse() { ... }Description
Inverse link styles
Makes links white, in all states. Use this mixin if you're displaying links against a dark background.
If you use this mixin in a component, you must also include the govuk-link-common mixin to get the correct focus and hover states.
Parameters
None.
Example
.govuk-component__link {
@include govuk-link-common;
@include govuk-link-style-inverse;
}Requires
- [function]
govuk-colour - [function]
govuk-functional-colour
govuk-link-style-no-visited-state
@mixin govuk-link-style-no-visited-state() { ... }Description
Default link styles, without a visited state
Makes links use the default unvisited, hover and active colours, with no distinct visited state.
Use this mixin when it's not helpful to distinguish between visited and non-visited links. For example, when you link to pages with frequently-changing content, such as the dashboard for an admin interface.
If you use this mixin in a component, you must also include the govuk-link-common mixin to get the correct focus and hover states.
Parameters
None.
Example
.govuk-component__link {
@include govuk-link-common;
@include govuk-link-style-no-visited-state;
}Requires
- [function]
govuk-functional-colour - [function]
govuk-functional-colour - [function]
govuk-functional-colour - [function]
govuk-functional-colour - [function]
govuk-functional-colour
govuk-link-style-no-underline
@mixin govuk-link-style-no-underline() { ... }Description
Remove underline from links
Remove underlines from links unless the link is active or a user hovers their cursor over it.
Parameters
None.
Example
.govuk-component__link {
@include govuk-link-common;
@include govuk-link-style-default;
@include govuk-link-style-no-underline;
}govuk-link-print-friendly
@mixin govuk-link-print-friendly() { ... }Description
Include link destination when printing the page
If the user prints the page, add the destination URL after the link text, if the URL starts with /, http:// or https://.
Parameters
None.
govuk-link-image
@mixin govuk-link-image() { ... }Description
Image link styles
Prepares and provides the focus state for links that only contain images with no accompanying text.
Parameters
None.
Requires
- [mixin]
govuk-focused-box
Helpers / Shapes
functions
[private] _govuk-equilateral-height
@function _govuk-equilateral-height($base) { ... }Description
Calculate the height of an equilateral triangle
Multiplying half the length of the base of an equilateral triangle by the square root of three gives us its height. We use 1.732 as an approximation.
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$base | Length of the base of the triangle | Number | — none |
Returns
Number —Calculated height of the triangle
Used by
- [mixin]
govuk-shape-arrow
mixins
govuk-shape-arrow
@mixin govuk-shape-arrow($direction, $base, $height: null, $display: block) { ... }Description
Arrow mixin
Generate Arrows (triangles) by using a mix of transparent (1) and coloured borders. The coloured borders inherit the text colour of the element (2).
Ensure the arrow is rendered correctly if browser colours are overridden by providing a clip path (3). Without this the transparent borders are overridden to become visible which results in a square.
We need both because older browsers do not support clip-path.
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$direction | Direction for arrow: up, right, down, left. | String | — none |
$base | Length of the triangle 'base' side | Number | — none |
$height | Height of triangle. Omit for equilateral. | Number | null |
$display | CSS display property of the arrow | String | block |
Throws
Invalid arrow direction: expected
up,right,downorleft, got#{$direction}
Requires
- [function]
_govuk-equilateral-height
Helpers / Spacing
functions
govuk-spacing
@function govuk-spacing($spacing-point) { ... }Description
Single point spacing
Returns measurement corresponding to the spacing point requested.
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$spacing-point | Point on the spacing scale (set in | Number | — none |
Returns
String —Spacing measurement eg. 10px
Example
.element {
padding: govuk-spacing(5);
}Using negative spacing
.element {
margin-top: govuk-spacing(-1);
}Marking spacing declarations as important
.element {
margin-top: govuk-spacing(1) !important;
}Throws
Expected a number (integer), but got a
Unknown spacing variable
#{$spacing-point}. Make sure you are using a point from the spacing scale in_settings/spacing.scss.
Requires
- [variable]
govuk-spacing-points - [variable]
govuk-spacing-points
Used by
mixins
[private] _govuk-responsive-spacing
@mixin _govuk-responsive-spacing($responsive-spacing-point, $property, $direction: all, $important: false, $adjustment: false) { ... }Description
Responsive spacing
Adds responsive spacing (either padding or margin, depending on $property) by fetching a 'spacing map' from the responsive spacing scale, which defines different spacing values at different breakpoints.
To generate responsive spacing, use 'govuk-responsive-margin' or 'govuk-responsive-padding' mixins
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$responsive-spacing-point | Point on the responsive spacing scale, corresponds to a map of breakpoints and spacing values | Number | — none |
$property | Property to add spacing to (e.g. 'margin') | String | — none |
$direction | Direction to add spacing to ( | String | all |
$important | Whether to mark as | Boolean | false |
$adjustment | Offset to adjust spacing by | Number | false |
Throws
Expected a number (integer), but got a
Unknown spacing point
#{$responsive-spacing-point}. Make sure you are using a point from the
Requires
- [function]
govuk-from-breakpoint - [variable]
govuk-spacing-responsive-scale - [variable]
govuk-spacing-responsive-scale
Used by
govuk-responsive-margin
@mixin govuk-responsive-margin($responsive-spacing-point, $direction: all, $important: false, $adjustment: false) { ... }Description
Responsive margin
Adds responsive margin by fetching a 'spacing map' from the responsive spacing scale, which defines different spacing values at different breakpoints. Wrapper for the _govuk-responsive-spacing mixin.
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$responsive-spacing-point | Point on the responsive spacing scale, corresponds to a map of breakpoints and spacing values | Number | — none |
$direction | Direction to add spacing to ( | String | all |
$important | Whether to mark as | Boolean | false |
$adjustment | Offset to adjust spacing by | Number | false |
Example
.element {
@include govuk-responsive-margin(6, "left", $adjustment: 1px);
}Requires
- [mixin]
_govuk-responsive-spacing
See
- [mixin]
_govuk-responsive-spacing
govuk-responsive-padding
@mixin govuk-responsive-padding($responsive-spacing-point, $direction: all, $important: false, $adjustment: false) { ... }Description
Responsive padding
Adds responsive padding by fetching a 'spacing map' from the responsive spacing scale, which defines different spacing values at different breakpoints. Wrapper for the _govuk-responsive-spacing mixin.
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$responsive-spacing-point | Point on the responsive spacing scale, corresponds to a map of breakpoints and spacing values | Number | — none |
$direction | Direction to add spacing to ( | String | all |
$important | Whether to mark as | Boolean | false |
$adjustment | Offset to adjust spacing | Number | false |
Example
.element {
@include govuk-responsive-padding(6, "left", $adjustment: 1px);
}Requires
- [mixin]
_govuk-responsive-spacing
See
- [mixin]
_govuk-responsive-spacing
Helpers / Typography
mixins
govuk-typography-common
@mixin govuk-typography-common($font-family: $govuk-font-family) { ... }Description
'Common typography' helper
Sets the font family and associated properties, such as font smoothing. Also overrides the font for print.
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$font-family | Font family to use | List | $govuk-font-family |
Requires
- [mixin]
_govuk-font-face-gds-transport - [variable]
govuk-include-default-font-face - [variable]
govuk-font-family-print
Used by
- [mixin]
govuk-link-common - [mixin]
govuk-font
govuk-text-colour
@mixin govuk-text-colour() { ... }Description
Text colour helper
Sets the text colour, including a suitable override for print.
Parameters
None.
Requires
- [function]
govuk-functional-colour - [function]
govuk-functional-colour
Used by
- [mixin]
govuk-link-style-text - [mixin]
govuk-link-style-text
govuk-typography-weight-regular
@mixin govuk-typography-weight-regular($important: false) { ... }Description
Regular font weight helper
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$important | Whether to mark declarations as | Boolean | false |
Requires
- [variable]
govuk-font-weight-regular
Used by
- [mixin]
govuk-font
govuk-typography-weight-bold
@mixin govuk-typography-weight-bold($important: false) { ... }Description
Bold font weight helper
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$important | Whether to mark declarations as | Boolean | false |
Requires
- [variable]
govuk-font-weight-bold
Used by
- [mixin]
govuk-font
govuk-font-tabular-numbers
@mixin govuk-font-tabular-numbers($important: false) { ... }Description
Tabular number helper
Switches numerical glyphs (0–9) to use alternative forms with a monospaced bounding box. This ensures that columns of numbers, such as those in tables, remain horizontally aligned with one another. This also has the useful side effect of making numbers more legible in some situations, such as reference codes, as the numbers are more distinct and visually separated from one another.
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$important | Whether to mark declarations as | Boolean | false |
Used by
- [mixin]
govuk-font
govuk-text-break-word
@mixin govuk-text-break-word($important: false) { ... }Description
Word break helper
Forcibly breaks long words that lack spaces, such as email addresses, across multiple lines when they wouldn't otherwise fit.
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$important | Whether to mark declarations as | Boolean | false |
govuk-font-size
@mixin govuk-font-size($size, $line-height: false, $important: false) { ... }Description
Font size and line height helper
Takes a point from the responsive 'font map' as an argument (the size as it would appear on tablet and above), and uses it to create font-size and line-height declarations for different breakpoints, and print.
Example font map:
19: (
null: (
font-size: 16px,
line-height: 20px
),
tablet: (
font-size: 19px,
line-height: 25px
),
print: (
font-size: 14pt,
line-height: 1.15
)
);Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$size | Point from the type scale (the size as it would appear on tablet and above) | Number or String | — none |
$line-height | Non responsive custom line height. Omit to use the line height from the font map. | Number | false |
$important | Whether to mark declarations as | Boolean | false |
Throws
Unknown font size
#{$size}- expected a point from the type scale.
Requires
- [mixin]
_warning - [function]
govuk-px-to-rem - [function]
_govuk-line-height - [function]
govuk-from-breakpoint - [variable]
govuk-typography-scale - [variable]
govuk-typography-scale - [variable]
govuk-typography-scale
Used by
- [mixin]
govuk-font
govuk-font
@mixin govuk-font($size, $weight: regular, $tabular: false, $line-height: false) { ... }Description
Font helper
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$size | Point from the type scale (the size as it would appear on tablet and above). Use | Number or Boolean or String | — none |
$weight | Weight: | String | regular |
$tabular | Whether to use tabular numbers or not | Boolean | false |
$line-height | Line-height, if overriding the default | Number | false |
Throws
if
$sizeis not a valid point from the type scale (or false)
Requires
- [mixin]
govuk-typography-common - [mixin]
govuk-font-tabular-numbers - [mixin]
govuk-typography-weight-regular - [mixin]
govuk-typography-weight-bold - [mixin]
govuk-font-size
functions
[private] _govuk-line-height
@function _govuk-line-height($line-height, $font-size) { ... }Description
Convert line-heights specified in pixels into a relative value, unless they are already unit-less (and thus already treated as relative values) or the units do not match the units used for the font size.
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$line-height | Line height | Number | — none |
$font-size | Font size | Number | — none |
Returns
Number —The line height as either a relative value or unmodified
Used by
- [mixin]
govuk-font-size
Objects / Layout
mixins
govuk-width-container
@mixin govuk-width-container($width: $govuk-page-width) { ... }Description
Width container mixin
Used to create page width and custom width container classes.
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$width | Width in pixels | String | $govuk-page-width |
Example
Creating a 1200px wide container class
.app-width-container--wide {
@include govuk-width-container(1200px);
}Requires
- [function]
govuk-from-breakpoint - [variable]
govuk-gutter-half - [variable]
govuk-gutter-half - [variable]
govuk-gutter-half - [variable]
govuk-gutter-half - [variable]
govuk-gutter-half - [variable]
govuk-gutter-half - [variable]
govuk-gutter - [variable]
govuk-gutter - [variable]
govuk-gutter-half - [variable]
govuk-gutter-half - [variable]
govuk-gutter - [variable]
govuk-gutter - [variable]
govuk-gutter
Overrides
variables
[private] _spacing-directions
$_spacing-directions: ("top", "right", "bottom", "left") !default;Description
Directions for spacing
Type
Map
Used by
mixins
[private] _govuk-generate-responsive-spacing-overrides
@mixin _govuk-generate-responsive-spacing-overrides($property) { ... }Description
Generate responsive spacing override classes
Generate spacing override classes for the given property (e.g. margin) for each point in the responsive spacing scale.
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$property | Property to add spacing to (e.g. 'margin') | String | — none |
Example
.govuk-\!-margin-4 {
margin: 15px !important;
}
@media (min-width: 40.0625em) {
.govuk-\!-margin-4 {
margin: 20px !important;
}
}Requires
- [mixin]
_govuk-responsive-spacing - [mixin]
_govuk-responsive-spacing - [variable]
govuk-spacing-responsive-scale - [variable]
_spacing-directions
[private] _govuk-generate-static-spacing-overrides
@mixin _govuk-generate-static-spacing-overrides($property) { ... }Description
Generate static spacing override classes
Generate spacing override classes for the given property (e.g. margin) for each point in the non-responsive spacing scale.
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$property | Property to add spacing to (e.g. 'margin') | String | — none |
Example
.govuk-\!-static-margin-4 {
margin: 20px !important;
}Requires
- [function]
govuk-spacing - [function]
govuk-spacing - [variable]
govuk-spacing-points - [variable]
_spacing-directions
Settings / Assets
variables
govuk-assets-path
$govuk-assets-path: "/assets/" !default;Description
Path to the assets directory, with trailing slash.
This is the directory where the images and fonts subdirectories live. You will need to make this directory available via your application – see the README for details.
Type
String
govuk-images-path
$govuk-images-path: "#{$govuk-assets-path}images/" !default;Description
Path to the images folder, with trailing slash.
Type
String
Used by
- [function]
govuk-image-url
govuk-fonts-path
$govuk-fonts-path: "#{$govuk-assets-path}fonts/" !default;Description
Path to the fonts folder, with trailing slash.
Type
String
Used by
- [function]
govuk-font-url
govuk-image-url-function
$govuk-image-url-function: false !default;Description
Custom image URL function
If the built-in image URL helper does not meet your needs, you can specify the name of a custom handler – either built in or by writing your own function.
If you are writing your own handler, ensure that it returns a string wrapped with url()
Type
String
Example
Rails asset handling
$govuk-image-url-function: 'image-url';Custom asset handling
@function my-url-handler($filename) {
// Some custom URL handling
@return url('example.jpg');
}
$govuk-image-url-function: 'my-url-handler';Used by
- [function]
govuk-image-url - [function]
govuk-image-url - [function]
govuk-image-url
govuk-font-url-function
$govuk-font-url-function: false !default;Description
Custom font URL function
If the built-in font URL helper does not meet your needs, you can specify the name of a custom handler – either built in or by writing your own function.
If you are writing your own handler, ensure that it returns a string wrapped with url()
Type
String
Example
Rails asset handling
$govuk-font-url-function: 'font-url';Custom asset handling
@function my-url-handler($filename) {
// Some custom URL handling
@return url('example.woff');
}
$govuk-font-url-function: 'my-url-handler';Used by
- [function]
govuk-font-url - [function]
govuk-font-url - [function]
govuk-font-url
Settings / Colours
variables
govuk-default-functional-colours
$govuk-default-functional-colours: (
(
"brand": (
name: "blue"
),
"text": (
name: "black"
),
// The background colour of the template. This is intended to be the same
// as `surface-background` for the purposes of making the Footer and Cookie
// banner components merge seamlessly with the template.
"template-background": (
name: "blue",
variant: "tint-95"
),
"body-background": (
name: "white"
),
// Use 'true black' to avoid printers using colour ink to print body text
"print-text": #000000,
// Used in for example 'muted' text and help text.
"secondary-text": (
name: "black",
variant: "tint-25"
),
// Used for outline (and background, where appropriate) when interactive
// elements (links, form controls) have keyboard focus.
"focus": (
name: "yellow"
),
// Ensure that the contrast between the text and background colour passes
// WCAG Level AA contrast requirements.
"focus-text": (
name: "black"
),
// Used to highlight error messages and form controls in an error state
"error": (
name: "red"
),
// Used to highlight success messages and banners
"success": (
name: "green"
),
// Used in for example borders, separators, rules and keylines.
"border": (
name: "black",
variant: "tint-80"
),
// Used for form inputs and controls
"input-border": (
name: "black"
),
// Used for hover states on form controls
"hover": (
name: "black",
variant: "tint-80"
),
// Standard links (on white)
"link": (
name: "blue"
),
"link-visited": (
name: "purple"
),
"link-hover": (
name: "blue",
variant: "shade-50"
),
"link-active": (
name: "black"
),
// 'Surfaces' are our name for components that have different colour
// palettes to typical page content. This is the generic surface.
"surface-background": (
name: "blue",
variant: "tint-95"
),
"surface-text": (
name: "black"
),
"surface-border": (
name: "blue",
variant: "tint-50"
),
"surface-link": (
name: "blue",
variant: "shade-10"
)
)
);Description
Default definitions of the functional colours
Type
Map
See
- [variable]
govuk-functional-colours
govuk-functional-colours
$govuk-functional-colours: $govuk-default-functional-colours !default;Description
Functional colours for the GOV.UK palette.
Each functional colour is represented by a name (for example 'brand') to which the map associates either:
- a Sass colour (like
#1d70b8) - a Sass map with a
nameand an optionalvariantproperties, referring to one of the colours in the colour palette (like(name: 'blue', variant: 'primary')).variantdefaults to'primary'if omitted.
Use the govuk-functional-colour function to access these colours.
Customise functional colours by defining $govuk-functional-colours with a map of the colours that you want to change before importing GOV.UK Frontend. These will then be merged with the default colours. Note that you can only redefine existing colours.
Type
Map
Example
– Redefining functional colours by setting them before import
// These will be merged with the default functional colours
$govuk-functional-colours: (
// set the 'brand' colour to the 'primary' variant of 'purple'
brand: (name: 'purple'),
// set the 'template-background' colour to the 'tint-95' variant of 'purple'
template-background: (name: 'purple', variant: 'tint-95'),
// set the 'text' colour to an arbitrary colour `#221133`
text: #221133
);Used by
- [function]
govuk-functional-colour - [function]
govuk-functional-colour - [function]
govuk-functional-colour
See
- [function]
govuk-functional-colour
govuk-brand-colour
Variables for applied colours are deprecated. Please use the govuk-functional-colour function instead: govuk-functional-colour(brand).
$govuk-brand-colour: govuk-functional-colour(brand);Description
Brand colour
Type
Colour
govuk-text-colour
Variables for applied colours are deprecated. Please use the govuk-functional-colour function instead: govuk-functional-colour(text).
$govuk-text-colour: govuk-functional-colour(text);Description
Text colour
Type
Colour
govuk-template-background-colour
Variables for applied colours are deprecated. Please use the govuk-functional-colour function instead: govuk-functional-colour(template-background).
$govuk-template-background-colour: govuk-functional-colour(template-background);Description
Template background colour
Used by components that want to give the illusion of extending the template background (such as the footer and cookie banner).
Type
Colour
govuk-body-background-colour
Variables for applied colours are deprecated. Please use the govuk-functional-colour function instead: govuk-functional-colour(body-background).
$govuk-body-background-colour: govuk-functional-colour(body-background);Description
Body background colour
Type
Colour
govuk-print-text-colour
Variables for applied colours are deprecated. Please use the govuk-functional-colour function instead: govuk-functional-colour(print-text).
$govuk-print-text-colour: govuk-functional-colour(print-text);Description
Text colour for print media
Use 'true black' to avoid printers using colour ink to print body text
Type
Colour
govuk-secondary-text-colour
Variables for applied colours are deprecated. Please use the govuk-functional-colour function instead: govuk-functional-colour(secondary-text).
$govuk-secondary-text-colour: govuk-functional-colour(secondary-text);Description
Secondary text colour
Used in for example 'muted' text and help text.
Type
Colour
govuk-focus-colour
Variables for applied colours are deprecated. Please use the govuk-functional-colour function instead: govuk-functional-colour(focus).
$govuk-focus-colour: govuk-functional-colour(focus);Description
Focus colour
Used for outline (and background, where appropriate) when interactive elements (links, form controls) have keyboard focus.
Type
Colour
govuk-focus-text-colour
Variables for applied colours are deprecated. Please use the govuk-functional-colour function instead: govuk-functional-colour(focus-text).
$govuk-focus-text-colour: govuk-functional-colour(focus-text);Description
Focused text colour
Ensure that the contrast between the text and background colour passes WCAG Level AA contrast requirements.
Type
Colour
govuk-error-colour
Variables for applied colours are deprecated. Please use the govuk-functional-colour function instead: govuk-functional-colour(error).
$govuk-error-colour: govuk-functional-colour(error);Description
Error colour
Used to highlight error messages and form controls in an error state
Type
Colour
govuk-success-colour
Variables for applied colours are deprecated. Please use the govuk-functional-colour function instead: govuk-functional-colour(error).
$govuk-success-colour: govuk-functional-colour(success);Description
Success colour
Used to highlight success messages and banners
Type
Colour
govuk-border-colour
Variables for applied colours are deprecated. Please use the govuk-functional-colour function instead: govuk-functional-colour(border).
$govuk-border-colour: govuk-functional-colour(border);Description
Border colour
Used in for example borders, separators, rules and keylines.
Type
Colour
govuk-input-border-colour
Variables for applied colours are deprecated. Please use the govuk-functional-colour function instead: govuk-functional-colour(input-border).
$govuk-input-border-colour: govuk-functional-colour(input-border);Description
Input border colour
Used for form inputs and controls
Type
Colour
govuk-hover-colour
Variables for applied colours are deprecated. Please use the govuk-functional-colour function instead: govuk-functional-colour(hover).
$govuk-hover-colour: govuk-functional-colour(hover);Description
Input hover colour
Used for hover states on form controls
Type
Colour
govuk-link-colour
Variables for applied colours are deprecated. Please use the govuk-functional-colour function instead: govuk-functional-colour(link).
$govuk-link-colour: govuk-functional-colour(link);Description
Link colour
Type
Colour
govuk-link-visited-colour
Variables for applied colours are deprecated. Please use the govuk-functional-colour function instead: govuk-functional-colour(link-visited).
$govuk-link-visited-colour: govuk-functional-colour(link-visited);Description
Visited link colour
Type
Colour
govuk-link-hover-colour
Variables for applied colours are deprecated. Please use the govuk-functional-colour function instead: govuk-functional-colour(link-hover).
$govuk-link-hover-colour: govuk-functional-colour(link-hover);Description
Link hover colour
Type
Colour
govuk-link-active-colour
Variables for applied colours are deprecated. Please use the govuk-functional-colour function instead: govuk-functional-colour(link-active).
$govuk-link-active-colour: govuk-functional-colour(link-active);Description
Active link colour
Type
Colour
govuk-colours-organisations
$govuk-colours-organisations: (
"attorney-generals-office": (
colour: #a91c8e
),
"cabinet-office": (
colour: #0056b8
),
"civil-service": (
colour: #b2292e
),
"department-for-business-trade": (
colour: #e52d13,
contrast-safe: #e02c13
),
"department-for-culture-media-sport": (
colour: #ed1588,
contrast-safe: #d6177a
),
"department-for-education": (
colour: #003764
),
"department-for-energy-security-net-zero": (
colour: #003479
),
"department-for-environment-food-rural-affairs": (
colour: #00a33b,
contrast-safe: #008531
),
"department-for-science-innovation-technology": (
colour: #00f8f8,
contrast-safe: #008180
),
"department-for-transport": (
colour: #006853
),
"department-for-work-pensions": (
colour: #00bcb5,
contrast-safe: #00857e
),
"department-of-health-social-care": (
colour: #00a990,
contrast-safe: #008674
),
"foreign-commonwealth-development-office": (
colour: #012069
),
"hm-government": (
colour: #266ebc
),
"hm-revenue-customs": (
colour: #008670
),
"hm-treasury": (
colour: #b2292e
),
"home-office": (
colour: #732282
),
"ministry-of-defence": (
colour: #532a45
),
"ministry-of-housing-communities-local-government": (
colour: #00625e
),
"ministry-of-justice": (
colour: #000000
),
"northern-ireland-office": (
colour: #00205c
),
"office-of-the-advocate-general-for-scotland": (
colour: #00205c
),
"office-of-the-leader-of-the-house-of-commons": (
colour: #497629
),
"office-of-the-leader-of-the-house-of-lords": (
colour: #9c182f
),
"prime-ministers-office-10-downing-street": (
colour: #0b0c0c
),
"scotland-office": (
colour: #00205c
),
"serious-fraud-office": (
colour: #82368c
),
"uk-export-finance": (
colour: #cf102d
),
"wales-office": (
colour: #a33038
)
) !default;Description
Organisation colour palette
Type
Map
Map structure
| Map key Name | Map key Description | Map key Type | Map key Value |
|---|---|---|---|
$organisation.colour | Colour for the given | Map | — none |
$organisation.contrast-safe | 'Contrast safe' colour for the given | Map | — none |
$organisation.deprecation-message | Marks this organisation as deprecated (usually because it has ceased to exist). The value is the deprecation message output to the terminal when compiling Sass. | Map | — none |
Used by
- [function]
govuk-organisation-colour - [function]
govuk-organisation-colour
[private] _govuk-colours-organisations-aliases
$_govuk-colours-organisations-aliases: (
"department-for-business-and-trade": "department-for-business-trade"
);Description
Organisation colour aliases
Some organisations have been renamed within our code over time. Here we map the prior key to the new equivalent key.
Note: This is for internal renames only. If a department has changed name or brand colour in a machinery of government change, it should be added to $govuk-colours-organisations as a new entry with any superseded organisations marked deprecated.
Type
Map
[private] _govuk-palette
$_govuk-palette: (
"blue": (
"primary": #1d70b8,
"tint-25": #5694ca,
"tint-50": #8eb8dc,
"tint-80": #d2e2f1,
"tint-95": #f4f8fb,
"shade-25": #16548a,
"shade-50": #0f385c,
// Listed last as tests expect colours to be in a given order
"shade-10": #1a65a6
),
"green": (
"primary": #0f7a52,
"tint-25": #4b9b7d,
"tint-50": #87bca8,
"tint-80": #cfe4dc,
"tint-95": #f3f8f6,
"shade-25": #0b5c3e,
"shade-50": #083d29
),
"teal": (
"primary": #158187,
"tint-25": #50a1a5,
"tint-50": #8ac0c3,
"tint-80": #d0e6e7,
"tint-95": #f3f9f9,
"shade-25": #106165,
"shade-50": #0b4144,
"accent": #00ffe0
),
"purple": (
"primary": #54319f,
"tint-25": #7f65b7,
"tint-50": #aa98cf,
"tint-80": #ddd6ec,
"tint-95": #f6f5fa,
"shade-25": #3f2577,
"shade-50": #2a1950
),
"magenta": (
"primary": #ca357c,
"tint-25": #d7689d,
"tint-50": #e59abe,
"tint-80": #f4d7e5,
"tint-95": #fcf5f8,
"shade-25": #98285d,
"shade-50": #651b3e
),
"red": (
"primary": #ca3535,
"tint-25": #d76868,
"tint-50": #e59a9a,
"tint-80": #f4d7d7,
"tint-95": #fcf5f5,
"shade-25": #982828,
"shade-50": #651b1b
),
"orange": (
"primary": #f47738,
"tint-25": #f7996a,
"tint-50": #fabb9c,
"tint-80": #fde4d7,
"tint-95": #fef8f5,
"shade-25": #b7592a,
"shade-50": #7a3c1c
),
"yellow": (
"primary": #ffdd00,
"tint-25": #ffe640,
"tint-50": #ffee80,
"tint-80": #fff8cc,
"tint-95": #fffdf2,
"shade-25": #bfa600,
"shade-50": #806f00
),
"brown": (
"primary": #99704a,
"tint-25": #b39477,
"tint-50": #ccb8a5,
"tint-95": #faf8f6
),
"black": (
"primary": #0b0c0c,
"tint-25": #484949,
"tint-50": #858686,
"tint-80": #cecece,
"tint-95": #f3f3f3
),
"white": #ffffff
);Description
Colour palette
Type
Map
Map structure
| Map key Name | Map key Description | Map key Type | Map key Value |
|---|---|---|---|
$colour | Representation for the | Map</code> or <code>Colour | — none |
Used by
- [function]
govuk-colour
[private] _govuk-pre-brand-colours
$_govuk-pre-brand-colours: (
"light-pink": "magenta" "tint-50",
"pink": "magenta" "primary",
"light-green": "green" "tint-25",
"turquoise": "teal" "primary",
"light-blue": "blue" "tint-25",
"dark-blue": "blue" "shade-50",
"light-purple": "purple" "tint-25",
"bright-purple": "magenta" "shade-25",
"dark-grey": "black" "tint-25",
"mid-grey": "black" "tint-80",
"light-grey": "black" "tint-95"
);Description
Pre-brand colours correspondence table
Type
Map
Map structure
| Map key Name | Map key Description | Map key Type | Map key Value |
|---|---|---|---|
$colour | Colour name and variant in the brand colours that correspond to the | List | — none |
settings/custom-properties
variables
govuk-output-custom-properties
$govuk-output-custom-properties: true !default;Description
Output CSS custom properties
Whether to output CSS Custom Properties in the compiled stylesheet.
If you are compiling multiple stylesheets that will be used together on a page, set this to false in any secondary stylesheets to avoid including the Custom Properties multiple times.
Type
Boolean
Settings / Global Styles
variables
govuk-global-styles
$govuk-global-styles: false !default;Description
Include 'global' styles
Whether to style paragraphs (<p>) and links (<a>) without explicitly having to apply the govuk-body and govuk-link classes.
Type
Boolean
settings/layout
variables
govuk-page-width
$govuk-page-width: 960px !default;Description
Width of main container
Type
Number
govuk-grid-widths
$govuk-grid-widths: (
one-quarter: (
100% / 4
),
one-third: (
100% / 3
),
one-half: (
100% / 2
),
two-thirds: (
200% / 3
),
three-quarters: (
300% / 4
),
full: 100%
) !default;Description
Map of grid column widths
Type
Map
Used by
- [function]
govuk-grid-width - [function]
govuk-grid-width
govuk-gutter
$govuk-gutter: 30px !default;Description
Width of gutter between grid columns
Type
Number
Used by
- [mixin]
govuk-width-container - [mixin]
govuk-width-container - [mixin]
govuk-width-container - [mixin]
govuk-width-container - [mixin]
govuk-width-container
govuk-gutter-half
$govuk-gutter-half: $govuk-gutter / 2;Description
Width of half the gutter between grid columns
Type
Number
Used by
- [mixin]
govuk-grid-column - [mixin]
govuk-width-container - [mixin]
govuk-width-container - [mixin]
govuk-width-container - [mixin]
govuk-width-container - [mixin]
govuk-width-container - [mixin]
govuk-width-container - [mixin]
govuk-width-container - [mixin]
govuk-width-container
govuk-border-width
$govuk-border-width: 5px !default;Description
Standard border width
Type
Number
govuk-border-width-wide
$govuk-border-width-wide: 10px !default;Description
Wide border width
Type
Number
govuk-border-width-narrow
$govuk-border-width-narrow: 4px !default;Description
Narrow border width
Type
Number
govuk-border-width-form-element
$govuk-border-width-form-element: 2px !default;Description
Form control border width
Type
Number
Used by
- [mixin]
govuk-focused-form-input
govuk-border-width-form-group-error
$govuk-border-width-form-group-error: $govuk-border-width !default;Description
Form group border width when in error state
Type
Number
govuk-focus-width
$govuk-focus-width: 3px !default;Description
Border width of focus outline
Type
Number
Used by
- [mixin]
govuk-focused-text - [mixin]
govuk-focused-box - [mixin]
govuk-focused-form-input
govuk-hover-width
$govuk-hover-width: 10px !default;Description
Hover width for form controls with a hover state
Type
Number
govuk-breakpoints
$govuk-breakpoints: (
mobile: 320px,
tablet: 641px,
desktop: 769px
) !default;Description
Breakpoint definitions
Type
Map
Settings / Links
variables
govuk-link-underline-thickness
$govuk-link-underline-thickness: unquote("max(1px, .0625rem)") !default;Description
Thickness of link underlines
The default will be either:
- 1px
- 0.0625rem, if it's thicker than 1px because the user has changed the text size in their browser
Set this variable to false to avoid setting a thickness.
Type
Number
Used by
- [mixin]
govuk-link-decoration - [mixin]
govuk-link-decoration
govuk-link-underline-offset
$govuk-link-underline-offset: 0.1578em !default;Description
Offset of link underlines from text baseline
The default is 3px expressed as ems, as calculated against the default body font size (on desktop) of 19px. 3 ÷ 19 = 0.1578
Set this variable to false to avoid setting an offset.
Type
Number
Used by
- [mixin]
govuk-link-decoration - [mixin]
govuk-link-decoration
govuk-link-hover-underline-thickness
$govuk-link-hover-underline-thickness: unquote("max(3px, .1875rem, .12em)") !default;Description
Thickness of link underlines in hover state
The default for each link will be the thickest of the following:
- 3px
- 0.1875rem, if it's thicker than 3px because the user has changed the text size in their browser
- 0.12em (relative to the link's text size)
Set this variable to false to avoid setting a thickness.
Type
Number
Used by
- [mixin]
govuk-link-hover-decoration - [mixin]
govuk-link-hover-decoration
Settings / Spacing
variables
[private] govuk-spacing-points
$govuk-spacing-points: (
0: 0,
1: 5px,
2: 10px,
3: 15px,
4: 20px,
5: 25px,
6: 30px,
7: 40px,
8: 50px,
9: 60px
) !default;Description
Single point spacing variables. Access using govuk-spacing() (see helpers/spacing).
Type
Map
Used by
- [function]
govuk-spacing - [function]
govuk-spacing - [mixin]
_govuk-generate-static-spacing-overrides
[private] govuk-spacing-responsive-scale
$govuk-spacing-responsive-scale: (
0: (
null: 0
),
1: (
null: 5px
),
2: (
null: 10px
),
3: (
null: 15px
),
4: (
null: 15px,
tablet: 20px
),
5: (
null: 15px,
tablet: 25px
),
6: (
null: 20px,
tablet: 30px
),
7: (
null: 25px,
tablet: 40px
),
8: (
null: 30px,
tablet: 50px
),
9: (
null: 40px,
tablet: 60px
)
) !default;Description
Responsive spacing maps
These definitions are used to generate responsive spacing that adapts according to the breakpoints (see 'helpers/spacing'). These maps should be used wherever possible to standardise responsive spacing.
You can define different behaviour on tablet and desktop. The 'null' breakpoint is for mobile.
Access responsive spacing with govuk-responsive-margin or govuk-responsive-padding mixins (see helpers/spacing).
Type
Map
Used by
- [mixin]
_govuk-responsive-spacing - [mixin]
_govuk-responsive-spacing - [mixin]
_govuk-generate-responsive-spacing-overrides
Settings / Typography
variables
govuk-font-family
$govuk-font-family: "GDS Transport", arial, sans-serif !default;Description
Font families to use for all typography on screen media
Type
List
govuk-font-family-print
$govuk-font-family-print: sans-serif !default;Description
Font families to use for print media
We recommend that you use system fonts when printing. This will avoid issues with some printer drivers and operating systems.
Type
List
Used by
- [mixin]
govuk-typography-common
govuk-include-default-font-face
$govuk-include-default-font-face: if(index($govuk-font-family, "GDS Transport"), true, false) !default;Description
Include the default @font-face declarations
Defaults to true if "GDS Transport" appears in the $govuk-font-family setting.
Type
Boolean
Used by
- [mixin]
govuk-typography-common
govuk-font-weight-regular
$govuk-font-weight-regular: 400 !default;Description
Font weight for regular typography
Type
Number
Used by
- [mixin]
govuk-typography-weight-regular
govuk-font-weight-bold
$govuk-font-weight-bold: 700 !default;Description
Font weight for bold typography
Type
Number
Used by
- [mixin]
govuk-typography-weight-bold
govuk-root-font-size
$govuk-root-font-size: 16px !default;Description
Root font size
This is used to calculate rem sizes for the typography, and should match the effective font-size of your root (or html) element.
Ideally you should not be setting the font-size on the html or root element in order to allow it to scale with user-preference, in which case this should be set to 16px.
Type
Number
Used by
- [function]
govuk-px-to-rem
govuk-typography-scale
$govuk-typography-scale: (
80: (
null: (
font-size: 53px,
line-height: 55px
),
tablet: (
font-size: 80px,
line-height: 80px
),
print: (
font-size: 53pt,
line-height: 1.1
)
),
48: (
null: (
font-size: 32px,
line-height: 35px
),
tablet: (
font-size: 48px,
line-height: 50px
),
print: (
font-size: 32pt,
line-height: 1.15
)
),
36: (
null: (
font-size: 27px,
line-height: 30px
),
tablet: (
font-size: 36px,
line-height: 40px
),
print: (
font-size: 24pt,
line-height: 1.05
)
),
27: (
// Made same as 24 on mobile (consider deprecating this size)
null: (
font-size: 21px,
line-height: 25px
),
tablet: (
font-size: 27px,
line-height: 30px
),
print: (
font-size: 18pt,
line-height: 1.15
)
),
24: (
// Bump up mobile size from 18/20 to 21/25
null: (
font-size: 21px,
line-height: 25px
),
tablet: (
font-size: 24px,
line-height: 30px
),
print: (
font-size: 18pt,
line-height: 1.15
)
),
19: (
// Stay at 19/25 at all sizes
null: (
font-size: 19px,
line-height: 25px
),
print: (
font-size: 14pt,
line-height: 1.15
)
),
16: (
// Stay at 16/20 at all sizes
null: (
font-size: 16px,
line-height: 20px
),
print: (
font-size: 14pt,
line-height: 1.2
)
)
) !default;Description
Responsive typography font map
This is used to generate responsive typography that adapts according to the breakpoints.
Font size and font weight can be defined for each breakpoint. You can define different behaviour on tablet and desktop. The 'null' breakpoint is for mobile.
Line-heights will automatically be converted from pixel measurements into relative values. For example, with a font-size of 16px and a line-height of 24px, the line-height will be converted to 1.5 before output.
You can also specify a separate font size and line height for print media.
Type
Map
Map structure
| Map key Name | Map key Description | Map key Type | Map key Value |
|---|---|---|---|
$point.$breakpoint.font-size | Font size for | Number | — none |
$point.$breakpoint.line-height | Line height for | Number | — none |
$point.print.font-size | Font size for | Number | — none |
$point.print.line-height | Line height for | Number | — none |
Used by
- [mixin]
govuk-font-size - [mixin]
govuk-font-size - [mixin]
govuk-font-size
Settings / Warnings
variables
govuk-suppressed-warnings
$govuk-suppressed-warnings: () !default;Description
Suppressed warnings map
This map is used to determine which deprecation warnings to not show to users when compiling sass. This is in place for codebases that do not have the necessary capacity to upgrade and remove the deprecation, particularly if the deprecation is significant. For example, the removal of mixins and functions that were previously available to users of Frontend.
You can add to this map and define which warnings to suppress by appending to it using the warning key, found in the warning message. For example:
Type
List
Example
:
// warning message:
// $foobar is no longer supported. To silence this warning, update
// $govuk-suppressed-warnings with key: "foobar"
$govuk-suppressed-warnings: (
foobar
);Used by
- [mixin]
_warning - [mixin]
_warning - [function]
_should-warn - [function]
_warning-text
mixins
[private] _warning
@mixin _warning($key, $message, $silence-further-warnings) { ... }Description
Warnings
Acts as a wrapper for the built in @warn sass function
We use this instead of using @warn for 3 reasons:
- To check if a warning is being suppressed through
$govuk-suppressed-warnings, in which case we don't call@warnand printing the warning to the user - To format the passed warning
$messagewith the warning key at the end - To prevent duplicate warnings by adding the passed
$keyto$govuk-suppressed-warningsafter@warnis called to ensure it only runs once per sass compilation (unless $silence-further-warnings is false)
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$key | The key to be checked against | String | — none |
$message | The message to use when calling | String | — none |
$silence-further-warnings | Whether to silence future warnings that use the same $key | Boolean | — none |
Requires
- [function]
_should-warn - [function]
_warning-text - [variable]
govuk-suppressed-warnings - [variable]
govuk-suppressed-warnings
Used by
- [mixin]
govuk-font-size
functions
[private] _should-warn
@function _should-warn($key) { ... }Description
Check whether a key is present in the suppressed warnings list.
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$key | The key to be checked against | String | — none |
Requires
- [variable]
govuk-suppressed-warnings
Used by
- [function]
govuk-organisation-colour - [mixin]
_warning
[private] _warning-text
@function _warning-text($key, $message) { ... }Description
Format a warning by appending information on how to suppress it.
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$key | The key needed to suppress the warning. | String | — none |
$message | The warning text. | String | — none |
Requires
- [variable]
govuk-suppressed-warnings
Used by
- [function]
govuk-organisation-colour - [mixin]
_warning
Tools
variables
[private] _govuk-imported-modules
$_govuk-imported-modules: () !default;Description
List of modules which have already been exported
Type
List
Used by
- [mixin]
govuk-exports - [mixin]
govuk-exports - [mixin]
govuk-exports
mixins
govuk-exports
@mixin govuk-exports($name) { ... }Description
Export module
Ensure that the modules of CSS that we define throughout Frontend are only included in the generated CSS once, no matter how many times they are imported across the individual components.
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$name | Name of module - must be unique within the codebase | String | — none |
Requires
- [variable]
_govuk-imported-modules - [variable]
_govuk-imported-modules - [variable]
_govuk-imported-modules
Used by
- [mixin]
_govuk-font-face-gds-transport
Tools / Assets
functions
govuk-font-url
@function govuk-font-url($filename) { ... }Description
Font URL
If a custom font-url handler is defined ($govuk-font-url-function) then it will be called, otherwise a url will be returned with the filename appended to the font path.
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$filename | Font filename | String | — none |
Returns
String —URL for the filename, wrapped in url()
Requires
- [variable]
govuk-font-url-function - [variable]
govuk-font-url-function - [variable]
govuk-font-url-function - [variable]
govuk-fonts-path
Used by
- [mixin]
_govuk-font-face-gds-transport - [mixin]
_govuk-font-face-gds-transport - [mixin]
_govuk-font-face-gds-transport - [mixin]
_govuk-font-face-gds-transport
govuk-image-url
@function govuk-image-url($Filename) { ... }Description
Image URL
If a custom image-url handler is defined ($govuk-image-url-function) then it will be called, otherwise a url will be returned with the filename appended to the image path.
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$Filename | for the image to load | String | — none |
Returns
String —URL for the filename, wrapped in url()
Requires
- [variable]
govuk-image-url-function - [variable]
govuk-image-url-function - [variable]
govuk-image-url-function - [variable]
govuk-images-path
Tools / Unit Conversion
functions
govuk-em
@function govuk-em($value, $context-font-size: $govuk-root-font-size) { ... }Description
Convert pixels to em
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$value | Length in pixels | Number | — none |
$context-font-size | Font size of element | Number | $govuk-root-font-size |
Returns
Number —Length in ems
Used by
- [function]
govuk-from-breakpoint - [function]
govuk-until-breakpoint
govuk-px-to-rem
@function govuk-px-to-rem($value) { ... }Description
Convert pixels to rem
The $govuk-root-font-size (defined in settings/_typography-responsive.scss) must be configured to match the font-size of your root (html) element
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$value | Length in pixels | Number | — none |
Returns
Number —Length in rems
Requires
- [variable]
govuk-root-font-size
Used by
- [mixin]
govuk-font-size