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 Nameparameter Descriptionparameter Typeparameter Default value
$colour

name of colour from the colour palette

String none

Returns

Colour

Representation of the named colour for use in tags

Requires

Used by

[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 Nameparameter Descriptionparameter Typeparameter Default value
$colour

name of colour from the colour palette

String none

Returns

Colour

Representation of the named colour for use in tags

Requires

Used by

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 Nameparameter Descriptionparameter Typeparameter Default value
$colour

name of colour from the colour palette

String none

Requires

Helpers

mixins

govuk-device-pixel-ratio

@mixin govuk-device-pixel-ratio($ratio: 2) { ... }

Description

Media query for retina images (device-pixel-ratio)

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$ratio

Device pixel ratio

Number2

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

Used by

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

Used by

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

Used by

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

[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 Nameparameter Descriptionparameter Typeparameter Default value
$important

Whether to mark as !important

Booleantrue

Used by

Links

govuk-visually-hidden

@mixin govuk-visually-hidden($important: true) { ... }

Description

Hide an element visually, but have it available for screen readers

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$important

Whether to mark as !important

Booleantrue

Requires

govuk-visually-hidden-focusable

@mixin govuk-visually-hidden-focusable($important: true) { ... }

Description

Hide an element visually, but have it available for screen readers whilst allowing the element to be focused when navigated to via the keyboard (e.g. for the skip link)

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$important

Whether to mark as !important

Booleantrue

Requires

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 Nameparameter Descriptionparameter Typeparameter Default value
$colour

Name of colour from the colour palette ($_govuk-palette)

String or Colour none
$variant

Name of the variant from the colour palette ($_govuk-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 a map or color, not a #{type-of($colour-variants)}

  • Unknown variant #{$variant} for colour #{$colour} (available variants: #{map-keys($colour-variants)})

Requires

Used by

govuk-functional-colour

@function govuk-functional-colour($colour) { ... }

Description

Get a functional colour

Parameters

parameter Nameparameter Descriptionparameter Typeparameter 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

Used by

See

[private] _govuk-resolve-colour

@function _govuk-resolve-colour($colour-reference) { ... }

Description

Resolves the given reference to a colour in the palette

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$colour-reference

A map with the name, and optionally a variant for the colour in the palette

Map or Colour none

Returns

Colour

The colour

Throws

  • Colour reference should be a Sass colour or a Sass map

  • Colour reference name shouldn

  • Colour reference variant shouldn

Requires

Used by

govuk-organisation-colour

@function govuk-organisation-colour($organisation, $contrast-safe: true) { ... }

Description

Get the colour for a government organisation

Parameters

parameter Nameparameter Descriptionparameter Typeparameter 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 false but your should ensure that you still meets contrast requirements for accessibility - for example, do not use the non-contrast safe version for text.

Booleantrue

Returns

Colour

Representation of colour for organisation

Throws

  • Unknown organisation #{$organisation}

Requires

[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 Nameparameter Descriptionparameter Typeparameter Default value
$colour

The colour to convert

Colour none

Returns

Colour

Helpers / 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 Nameparameter Descriptionparameter Typeparameter Default value
$width

name of a grid width from $govuk-grid-widths

Stringfull
$float

left | right

Stringleft
$at

mobile | tablet | desktop | any custom breakpoint

Stringtablet

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

govuk-media-query

@mixin govuk-media-query($from: false, $until: false, $and: false, $media-type: all, $breakpoints: $govuk-breakpoints) { ... }

Description

Media query

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$from

One of $breakpoints

String or Booleanfalse
$until

One of $breakpoints

String or Booleanfalse
$and

Additional media query parameters

String or Booleanfalse
$media-type

Override media type: screen, print…

Stringall
$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

functions

govuk-grid-width

@function govuk-grid-width($key) { ... }

Description

Grid width percentage

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$key

Name of grid width (e.g. two-thirds)

String none

Returns

Number

Percentage width

Throws

  • Unknown grid width #{$key}

Requires

Used by

govuk-breakpoint-value

@function govuk-breakpoint-value($value, $breakpoints: $govuk-breakpoints) { ... }

Description

Get the value of a breakpoint by name.

Parameters

parameter Nameparameter Descriptionparameter Typeparameter 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

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 Nameparameter Descriptionparameter Typeparameter 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

Used by

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 Nameparameter Descriptionparameter Typeparameter 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

Used by

Helpers / Links

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 Nameparameter Descriptionparameter Typeparameter Default value
$base

Length of the base of the triangle

Number none

Returns

Number

Calculated height of the triangle

Used by

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 Nameparameter Descriptionparameter Typeparameter 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.

Numbernull
$display

CSS display property of the arrow

Stringblock

Throws

  • Invalid arrow direction: expected up, right, down or left, got #{$direction}

Requires

Helpers / Spacing

functions

govuk-spacing

@function govuk-spacing($spacing-point) { ... }

Description

Single point spacing

Returns measurement corresponding to the spacing point requested.

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$spacing-point

Point on the spacing scale (set in settings/_spacing.scss)

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

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 Nameparameter Descriptionparameter Typeparameter 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 (top, right, bottom, left, all)

Stringall
$important

Whether to mark as !important

Booleanfalse
$adjustment

Offset to adjust spacing by

Numberfalse

Throws

  • Expected a number (integer), but got a

  • Unknown spacing point #{$responsive-spacing-point}. Make sure you are using a point from the

Requires

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 Nameparameter Descriptionparameter Typeparameter 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 (top, right, bottom, left, all)

Stringall
$important

Whether to mark as !important

Booleanfalse
$adjustment

Offset to adjust spacing by

Numberfalse

Example

.element {
   @include govuk-responsive-margin(6, "left", $adjustment: 1px);
}

Requires

See

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 Nameparameter Descriptionparameter Typeparameter 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 (top, right, bottom, left, all)

Stringall
$important

Whether to mark as !important

Booleanfalse
$adjustment

Offset to adjust spacing

Numberfalse

Example

.element {
   @include govuk-responsive-padding(6, "left", $adjustment: 1px);
}

Requires

See

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 Nameparameter Descriptionparameter Typeparameter Default value
$font-family

Font family to use

List$govuk-font-family

Requires

Used by

govuk-text-colour

@mixin govuk-text-colour() { ... }

Description

Text colour helper

Sets the text colour, including a suitable override for print.

Parameters

None.

Requires

Used by

govuk-typography-weight-regular

@mixin govuk-typography-weight-regular($important: false) { ... }

Description

Regular font weight helper

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$important

Whether to mark declarations as !important. Generally Used to create override classes.

Booleanfalse

Requires

Used by

govuk-typography-weight-bold

@mixin govuk-typography-weight-bold($important: false) { ... }

Description

Bold font weight helper

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$important

Whether to mark declarations as !important. Generally Used to create override classes.

Booleanfalse

Requires

Used by

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 Nameparameter Descriptionparameter Typeparameter Default value
$important

Whether to mark declarations as !important. Generally Used to create override classes.

Booleanfalse

Used by

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 Nameparameter Descriptionparameter Typeparameter Default value
$important

Whether to mark declarations as !important. Generally used to create override classes.

Booleanfalse

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 Nameparameter Descriptionparameter Typeparameter 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.

Numberfalse
$important

Whether to mark declarations as !important.

Booleanfalse

Throws

  • Unknown font size #{$size} - expected a point from the type scale.

Requires

Used by

govuk-font

@mixin govuk-font($size, $weight: regular, $tabular: false, $line-height: false) { ... }

Description

Font helper

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$size

Point from the type scale (the size as it would appear on tablet and above). Use false to avoid setting a size.

Number or Boolean or String none
$weight

Weight: bold or regular

Stringregular
$tabular

Whether to use tabular numbers or not

Booleanfalse
$line-height

Line-height, if overriding the default

Numberfalse

Throws

  • if $size is not a valid point from the type scale (or false)

Requires

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 Nameparameter Descriptionparameter Typeparameter 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

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 Nameparameter Descriptionparameter Typeparameter 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

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 Nameparameter Descriptionparameter Typeparameter 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

[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 Nameparameter Descriptionparameter Typeparameter Default value
$property

Property to add spacing to (e.g. 'margin')

String none

Example

.govuk-\!-static-margin-4 {
   margin: 20px !important;
}

Requires

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

govuk-fonts-path

$govuk-fonts-path: "#{$govuk-assets-path}fonts/" !default;

Description

Path to the fonts folder, with trailing slash.

Type

String

Used by

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

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

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

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 name and an optional variant properties, referring to one of the colours in the colour palette (like (name: 'blue', variant: 'primary')). variant defaults 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

See

govuk-brand-colour

Deprecated!

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

Deprecated!

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

Deprecated!

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

Deprecated!

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

Deprecated!

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

Deprecated!

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

Deprecated!

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

Deprecated!

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

Deprecated!

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

Deprecated!

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

Deprecated!

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

Deprecated!

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

Deprecated!

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-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 NameMap key DescriptionMap key TypeMap key Value
$organisation.colour

Colour for the given $organisation

Map none
$organisation.contrast-safe

'Contrast safe' colour for the given $organisation. This colour has at least a 4.5:1 contrast against white, to be used for copy and meet the AAA (large text) and AA (smaller copy) WCAG guidelines.

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

[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 NameMap key DescriptionMap key TypeMap key Value
$colour

Representation for the $colour or a map associating name of $variants of the colours to their representation

Map</code> or <code>Colour none

Used by

[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 NameMap key DescriptionMap key TypeMap key Value
$colour

Colour name and variant in the brand colours that correspond to the $colour in GOV.UK Frontend colours before the brand colours were introduced

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

govuk-gutter

$govuk-gutter: 30px !default;

Description

Width of gutter between grid columns

Type

Number

Used by

govuk-gutter-half

$govuk-gutter-half: $govuk-gutter / 2;

Description

Width of half the gutter between grid columns

Type

Number

Used by

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

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

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

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

[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

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

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

govuk-font-weight-regular

$govuk-font-weight-regular: 400 !default;

Description

Font weight for regular typography

Type

Number

Used by

govuk-font-weight-bold

$govuk-font-weight-bold: 700 !default;

Description

Font weight for bold typography

Type

Number

Used by

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

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 NameMap key DescriptionMap key TypeMap key Value
$point.$breakpoint.font-size

Font size for $point at $breakpoint

Number none
$point.$breakpoint.line-height

Line height for $point at $breakpoint

Number none
$point.print.font-size

Font size for $point when printing

Number none
$point.print.line-height

Line height for $point when printing

Number none

Used by

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

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 @warn and printing the warning to the user
  • To format the passed warning $message with the warning key at the end
  • To prevent duplicate warnings by adding the passed $key to $govuk-suppressed-warnings after @warn is called to ensure it only runs once per sass compilation (unless $silence-further-warnings is false)

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$key

The key to be checked against $govuk-suppressed-warnings and then passed to it to prevent multiple of the same warning.

String none
$message

The message to use when calling @warn

String none
$silence-further-warnings

Whether to silence future warnings that use the same $key

Boolean none

Requires

Used by

functions

[private] _should-warn

@function _should-warn($key) { ... }

Description

Check whether a key is present in the suppressed warnings list.

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$key

The key to be checked against $govuk-suppressed-warnings.

String none

Requires

Used by

[private] _warning-text

@function _warning-text($key, $message) { ... }

Description

Format a warning by appending information on how to suppress it.

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$key

The key needed to suppress the warning.

String none
$message

The warning text.

String none

Requires

Used by

Tools

variables

[private] _govuk-imported-modules

$_govuk-imported-modules: () !default;

Description

List of modules which have already been exported

Type

List

Used by

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 Nameparameter Descriptionparameter Typeparameter Default value
$name

Name of module - must be unique within the codebase

String none

Requires

Used by

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 Nameparameter Descriptionparameter Typeparameter Default value
$filename

Font filename

String none

Returns

String

URL for the filename, wrapped in url()

Requires

Used by

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 Nameparameter Descriptionparameter Typeparameter Default value
$Filename

for the image to load

String none

Returns

String

URL for the filename, wrapped in url()

Requires

Tools / Unit Conversion

functions

govuk-em

@function govuk-em($value, $context-font-size: $govuk-root-font-size) { ... }

Description

Convert pixels to em

Parameters

parameter Nameparameter Descriptionparameter Typeparameter 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

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 Nameparameter Descriptionparameter Typeparameter Default value
$value

Length in pixels

Number none

Returns

Number

Length in rems

Requires

Used by