components/panel

variables

nhsuk-panel-border-width

$nhsuk-panel-border-width: nhsuk-spacing(1);

Description

The overflowing is a particular problem with the panel component since it uses white text: when the text overflows the container, it is invisible on the white (page) background. When the text in our other components overflow, the user might have to scroll horizontally to view it but the text remains legible.

Links

helpers/colour

functions

nhsuk-colour

@function nhsuk-colour($colour) { ... }

Description

Get colour

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$colour

Name of colour from the colour palette ($nhsuk-colours)

String or Colour none

Returns

Colour

Representation of named colour

Throws

  • Unknown colour #{$colour}

Requires

Used by

nhsuk-colour-compatible

@function nhsuk-colour-compatible($colour) { ... }

Description

Converts a colour with potential float values for its RGB channels into hexadecimal notation where possible (e.g. no alpha transparency)

This ensures the colour is rendered properly by Safari < 12

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$colour

The colour to convert or name from the colour palette

String or Colour none

Returns

Colour

Requires

Used by

nhsuk-shade

@function nhsuk-shade($colour, $percentage) { ... }

Description

Make a colour darker by mixing it with black

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$colour

colour to shade

Colour none
$percentage

percentage of black to mix with $colour

Number none

Returns

Colour

Example

nhsuk-shade(color, percentage);
nhsuk-shade(nhsuk-colour("blue"), 50%);

Requires

Used by

nhsuk-tint

@function nhsuk-tint($colour, $percentage) { ... }

Description

Make a colour lighter by mixing it with white

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$colour

colour to tint

Colour none
$percentage

percentage of white to mix with $colour

Number none

Returns

Colour

Example

nhsuk-tint(color, percentage);
nhsuk-tint(nhsuk-colour("blue"), 10%);

Requires

objects/layout

mixins

nhsuk-width-container

@mixin nhsuk-width-container($width: $nhsuk-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$nhsuk-page-width

Example

Creating a 1200px wide container class

.app-width-container--wide {
  @include nhsuk-width-container(1200px);
}

Requires

Links

settings/colours

variables

nhsuk-brand-colour

$nhsuk-brand-colour: nhsuk-colour("blue") !default;

Description

Brand colour

Type

Colour

nhsuk-text-colour

$nhsuk-text-colour: nhsuk-colour("black") !default;

Description

Text colour

Type

Colour

Used by

nhsuk-reverse-text-colour

$nhsuk-reverse-text-colour: nhsuk-colour("white") !default;

Description

Text colour (reverse)

Type

Colour

Used by

nhsuk-template-background-colour

$nhsuk-template-background-colour: nhsuk-colour("grey-4") !default;

Description

Template background colour

Used by components that want to give the illusion of extending the template background (such as the footer).

Type

Colour

nhsuk-body-background-colour

$nhsuk-body-background-colour: nhsuk-colour("grey-5") !default;

Description

Body background colour

Type

Colour

nhsuk-card-background-colour

$nhsuk-card-background-colour: nhsuk-colour("white") !default;

Description

Card background colour

Type

Colour

nhsuk-print-text-colour

$nhsuk-print-text-colour: #000000 !default;

Description

Text colour for print media

Use 'true black' to avoid printers using colour ink to print body text

Type

Colour

Used by

nhsuk-secondary-text-colour

$nhsuk-secondary-text-colour: nhsuk-colour("grey-1") !default;

Description

Secondary text colour

Used in for example 'muted' text and help text.

Type

Colour

nhsuk-focus-colour

$nhsuk-focus-colour: nhsuk-colour("yellow") !default;

Description

Focus colour

Used for outline (and background, where appropriate) when interactive elements (links, form controls) have keyboard focus.

Type

Colour

Used by

nhsuk-focus-text-colour

$nhsuk-focus-text-colour: nhsuk-colour("black") !default;

Description

Focused text colour

Ensure that the contrast between the text and background colour passes WCAG Level AA contrast requirements.

Type

Colour

Used by

nhsuk-error-colour

$nhsuk-error-colour: nhsuk-colour("red") !default;

Description

Error colour

Used to highlight error messages and form controls in an error state

Type

Colour

nhsuk-success-colour

$nhsuk-success-colour: nhsuk-colour("green") !default;

Description

Success colour

Used to highlight success messages and banners

Type

Colour

Used by

nhsuk-border-colour

$nhsuk-border-colour: nhsuk-colour("grey-4") !default;

Description

Border colour

Used in for example borders, separators, rules and keylines.

Type

Colour

nhsuk-border-hover-colour

$nhsuk-border-hover-colour: nhsuk-colour("grey-3") !default;

Description

Border hover colour

Type

Colour

nhsuk-secondary-border-colour

$nhsuk-secondary-border-colour: rgba(nhsuk-colour("white"), 0.2) !default;

Description

Secondary border colour

Type

Colour

nhsuk-input-border-colour

$nhsuk-input-border-colour: nhsuk-colour("grey-1") !default;

Description

Form border colour

Used for form inputs and controls

Type

Colour

nhsuk-hover-colour

$nhsuk-hover-colour: nhsuk-colour("grey-3") !default;

Description

Input hover colour

Used for hover states on form controls

Type

Colour

nhsuk-input-background-colour

$nhsuk-input-background-colour: nhsuk-colour("white") !default;

Description

Form element background colour

Type

Colour

nhsuk-button-colour

$nhsuk-button-colour: nhsuk-colour("green") !default;

Description

Button background colour

Type

Colour

nhsuk-button-text-colour

$nhsuk-button-text-colour: nhsuk-colour("white") !default;

Description

Button text colour

Type

Colour

nhsuk-button-hover-colour

$nhsuk-button-hover-colour: nhsuk-shade($nhsuk-button-colour, 20%) !default;

Description

Button background colour (hover)

Type

Colour

nhsuk-button-active-colour

$nhsuk-button-active-colour: nhsuk-shade($nhsuk-button-colour, 50%) !default;

Description

Button background colour (active)

Type

Colour

nhsuk-button-shadow-colour

$nhsuk-button-shadow-colour: nhsuk-shade($nhsuk-button-colour, 50%) !default;

Description

Button shadow colour

Type

Colour

nhsuk-secondary-button-colour

$nhsuk-secondary-button-colour: transparent !default;

Description

Secondary button background colour

Type

Colour

nhsuk-secondary-button-solid-background-colour

$nhsuk-secondary-button-solid-background-colour: nhsuk-colour("white") !default;

Description

Secondary button (solid background) background colour

Type

Colour

nhsuk-secondary-button-border-colour

$nhsuk-secondary-button-border-colour: $nhsuk-brand-colour !default;

Description

Secondary button border colour

Type

Colour

nhsuk-secondary-button-text-colour

$nhsuk-secondary-button-text-colour: $nhsuk-brand-colour !default;

Description

Secondary button text colour

Type

Colour

nhsuk-secondary-button-hover-colour

$nhsuk-secondary-button-hover-colour: nhsuk-tint($nhsuk-secondary-button-border-colour, 85%) !default;

Description

Secondary button background colour (hover)

Type

Colour

nhsuk-secondary-button-active-colour

$nhsuk-secondary-button-active-colour: nhsuk-tint($nhsuk-secondary-button-border-colour, 78%) !default;

Description

Secondary button background colour (active)

Type

Colour

nhsuk-secondary-button-shadow-colour

$nhsuk-secondary-button-shadow-colour: $nhsuk-secondary-button-border-colour !default;

Description

Secondary button shadow colour

Type

Colour

nhsuk-reverse-button-colour

$nhsuk-reverse-button-colour: nhsuk-colour("white") !default;

Description

Reverse button background colour

Type

Colour

nhsuk-reverse-button-text-colour

$nhsuk-reverse-button-text-colour: nhsuk-colour("black") !default;

Description

Reverse button text colour

Type

Colour

nhsuk-reverse-button-hover-colour

$nhsuk-reverse-button-hover-colour: nhsuk-shade($nhsuk-reverse-button-colour, 15%) !default;

Description

Reverse button background colour (hover)

Type

Colour

nhsuk-reverse-button-active-colour

$nhsuk-reverse-button-active-colour: nhsuk-shade($nhsuk-reverse-button-colour, 30%) !default;

Description

Reverse button background colour (active)

Type

Colour

nhsuk-reverse-button-shadow-colour

$nhsuk-reverse-button-shadow-colour: nhsuk-shade($nhsuk-reverse-button-colour, 30%) !default;

Description

Reverse button shadow colour

Type

Colour

nhsuk-warning-button-colour

$nhsuk-warning-button-colour: nhsuk-colour("red") !default;

Description

Warning button background colour

Type

Colour

nhsuk-warning-button-hover-colour

$nhsuk-warning-button-hover-colour: nhsuk-shade($nhsuk-warning-button-colour, 20%) !default;

Description

Warning button background colour (hover)

Type

Colour

nhsuk-warning-button-active-colour

$nhsuk-warning-button-active-colour: nhsuk-shade($nhsuk-warning-button-colour, 50%) !default;

Description

Warning button background colour (active)

Type

Colour

nhsuk-warning-button-shadow-colour

$nhsuk-warning-button-shadow-colour: nhsuk-shade($nhsuk-warning-button-colour, 50%) !default;

Description

Warning button shadow colour

Type

Colour

nhsuk-login-button-colour

$nhsuk-login-button-colour: $nhsuk-brand-colour !default;

Description

Login button background colour

Type

Colour

nhsuk-login-button-hover-colour

$nhsuk-login-button-hover-colour: nhsuk-shade($nhsuk-login-button-colour, 20%) !default;

Description

Login button background colour (hover)

Type

Colour

nhsuk-login-button-active-colour

$nhsuk-login-button-active-colour: nhsuk-shade($nhsuk-login-button-colour, 50%) !default;

Description

Login button background colour (active)

Type

Colour

nhsuk-login-button-shadow-colour

$nhsuk-login-button-shadow-colour: nhsuk-shade($nhsuk-login-button-colour, 50%) !default;

Description

Login button shadow colour

Type

Colour

nhsuk-colours

$nhsuk-colours: (
  // Primary
  "blue": #005eb8,
  "white": #ffffff,
  "black": #212b32,
  "green": #007f3b,
  "purple": #330072,
  "dark-pink": #7c2855,
  "red": #d5281b,
  "yellow": #ffeb3b,

  // Secondary
  "dark-blue": #003087,
  "pale-yellow": #fff9c4,
  "warm-yellow": #ffb81c,
  "orange": #ed8b00,
  "aqua-green": #00a499,
  "pink": #ae2573,

  // Greyscale
  "grey-1": #4c6272,
  "grey-2": #768692,
  "grey-3": #aeb7bd,
  "grey-4": #d8dde0,
  "grey-5": #f0f4f5
) !default;

Description

NHS colour palette

Type

Map

Map structure

Map key NameMap key DescriptionMap key TypeMap key Value
$colour

Representation for the given $colour, where $colour is the friendly name for the colour (e.g. "red": #ff0000);

Map none

Used by

settings/globals

variables

nhsuk-font

$nhsuk-font: "Frutiger W01" !default;

Description

Fonts

  1. Fallback fonts if Frutiger fails to load

nhsuk-base-font-size

$nhsuk-base-font-size: 16px !default;

Description

Font sizing and spacing

Used by

nhsuk-icon-size

$nhsuk-icon-size: 24px !default;

Description

Icon default sizing

nhsuk-page-width

$nhsuk-page-width: 960px !default;

Description

Grid spacing

nhsuk-grid-widths

$nhsuk-grid-widths: (
  one-quarter: math.percentage(math.div(1, 4)),
  one-third: math.percentage(math.div(1, 3)),
  one-half: math.percentage(math.div(1, 2)),
  two-thirds: math.percentage(math.div(2, 3)),
  three-quarters: math.percentage(math.div(3, 4)),
  full: 100%
) !default;

Description

Map of grid column widths

Used by

nhsuk-border-width

$nhsuk-border-width: 4px !default;

Description

Standard border width

Type

Number

nhsuk-border-width-form-element

$nhsuk-border-width-form-element: 2px !default;

Description

Form control border width

Type

Number

Used by

nhsuk-focus-width

$nhsuk-focus-width: 4px !default;

Description

Border width of focus outline

Type

Number

Used by

nhsuk-hover-width

$nhsuk-hover-width: 10px !default;

Description

Hover width for form controls with a hover state

Type

Number

settings/layout

variables

nhsuk-breakpoints

$nhsuk-breakpoints: (
  mobile: 320px,
  tablet: 641px,
  desktop: 769px,
  large-desktop: 990px
) !default;

Description

Breakpoint definitions

nhsuk-show-breakpoints

$nhsuk-show-breakpoints: false !default;

Description

Show active breakpoint in top-right corner.

Only use this during local development.

settings/spacing

variables

nhsuk-spacing-points

$nhsuk-spacing-points: (
  0: 0,
  1: 4px,
  2: 8px,
  3: 16px,
  4: 24px,
  5: 32px,
  6: 40px,
  7: 48px,
  8: 56px,
  9: 64px
) !default;

Description

Single point spacing variables

Used by

Links

nhsuk-spacing-responsive-scale

$nhsuk-spacing-responsive-scale: (
  0: (
    null: 0,
    tablet: 0
  ),
  1: (
    null: 4px,
    tablet: 4px
  ),
  2: (
    null: 8px,
    tablet: 8px
  ),
  3: (
    null: 8px,
    tablet: 16px
  ),
  4: (
    null: 16px,
    tablet: 24px
  ),
  5: (
    null: 24px,
    tablet: 32px
  ),
  6: (
    null: 32px,
    tablet: 40px
  ),
  7: (
    null: 40px,
    tablet: 48px
  ),
  8: (
    null: 48px,
    tablet: 56px
  ),
  9: (
    null: 56px,
    tablet: 64px
  )
) !default;

Description

Responsive spacing map

These definitions are used to generate responsive spacing that adapts according to the breakpoints (see 'tools/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 nhsuk-responsive-margin or nhsuk-responsive-padding mixins.

Used by

Links

settings/typography

variables

nhsuk-typography-scale

$nhsuk-typography-scale: (
  64: (
    null: (
      font-size: 48px,
      line-height: 54px
    ),
    tablet: (
      font-size: 64px,
      line-height: 70px
    ),
    print: (
      font-size: 34pt,
      line-height: 1.1
    )
  ),
  48: (
    null: (
      font-size: 32px,
      line-height: 38px
    ),
    tablet: (
      font-size: 48px,
      line-height: 54px
    ),
    print: (
      font-size: 26pt,
      line-height: 1.15
    )
  ),
  36: (
    null: (
      font-size: 27px,
      line-height: 33px
    ),
    tablet: (
      font-size: 36px,
      line-height: 42px
    ),
    print: (
      font-size: 20pt,
      line-height: 1.2
    )
  ),
  26: (
    null: (
      font-size: 22px,
      line-height: 29px
    ),
    tablet: (
      font-size: 26px,
      line-height: 32px
    ),
    print: (
      font-size: 17pt,
      line-height: 1.25
    )
  ),
  22: (
    null: (
      font-size: 19px,
      line-height: 27px
    ),
    tablet: (
      font-size: 22px,
      line-height: 30px
    ),
    print: (
      font-size: 15pt,
      line-height: 1.25
    )
  ),
  19: (
    null: (
      font-size: 16px,
      line-height: 24px
    ),
    tablet: (
      font-size: 19px,
      line-height: 28px
    ),
    print: (
      font-size: 13pt,
      line-height: 1.25
    )
  ),
  16: (
    null: (
      font-size: 14px,
      line-height: 24px
    ),
    tablet: (
      font-size: 16px,
      line-height: 24px
    ),
    print: (
      font-size: 12pt,
      line-height: 1.3
    )
  ),
  14: (
    null: (
      font-size: 12px,
      line-height: 20px
    ),
    tablet: (
      font-size: 14px,
      line-height: 24px
    ),
    print: (
      font-size: 12pt,
      line-height: 1.3
    )
  )
) !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.

Map structure

key Namekey Descriptionkey Typekey 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

Links

settings/warnings

variables

nhsuk-suppressed-warnings

$nhsuk-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:

Example

// warning message:
//  $foobar is no longer supported. To silence this warning, update
//  $nhsuk-suppressed-warnings with key: "foobar"
$nhsuk-suppressed-warnings: (
  foobar
);

Used by

Links

mixins

nhsuk-warning

@mixin nhsuk-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 $nhsuk-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 $nhsuk-suppressed-warnings after @warn is called to ensure it only runs once per sass compilation

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$key

The key to be checked against $nhsuk-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

Links

tools

variables

imported-modules

$imported-modules: () !default;

Description

List of modules which have already been exported

Used by

mixins

nhsuk-exports

@mixin nhsuk-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

Links

nhsuk-focused-text

@mixin nhsuk-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.

Requires

Used by

Links

nhsuk-focused-input

@mixin nhsuk-focused-input() { ... }

Description

Focused input (form elements)

Provides an additional outline and border to clearly indicate when the target element has focus. Used for interactive input-based elements such as text inputs.

Parameters

None.

Requires

Links

nhsuk-focused-radio

@mixin nhsuk-focused-radio($focus-width: $nhsuk-focus-width + 1px) { ... }

Description

Focused radio input (form element)

Provides an additional outline and border to clearly indicate when the target element has focus. Used by radios.

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$focus-width

Focus width

Number$nhsuk-focus-width + 1px

Requires

Links

nhsuk-focused-checkbox

@mixin nhsuk-focused-checkbox() { ... }

Description

Focused checkbox input (form element)

Provides an additional outline and border to clearly indicate when the target element has focus. Used by checkbox.

Parameters

None.

Requires

Links

nhsuk-focused-button

@mixin nhsuk-focused-button() { ... }

Description

Focused button

Provides an additional outline and background to clearly indicate when the target element has focus. Used for buttons.

Parameters

None.

Requires

Links

nhsuk-focused-box

@mixin nhsuk-focused-box() { ... }

Description

Focused box

Provides an outline to clearly indicate when the target element is focused. Unlike nhsuk-focused-text, which only draws an underline below the element, nhsuk-focused-box draws an outline around all sides of the element. Best used for non-text content contained within links.

Parameters

None.

Requires

Used by

Links

nhsuk-grid-column

@mixin nhsuk-grid-column($width: full, $float: left, $at: desktop) { ... }

Description

Generate grid column styles

Creates a grid column with standard gutter between the columns.

Grid widths are defined in the $nhsuk-grid-widths map.

By default the column width changes from 100% to specified width at the 'desktop' 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 $nhsuk-grid-widths

Stringfull
$float

left | right

Stringleft
$at

mobile | tablet | desktop | any custom breakpoint

Stringdesktop

Example

Default

.nhsuk-grid-column-two-thirds {
  @include nhsuk-grid-column(two-thirds)
}

Customising the breakpoint where width percentage is applied

.nhsuk-grid-column-one-half-at-tablet {
  @include nhsuk-grid-column(one-half, $at: tablet);
}

Customising the float direction

.nhsuk-grid-column-one-half-right {
  @include nhsuk-grid-column(two-thirds, $float: right);
}

Requires

Links

nhsuk-clearfix

@mixin nhsuk-clearfix() { ... }

Description

Clearfix mixin

Parameters

None.

Example

@include nhsuk-clearfix;

nhsuk-reading-width

@mixin nhsuk-reading-width() { ... }

Description

Reading width mixin, add a maximum width to large pieces of content

Parameters

None.

Example

@include nhsuk-reading-width;

nhsuk-visually-hidden

@mixin nhsuk-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

Example

@include nhsuk-visually-hidden;

nhsuk-visually-hidden-focusable

@mixin nhsuk-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

Links

visually-shown

Deprecated!

To be removed in v11.0, use @media queries to apply visually-hidden instead

@mixin visually-shown($display: null, $important: true) { ... }

Description

Show an element visually that has previously been hidden by visually-hidden

For differences between mobile and desktop views, use $display to set the CSS display property

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$display

CSS display property (optional)

Stringnull
$important

Whether to mark as !important

Booleantrue

Requires

nhsuk-top-and-bottom

@mixin nhsuk-top-and-bottom() { ... }

Description

Top and bottom margin mixin, remove the top and bottom margin spacing

Parameters

None.

Example

@include nhsuk-top-and-bottom;

Used by

nhsuk-panel

@mixin nhsuk-panel($panel-background-colour, $panel-text-colour, $panel-border-colour) { ... }

Description

Panel mixin

See components/_panel

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$panel-background-colour

Panel background colour

Colour none
$panel-text-colour

Panel text colour

Colour none
$panel-border-colour

Panel border colour

Colour none

Example

@include nhsuk-panel($nhsuk-brand-colour, $nhsuk-reverse-text-colour, $nhsuk-secondary-border-colour);

Requires

Used by

nhsuk-panel-with-label

@mixin nhsuk-panel-with-label($panel-background-colour, $panel-text-colour, $panel-border-colour) { ... }

Description

Panel with label mixin, inherits panel styling and removes padding top for the label positioning

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$panel-background-colour

Panel background colour

Colour none
$panel-text-colour

Panel text colour

Colour none
$panel-border-colour

Panel border colour

Colour none

Example

@include nhsuk-panel-with-label($nhsuk-brand-colour, $nhsuk-reverse-text-colour, $nhsuk-secondary-border-colour);

Requires

nhsuk-heading-label

@mixin nhsuk-heading-label($heading-background-colour, $heading-text-colour) { ... }

Description

Heading label mixin, adds a tab heading to warning callout, do and don't lists and panel

  1. Background colour to be set on the @include.
  2. Ensures heading appears separate to the body text in high contrast mode.
  3. Text colour to be set on the @include.
  4. Display inline-block so it does not take up the full width.
  5. Negative left margin aligns the heading to the box.
  6. Top positioning set to minus to make heading sit just outside the box.

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$heading-background-colour

Heading background colour

Colour none
$heading-text-colour

Heading text colour

Colour none

Example

@include nhsuk-heading-label($nhsuk-brand-colour, $nhsuk-reverse-text-colour);

Requires

nhsuk-care-card

@mixin nhsuk-care-card($heading-background-colour, $heading-text-colour, $print-border-size) { ... }

Description

Care card mixin, used for creating different coloured care cards

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$heading-background-colour

Heading background colour

Colour none
$heading-text-colour

Heading text colour

Colour none
$print-border-size

Print border size

Number none

Example

@include nhsuk-care-card($nhsuk-brand-colour, $nhsuk-reverse-text-colour, 4px);

Requires

nhsuk-print-colour

@mixin nhsuk-print-colour($print-colour: $nhsuk-print-text-colour) { ... }

Description

Print colour mixin, sets the text print colour warning callout, do and don't lists and panels

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$print-colour

Print colour

Colour$nhsuk-print-text-colour

Example

@include nhsuk-print-colour($print-colour: inherit);

Requires

nhsuk-print-hide

@mixin nhsuk-print-hide() { ... }

Description

Print hide mixin, hides the element from print

Parameters

None.

Example

@include nhsuk-print-hide;

Requires

nhsuk-flex

@mixin nhsuk-flex() { ... }

Description

Flex mixin

Parameters

None.

Example

@include nhsuk-flex;

nhsuk-flex-item

@mixin nhsuk-flex-item() { ... }

Description

Flex item mixin

Parameters

None.

Example

@include nhsuk-flex-item;

Requires

nhsuk-remove-margin-mobile

@mixin nhsuk-remove-margin-mobile() { ... }

Description

Remove margin mobile mixin

Removes left and right margin at tablet breakpoint

Parameters

None.

Requires

nhsuk-logo-size

@mixin nhsuk-logo-size() { ... }

Description

NHS logo size helper

Saves duplicating the code for when using the logo as a link. Used in the header and footer.

Parameters

None.

nhsuk-media-query

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

Description

Media query

This is a currently a wrapper for sass-mq - abstracted so that we can replace it in the future if we so choose.

Due to Sass deprecated 'misplaced-rest' named argument warnings, all arguments must be passed to maintain nhsuk-media-query(950px) support.

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$from

One of $nhsuk-breakpoints

String or Booleanfalse
$until

One of $nhsuk-breakpoints

String or Booleanfalse
$and

Additional media query parameters

String or Booleanfalse
$media-type

Media type: screen, print…

Stringall

Example

.element {
  @include nhsuk-media-query($from: mobile) {
    color: red;
  }
  @include nhsuk-media-query($until: tablet) {
    color: blue;
  }
  @include nhsuk-media-query(mobile, tablet) {
    color: green;
  }
  @include nhsuk-media-query($from: tablet, $and: '(orientation: landscape)') {
    color: teal;
  }
  @include nhsuk-media-query(950px) {
    color: hotpink;
  }
  @include nhsuk-media-query(tablet, $media-type: screen) {
    color: hotpink;
  }
}

Requires

  • [mixin] mq

Used by

Links

nhsuk-shape-arrow

@mixin nhsuk-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}

Links

nhsuk-shape-chevron

@mixin nhsuk-shape-chevron($direction, $colour, $font-size: 14, $display: block) { ... }

Description

Chevron mixin

Generate chevron by using a box with borders on two sides, then rotating it.

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$direction

Direction for chevron: up, right, down, left

String none
$colour

Colour of chevron

Colour none
$font-size

Font size to base chevron size on

Number14
$display

CSS display property of the arrow

Stringblock

Throws

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

Requires

nhsuk-responsive-spacing

@mixin nhsuk-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 'nhsuk-responsive-margin' or 'nhsuk-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

Example

  .foo {
    padding: nhsuk-spacing(5);
    top: nhsuk-spacing(2) !important; // if `!important` is required
  }

1. Make sure that the return value from `_settings/spacing.scss` is a map.
2. Loop through each breakpoint in the map
3. The 'null' breakpoint is for mobile.

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

Links

nhsuk-responsive-margin

@mixin nhsuk-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 nhsuk-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

.foo {
  @include nhsuk-responsive-margin(6, 'left', $adjustment: 1px);
}

Requires

Used by

Links

nhsuk-responsive-padding

@mixin nhsuk-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 nhsuk-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

.foo {
  @include nhsuk-responsive-padding(6, 'left', $adjustment: 1px);
}

Requires

Used by

Links

nhsuk-text-colour

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

Description

Text colour

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

Parameters

None.

Requires

Links

nhsuk-typography-weight-normal

@mixin nhsuk-typography-weight-normal($important: false) { ... }

Description

Normal font weight

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$important

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

Booleanfalse

Used by

nhsuk-typography-weight-bold

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

Description

Bold font weight

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$important

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

Booleanfalse

Used by

nhsuk-text-break-word

@mixin nhsuk-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

nhsuk-font-size

@mixin nhsuk-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 typography 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 typography scale.

Requires

Used by

Links

nhsuk-font

@mixin nhsuk-font($size, $weight: normal, $line-height: false) { ... }

Description

Font helper

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$size

Size of the font as it would appear on desktop - uses the responsive font size map

Number none
$weight

Weight: bold or normal

Stringnormal
$line-height

Line-height, if overriding the default

Numberfalse

Example

.foo {
  @include nhsuk-font(19);
}

.foo {
  @include nhsuk-font(36, $weight: bold);
}

Requires

functions

nhsuk-em

@function nhsuk-em() { ... }

Description

Convert pixels to em

A quick way to convert px into em

Parameters

None.

Example

nhsuk-em(20px, $nhsuk-base-font-size);

Used by

Links

nhsuk-px-to-rem

@function nhsuk-px-to-rem() { ... }

Description

Convert pixels to rem

A quick way to convert px into rem

Parameters

None.

Example

  nhsuk-px-to-rem(20px);

The $nhsuk-base-font-size (defined in settings/_globals.scss)
must be configured to match the font-size of your root (html) element

Requires

Used by

nhsuk-chevron-size

@function nhsuk-chevron-size($font-size: 14) { ... }

Description

Get the size (△↕) of chevron, from base to tip, given a certain font size

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$font-size

Font size to base chevron size on

Number14

Returns

String

Height of chevron as em-based value

Used by

nhsuk-grid-width

@function nhsuk-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

Links

nhsuk-spacing

@function nhsuk-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. 8px

Example

.element {
  padding: nhsuk-spacing(5);
}

Using negative spacing

.element {
  margin-top: nhsuk-spacing(-1);
}

Marking spacing declarations as important

.element {
  margin-top: nhsuk-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

Links

nhsuk-line-height

@function nhsuk-line-height($line-height, $font-size) { ... }

Description

Line height

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

General

variables

mq-breakpoints

$mq-breakpoints: (
  mobile: 320px,
  tablet: 740px,
  desktop: 980px,
  wide: 1300px
) !default;

Description

Breakpoint list

Name your breakpoints in a way that creates a ubiquitous language across team members. It will improve communication between stakeholders, designers, developers, and testers.

Type

Map

Used by

Links

mq-show-breakpoints

$mq-show-breakpoints: () !default;

Description

Show breakpoints in the top right corner

If you want to display the currently active breakpoint in the top right corner of your site during development, add the breakpoints to this list, ordered by width. For example: (mobile, tablet, desktop).

Type

Map

Example

@use 'path/to/mq' with ($mq-show-breakpoints: ('mobile', 'tablet', 'desktop'));

Used by

mq-media-type

$mq-media-type: all !default;

Description

Customize the media type (for example: @media screen or @media print) By default sass-mq uses an "all" media type (@media all and …)

If you want to overried the media type, you can use this option.

Type

String

Example

@use 'path/to/mq' with ($media-type: 'screen');

Used by

  • [mixin] mq

Links

functions

px2em

@function px2em($px) { ... }

Description

Convert pixels to ems

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$px

value to convert

Number none

Returns

Number

Example

$font-size-in-ems: px2em(16px);
p { font-size: px2em(16px); }

Used by

get-breakpoint-width

@function get-breakpoint-width($name) { ... }

Description

Get a breakpoint's width

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$name

Name of the breakpoint. One of $mq-breakpoints

String none

Returns

Number

Value in pixels

Example

$tablet-width: get-breakpoint-width(tablet);
@media (min-width: get-breakpoint-width(tablet)) {}

Requires

Used by

mixins

mq

@mixin mq($from: false, $until: false, $and: false, $media-type: $mq-media-type, $silence-warning: false) { ... }

Description

Media Query mixin

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$from

One of $mq-breakpoints

String or Booleanfalse
$until

One of $mq-breakpoints

String or Booleanfalse
$and

Additional media query parameters

String or Booleanfalse
$media-type

Media type: screen, print…

String$mq-media-type
$silence-warning

Whether to silence deprecation warning to use nhsuk-media-query instead

Booleanfalse

Example

@use 'path/to/mq' as *;
.element {
  @include mq($from: mobile) {
    color: red;
  }
  @include mq($until: tablet) {
    color: blue;
  }
  @include mq(mobile, tablet) {
    color: green;
  }
  @include mq($from: tablet, $and: '(orientation: landscape)') {
    color: teal;
  }
  @include mq(950px) {
    color: hotpink;
  }
  @include mq(tablet, $media-type: screen) {
    color: hotpink;
  }
  // Advanced use:
  $my-breakpoints: (L: 900px, XL: 1200px);
  @include mq(L, $breakpoints: $my-breakpoints) {
    color: hotpink;
  }
}

Requires

Used by

Links

add-breakpoint

@mixin add-breakpoint($name, $width) { ... }

Description

Add a breakpoint

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$name

Name of the breakpoint

String none
$width

Width of the breakpoint

Number none

Example

@include add-breakpoint(tvscreen, 1920px);
@include mq(tvscreen) {}

Requires

show-breakpoints

@mixin show-breakpoints($show-breakpoints: $mq-show-breakpoints, $breakpoints: $mq-breakpoints) { ... }

Description

Show the active breakpoint in the top right corner of the viewport

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$show-breakpoints

List of breakpoints to show in the top right corner

List$mq-show-breakpoints
$breakpoints

Breakpoint names and sizes

Map$mq-breakpoints

Example

// Show breakpoints using global settings
@include show-breakpoints;

// Show breakpoints using custom settings
@include show-breakpoints((L, XL), (S: 300px, L: 800px, XL: 1200px));

Requires

Links