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 Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$colour | Name of colour from the colour palette ( | String or Colour | — none |
Returns
Colour
—Representation of named colour
Throws
Unknown colour
#{$colour}
Requires
- [variable]
nhsuk-colours
- [variable]
nhsuk-colours
Used by
- [function]
nhsuk-colour-compatible
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 Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$colour | The colour to convert or name from the colour palette | String or Colour | — none |
Returns
Colour
Requires
- [function]
nhsuk-colour
Used by
- [function]
nhsuk-shade
- [function]
nhsuk-tint
nhsuk-shade
@function nhsuk-shade($colour, $percentage) { ... }
Description
Make a colour darker by mixing it with black
Parameters
parameter Name | parameter Description | parameter Type | parameter 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
- [function]
nhsuk-colour-compatible
Used by
- [mixin]
nhsuk-link-style-success
- [mixin]
nhsuk-link-style-success
nhsuk-tint
@function nhsuk-tint($colour, $percentage) { ... }
Description
Make a colour lighter by mixing it with white
Parameters
parameter Name | parameter Description | parameter Type | parameter 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
- [function]
nhsuk-colour-compatible
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 Name | parameter Description | parameter Type | parameter 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
- [mixin]
nhsuk-media-query
- [mixin]
nhsuk-media-query
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
- [mixin]
nhsuk-text-colour
nhsuk-reverse-text-colour
$nhsuk-reverse-text-colour: nhsuk-colour("white") !default;
Description
Text colour (reverse)
Type
Colour
Used by
- [mixin]
nhsuk-link-style-white
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
- [mixin]
nhsuk-panel
- [mixin]
nhsuk-care-card
- [mixin]
nhsuk-text-colour
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
- [mixin]
nhsuk-focused-text
- [mixin]
nhsuk-focused-text
- [mixin]
nhsuk-focused-input
- [mixin]
nhsuk-focused-radio
- [mixin]
nhsuk-focused-checkbox
- [mixin]
nhsuk-focused-button
- [mixin]
nhsuk-focused-box
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
- [mixin]
nhsuk-focused-text
- [mixin]
nhsuk-focused-text
- [mixin]
nhsuk-focused-text
- [mixin]
nhsuk-focused-input
- [mixin]
nhsuk-focused-input
- [mixin]
nhsuk-focused-radio
- [mixin]
nhsuk-focused-checkbox
- [mixin]
nhsuk-focused-button
- [mixin]
nhsuk-focused-button
- [mixin]
nhsuk-focused-button
- [mixin]
nhsuk-focused-button
- [mixin]
nhsuk-focused-box
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
- [mixin]
nhsuk-link-style-success
- [mixin]
nhsuk-link-style-success
- [mixin]
nhsuk-link-style-success
- [mixin]
nhsuk-link-style-success
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-link-colour
$nhsuk-link-colour: nhsuk-colour("blue") !default;
Description
Link colour
Type
Colour
Used by
nhsuk-link-visited-colour
$nhsuk-link-visited-colour: nhsuk-colour("purple") !default;
Description
Visited link colour
Type
Colour
nhsuk-link-hover-colour
$nhsuk-link-hover-colour: nhsuk-colour("dark-pink") !default;
Description
Link hover colour
Type
Colour
nhsuk-link-active-colour
$nhsuk-link-active-colour: nhsuk-shade($nhsuk-link-colour, 50%) !default;
Description
Active link 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 Name | Map key Description | Map key Type | Map 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
- [function]
nhsuk-colour
- [function]
nhsuk-colour
settings/globals
variables
nhsuk-font
$nhsuk-font: "Frutiger W01" !default;
Description
Fonts
- Fallback fonts if Frutiger fails to load
nhsuk-base-font-size
$nhsuk-base-font-size: 16px !default;
Description
Font sizing and spacing
Used by
- [function]
nhsuk-px-to-rem
- [mixin]
nhsuk-shape-chevron
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
- [function]
nhsuk-grid-width
- [function]
nhsuk-grid-width
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
- [mixin]
nhsuk-focused-input
- [mixin]
nhsuk-focused-input
nhsuk-focus-width
$nhsuk-focus-width: 4px !default;
Description
Border width of focus outline
Type
Number
Used by
- [mixin]
nhsuk-focused-text
- [mixin]
nhsuk-focused-text
- [mixin]
nhsuk-focused-input
- [mixin]
nhsuk-focused-radio
- [mixin]
nhsuk-focused-radio
- [mixin]
nhsuk-focused-checkbox
- [mixin]
nhsuk-focused-checkbox
- [mixin]
nhsuk-focused-checkbox
- [mixin]
nhsuk-focused-button
- [mixin]
nhsuk-focused-button
- [mixin]
nhsuk-focused-button
- [mixin]
nhsuk-focused-box
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
- [function]
nhsuk-spacing
- [function]
nhsuk-spacing
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
- [mixin]
nhsuk-responsive-spacing
- [mixin]
nhsuk-responsive-spacing
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 Name | key Description | key Type | key Value |
---|---|---|---|
$point.$breakpoint.font-size | Font size for | Number | — none |
$point.$breakpoint.line-height | Line height for | Number | — none |
$point.print.font-size | Font size for | Number | — none |
$point.print.line-height | Line height for | Number | — none |
Used by
- [mixin]
nhsuk-font-size
- [mixin]
nhsuk-font-size
- [mixin]
nhsuk-font-size
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
- [mixin]
nhsuk-warning
- [mixin]
nhsuk-warning
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 Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$key | The key to be checked against | String | — none |
$message | The message to use when calling | String | — none |
$silence-further-warnings | Whether to silence future warnings that use the same $key | Boolean | — none |
Requires
- [variable]
nhsuk-suppressed-warnings
- [variable]
nhsuk-suppressed-warnings
Used by
- [mixin]
visually-shown
- [mixin]
nhsuk-font-size
- [mixin]
mq
Links
tools
variables
imported-modules
$imported-modules: () !default;
Description
List of modules which have already been exported
Used by
- [mixin]
nhsuk-exports
- [mixin]
nhsuk-exports
- [mixin]
nhsuk-exports
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 Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$name | Name of module - must be unique within the codebase | String | — none |
Requires
- [variable]
imported-modules
- [variable]
imported-modules
- [variable]
imported-modules
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
- [variable]
nhsuk-focus-colour
- [variable]
nhsuk-focus-colour
- [variable]
nhsuk-focus-width
- [variable]
nhsuk-focus-text-colour
- [variable]
nhsuk-focus-width
- [variable]
nhsuk-focus-text-colour
- [variable]
nhsuk-focus-text-colour
Used by
- [mixin]
nhsuk-link-style-focus
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
- [variable]
nhsuk-border-width-form-element
- [variable]
nhsuk-focus-text-colour
- [variable]
nhsuk-focus-width
- [variable]
nhsuk-focus-colour
- [variable]
nhsuk-border-width-form-element
- [variable]
nhsuk-focus-text-colour
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 Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$focus-width | Focus width | Number | $nhsuk-focus-width + 1px |
Requires
- [variable]
nhsuk-focus-width
- [variable]
nhsuk-focus-text-colour
- [variable]
nhsuk-focus-width
- [variable]
nhsuk-focus-colour
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
- [variable]
nhsuk-focus-width
- [variable]
nhsuk-focus-text-colour
- [variable]
nhsuk-focus-width
- [variable]
nhsuk-focus-width
- [variable]
nhsuk-focus-colour
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
- [variable]
nhsuk-focus-colour
- [variable]
nhsuk-focus-width
- [variable]
nhsuk-focus-text-colour
- [variable]
nhsuk-focus-text-colour
- [variable]
nhsuk-focus-width
- [variable]
nhsuk-focus-width
- [variable]
nhsuk-focus-text-colour
- [variable]
nhsuk-focus-text-colour
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
- [variable]
nhsuk-focus-width
- [variable]
nhsuk-focus-colour
- [variable]
nhsuk-focus-text-colour
Used by
- [mixin]
nhsuk-link-image
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 Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$width | name of a grid width from $nhsuk-grid-widths | String | full |
$float | left | right | String | left |
$at | mobile | tablet | desktop | any custom breakpoint | String | desktop |
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
- [mixin]
nhsuk-media-query
- [function]
nhsuk-grid-width
Links
nhsuk-link-style
@mixin nhsuk-link-style($link-colour: $nhsuk-link-colour, $link-hover-colour: $nhsuk-link-hover-colour, $link-visited-colour: $nhsuk-link-visited-colour, $link-active-colour: $nhsuk-link-active-colour) { ... }
Description
Link styling with colour overrides
Parameters
parameter Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$link-colour | Link colour | Colour | $nhsuk-link-colour |
$link-hover-colour | Link hover colour | Colour | $nhsuk-link-hover-colour |
$link-visited-colour | Link visited colour | Colour | $nhsuk-link-visited-colour |
$link-active-colour | Link active colour | Colour | $nhsuk-link-active-colour |
Requires
- [mixin]
nhsuk-link-style-visited
- [mixin]
nhsuk-link-style-hover
- [mixin]
nhsuk-link-style-active
- [mixin]
nhsuk-link-style-focus
Used by
- [mixin]
nhsuk-link-style-default
- [mixin]
nhsuk-link-style-success
- [mixin]
nhsuk-link-style-text
nhsuk-link-style-default
@mixin nhsuk-link-style-default() { ... }
Description
Default link styling
Parameters
None.
Example
@include nhsuk-link-style-default;
Requires
- [mixin]
nhsuk-link-style
nhsuk-link-style-white
@mixin nhsuk-link-style-white() { ... }
Description
White link styling, used in hero component, and in the .nhsuk-link--reverse
modifier class.
Parameters
None.
Example
@include nhsuk-link-style-white;
Requires
- [mixin]
nhsuk-link-style-text
- [variable]
nhsuk-reverse-text-colour
nhsuk-link-style-visited
@mixin nhsuk-link-style-visited($link-visited-colour: $nhsuk-link-visited-colour) { ... }
Description
Default link visited only styling
Parameters
parameter Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$link-visited-colour | Link visited colour | Colour | $nhsuk-link-visited-colour |
Example
@include nhsuk-link-style-visited;
Used by
- [mixin]
nhsuk-link-style
- [mixin]
nhsuk-link-style-no-visited-state
nhsuk-link-style-hover
@mixin nhsuk-link-style-hover($link-hover-colour: $nhsuk-link-hover-colour) { ... }
Description
Default link hover only styling
Parameters
parameter Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$link-hover-colour | Link hover colour | Colour | $nhsuk-link-hover-colour |
Example
@include nhsuk-link-style-hover;
Used by
- [mixin]
nhsuk-link-style
nhsuk-link-style-focus
@mixin nhsuk-link-style-focus() { ... }
Description
Default link focus only styling
Parameters
None.
Example
@include nhsuk-link-style-focus;
Requires
- [mixin]
nhsuk-focused-text
Used by
- [mixin]
nhsuk-link-style
nhsuk-link-style-active
@mixin nhsuk-link-style-active($link-active-colour: $nhsuk-link-active-colour) { ... }
Description
Default link active only styling
Parameters
parameter Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$link-active-colour | Link active colour | Colour | $nhsuk-link-active-colour |
Example
@include nhsuk-link-style-active;
Used by
- [mixin]
nhsuk-link-style
nhsuk-link-style-success
@mixin nhsuk-link-style-success() { ... }
Description
Success link styles
Makes links use the success colour. The link will darken if it's active or a user hovers their cursor over it.
If you use this mixin in a component you must also include the nhsuk-link-style-default mixin in order to get the focus state.
Parameters
None.
Example
.nhsuk-component__link {
@include nhsuk-link-style-default;
@include nhsuk-link-style-success;
}
Requires
- [mixin]
nhsuk-link-style
- [function]
nhsuk-shade
- [function]
nhsuk-shade
- [variable]
nhsuk-success-colour
- [variable]
nhsuk-success-colour
- [variable]
nhsuk-success-colour
- [variable]
nhsuk-success-colour
nhsuk-link-style-no-visited-state
@mixin nhsuk-link-style-no-visited-state() { ... }
Description
No visited state link mixin
Used in cases where it is not helpful to distinguish between visited and non-visited links.
For example, navigation links to pages with dynamic content like admin dashboards. The content on the page is changing all the time, so the fact that you’ve visited it before is not important.
If you use this mixin in a component you must also include the nhsuk-link-style-default mixin in order to get the focus state.
Parameters
None.
Example
.nhsuk-component__link {
@include nhsuk-link-style-default;
@include nhsuk-link-style-no-visited-state;
}
Requires
- [mixin]
nhsuk-link-style-visited
- [variable]
nhsuk-link-colour
nhsuk-link-style-text
@mixin nhsuk-link-style-text($override-colour: $nhsuk-text-colour) { ... }
Description
Text link styles
Makes links use the primary text colour, in all states. Use this mixin for navigation components, such as breadcrumbs or the back link.
Parameters
parameter Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$override-colour | Link colour for all states | Colour | $nhsuk-text-colour |
Example
.nhsuk-component__link {
@include nhsuk-link-style-text;
}
Requires
- [mixin]
nhsuk-link-style
Used by
- [mixin]
nhsuk-link-style-white
nhsuk-link-image
@mixin nhsuk-link-image() { ... }
Description
Image link styles
Prepares and provides the focus state for links that only contain images with no accompanying text.
Parameters
None.
Requires
- [mixin]
nhsuk-focused-box
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;
visually-shown
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 Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$display | CSS display property (optional) | String | null |
$important | Whether to mark as | Boolean | true |
Requires
- [mixin]
nhsuk-warning
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
- [mixin]
nhsuk-panel
nhsuk-panel
@mixin nhsuk-panel($panel-background-colour, $panel-text-colour, $panel-border-colour) { ... }
Description
Panel mixin
See components/_panel
Parameters
parameter Name | parameter Description | parameter Type | parameter 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
- [mixin]
nhsuk-top-and-bottom
- [mixin]
nhsuk-responsive-margin
- [mixin]
nhsuk-media-query
- [variable]
nhsuk-print-text-colour
Used by
- [mixin]
nhsuk-panel-with-label
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 Name | parameter Description | parameter Type | parameter 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
- [mixin]
nhsuk-panel
- [mixin]
nhsuk-responsive-margin
- [mixin]
nhsuk-responsive-padding
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
- Background colour to be set on the @include.
- Ensures heading appears separate to the body text in high contrast mode.
- Text colour to be set on the @include.
- Display inline-block so it does not take up the full width.
- Negative left margin aligns the heading to the box.
- Top positioning set to minus to make heading sit just outside the box.
Parameters
parameter Name | parameter Description | parameter Type | parameter 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
- [mixin]
nhsuk-font-size
- [mixin]
nhsuk-media-query
- [function]
nhsuk-spacing
- [function]
nhsuk-spacing
- [function]
nhsuk-spacing
- [function]
nhsuk-spacing
- [function]
nhsuk-spacing
- [function]
nhsuk-spacing
- [function]
nhsuk-spacing
- [function]
nhsuk-spacing
- [function]
nhsuk-spacing
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 Name | parameter Description | parameter Type | parameter 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
- [variable]
nhsuk-print-text-colour
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 Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$print-colour | Print colour | Colour | $nhsuk-print-text-colour |
Example
@include nhsuk-print-colour($print-colour: inherit);
Requires
- [mixin]
nhsuk-media-query
nhsuk-print-hide
@mixin nhsuk-print-hide() { ... }
Description
Print hide mixin, hides the element from print
Parameters
None.
Example
@include nhsuk-print-hide;
Requires
- [mixin]
nhsuk-media-query
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
- [mixin]
nhsuk-media-query
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
- [mixin]
nhsuk-media-query
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 Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$from | One of $nhsuk-breakpoints | String or Boolean | false |
$until | One of $nhsuk-breakpoints | String or Boolean | false |
$and | Additional media query parameters | String or Boolean | false |
$media-type | Media type: screen, print… | String | all |
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
- [mixin]
nhsuk-width-container
- [mixin]
nhsuk-width-container
- [mixin]
nhsuk-grid-column
- [mixin]
nhsuk-panel
- [mixin]
nhsuk-heading-label
- [mixin]
nhsuk-print-colour
- [mixin]
nhsuk-print-hide
- [mixin]
nhsuk-flex-item
- [mixin]
nhsuk-remove-margin-mobile
- [mixin]
nhsuk-responsive-spacing
- [mixin]
nhsuk-text-colour
- [mixin]
nhsuk-font-size
- [mixin]
nhsuk-font-size
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 Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$direction | Direction for arrow: up, right, down, left. | String | — none |
$base | Length of the triangle 'base' side | Number | — none |
$height | Height of triangle. Omit for equilateral. | Number | null |
$display | CSS display property of the arrow | String | block |
Throws
Invalid arrow direction: expected
up
,right
,down
orleft
, 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 Name | parameter Description | parameter Type | parameter 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 | Number | 14 |
$display | CSS display property of the arrow | String | block |
Throws
Invalid arrow direction: expected
up
,right
,down
orleft
, got#{$direction}
Requires
- [function]
nhsuk-em
- [function]
nhsuk-em
- [function]
nhsuk-em
- [function]
nhsuk-chevron-size
- [variable]
nhsuk-base-font-size
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 Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$responsive-spacing-point | Point on the responsive spacing scale, corresponds to a map of breakpoints and spacing values | Number | — none |
$property | Property to add spacing to (e.g. 'margin') | String | — none |
$direction | Direction to add spacing to ( | String | all |
$important | Whether to mark as | Boolean | false |
$adjustment | Offset to adjust spacing by | Number | false |
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
- [mixin]
nhsuk-media-query
- [variable]
nhsuk-spacing-responsive-scale
- [variable]
nhsuk-spacing-responsive-scale
Used by
- [mixin]
nhsuk-responsive-margin
- [mixin]
nhsuk-responsive-padding
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 Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$responsive-spacing-point | Point on the responsive spacing scale, corresponds to a map of breakpoints and spacing values | Number | — none |
$direction | Direction to add spacing to ( | String | all |
$important | Whether to mark as | Boolean | false |
$adjustment | Offset to adjust spacing by | Number | false |
Example
.foo {
@include nhsuk-responsive-margin(6, 'left', $adjustment: 1px);
}
Requires
- [mixin]
nhsuk-responsive-spacing
Used by
- [mixin]
nhsuk-panel
- [mixin]
nhsuk-panel-with-label
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 Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$responsive-spacing-point | Point on the responsive spacing scale, corresponds to a map of breakpoints and spacing values | Number | — none |
$direction | Direction to add spacing to ( | String | all |
$important | Whether to mark as | Boolean | false |
$adjustment | Offset to adjust spacing | Number | false |
Example
.foo {
@include nhsuk-responsive-padding(6, 'left', $adjustment: 1px);
}
Requires
- [mixin]
nhsuk-responsive-spacing
Used by
- [mixin]
nhsuk-panel-with-label
Links
nhsuk-text-colour
@mixin nhsuk-text-colour() { ... }
Description
Text colour
Sets the text colour, including a suitable override for print.
Parameters
None.
Requires
- [mixin]
nhsuk-media-query
- [variable]
nhsuk-text-colour
- [variable]
nhsuk-print-text-colour
Links
nhsuk-typography-weight-normal
@mixin nhsuk-typography-weight-normal($important: false) { ... }
Description
Normal font weight
Parameters
parameter Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$important | Whether to mark declarations as | Boolean | false |
Used by
- [mixin]
nhsuk-font
nhsuk-typography-weight-bold
@mixin nhsuk-typography-weight-bold($important: false) { ... }
Description
Bold font weight
Parameters
parameter Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$important | Whether to mark declarations as | Boolean | false |
Used by
- [mixin]
nhsuk-font
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 Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$important | Whether to mark declarations as | Boolean | false |
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 Name | parameter Description | parameter Type | parameter 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. | Number | false |
$important | Whether to mark declarations as | Boolean | false |
Throws
Unknown font size
#{$size}
- expected a point from the typography scale.
Requires
- [mixin]
nhsuk-warning
- [mixin]
nhsuk-media-query
- [mixin]
nhsuk-media-query
- [function]
nhsuk-px-to-rem
- [function]
nhsuk-line-height
- [variable]
nhsuk-typography-scale
- [variable]
nhsuk-typography-scale
- [variable]
nhsuk-typography-scale
Used by
- [mixin]
nhsuk-heading-label
- [mixin]
nhsuk-font
Links
nhsuk-font
@mixin nhsuk-font($size, $weight: normal, $line-height: false) { ... }
Description
Font helper
Parameters
parameter Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$size | Size of the font as it would appear on desktop - uses the responsive font size map | Number | — none |
$weight | Weight: | String | normal |
$line-height | Line-height, if overriding the default | Number | false |
Example
.foo {
@include nhsuk-font(19);
}
.foo {
@include nhsuk-font(36, $weight: bold);
}
Requires
- [mixin]
nhsuk-typography-weight-normal
- [mixin]
nhsuk-typography-weight-bold
- [mixin]
nhsuk-font-size
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
- [mixin]
nhsuk-shape-chevron
- [mixin]
nhsuk-shape-chevron
- [mixin]
nhsuk-shape-chevron
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
- [variable]
nhsuk-base-font-size
Used by
- [mixin]
nhsuk-font-size
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 Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$font-size | Font size to base chevron size on | Number | 14 |
Returns
String
—Height of chevron as em-based value
Used by
- [mixin]
nhsuk-shape-chevron
nhsuk-grid-width
@function nhsuk-grid-width($key) { ... }
Description
Grid width percentage
Parameters
parameter Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$key | Name of grid width (e.g. two-thirds) | String | — none |
Returns
Number
—Percentage width
Throws
Unknown grid width
#{$key}
Requires
- [variable]
nhsuk-grid-widths
- [variable]
nhsuk-grid-widths
Used by
- [mixin]
nhsuk-grid-column
Links
nhsuk-spacing
@function nhsuk-spacing($spacing-point) { ... }
Description
Single point spacing
Returns measurement corresponding to the spacing point requested.
Parameters
parameter Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$spacing-point | Point on the spacing scale (set in | Number | — none |
Returns
String
—Spacing measurement eg. 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
- [variable]
nhsuk-spacing-points
- [variable]
nhsuk-spacing-points
Used by
- [mixin]
nhsuk-heading-label
- [mixin]
nhsuk-heading-label
- [mixin]
nhsuk-heading-label
- [mixin]
nhsuk-heading-label
- [mixin]
nhsuk-heading-label
- [mixin]
nhsuk-heading-label
- [mixin]
nhsuk-heading-label
- [mixin]
nhsuk-heading-label
- [mixin]
nhsuk-heading-label
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 Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$line-height | Line height | Number | — none |
$font-size | Font size | Number | — none |
Returns
Number
—The line height as either a relative value or unmodified
Used by
- [mixin]
nhsuk-font-size
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
- [function]
get-breakpoint-width
- [mixin]
mq
- [mixin]
add-breakpoint
- [mixin]
show-breakpoints
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
- [mixin]
show-breakpoints
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 Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$px | value to convert | Number | — none |
Returns
Number
Example
$font-size-in-ems: px2em(16px);
p { font-size: px2em(16px); }
Used by
- [mixin]
mq
- [mixin]
show-breakpoints
get-breakpoint-width
@function get-breakpoint-width($name) { ... }
Description
Get a breakpoint's width
Parameters
parameter Name | parameter Description | parameter Type | parameter 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
- [variable]
mq-breakpoints
Used by
- [mixin]
mq
- [mixin]
show-breakpoints
mixins
mq
@mixin mq($from: false, $until: false, $and: false, $media-type: $mq-media-type, $silence-warning: false) { ... }
Description
Media Query mixin
Parameters
parameter Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$from | One of $mq-breakpoints | String or Boolean | false |
$until | One of $mq-breakpoints | String or Boolean | false |
$and | Additional media query parameters | String or Boolean | false |
$media-type | Media type: screen, print… | String | $mq-media-type |
$silence-warning | Whether to silence deprecation warning to use nhsuk-media-query instead | Boolean | false |
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
- [mixin]
nhsuk-warning
- [variable]
mq-media-type
- [variable]
mq-breakpoints
- [function]
px2em
- [function]
get-breakpoint-width
Used by
- [mixin]
nhsuk-media-query
- [mixin]
show-breakpoints
Links
add-breakpoint
@mixin add-breakpoint($name, $width) { ... }
Description
Add a breakpoint
Parameters
parameter Name | parameter Description | parameter Type | parameter 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
- [variable]
mq-breakpoints
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 Name | parameter Description | parameter Type | parameter 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
- [mixin]
mq
- [function]
get-breakpoint-width
- [function]
px2em
- [variable]
mq-breakpoints
- [variable]
mq-show-breakpoints