Colour

Stable

Colour tokens store the colour variables for styling elements.

Accessibility

Things to note

  • When choosing and using colours, always check that sufficient colour contrast between the element and its background is maintained. All colour choices should comply with WCAG 2.1 Standard at AA Level contrast ratios.
  • Do not rely solely on colour when communicating information to the user – especially crucial system information like error state, success state, or warnings. Also, convey the same information with another modality, e.g. with a text label or icon that clearly indicates its meaning.

Accessible colour combinations

Here you can find some recommended colour combinations for text and other informative elements. The examples are sorted in order of their contrast ratio. For more examples of accessible colour combinations, see the Colour accessibility examples - Abstract collection.

  • AA (contrast ratio at least 4,5 : 1) and AAA (contrast ratio at least 7 : 1) means you can safely use the color combination on all text sizes
  • AA for large text (contrast ratio at least 3 : 1) means the text size should be at least 18 pt for regular weight or 14 pt for bold weight
  • Black 90 is the default text colour in HDS

Brand colour combinations

Combining a brand colour background with the correct text colour is important to maintain a high contrast.

Table 1: Combining brand colours with a text colour
Colour name (en)Text colour tokenColour contrast (WCAG)Example
Engel--color-black-90AAA 14,3 : 1
AAA
Silver--color-black-90AAA 13,1 : 1
AAA
Bus--color-whiteAAA 12 : 1
AAA
Summer--color-black-90AAA 11,1 : 1
AAA
Fog--color-black-90AAA 10 : 1
AAA
Copper--color-black-90AAA 9,4 : 1
AAA
Suomenlinna--color-black-90AAA 9,1 : 1
AAA
Gold--color-black-90AAA 7,1 : 1
AAA
Brick--color-whiteAA (AAA for large text) 6,1 : 1
AA
Metro--color-black-90AA (AAA for large text) 5,2 : 1
AA
Coat of Arms--color-whiteAA (AAA for large text) 5 : 1
AA
Spåra--color-whiteAA (AAA for large text) 4,6 : 1
AA

For text and other informative elements on white background it is recommended to only use following brand colours:

Table 2: Using brand colours on a white background
Colour name (en)Colour contrast (WCAG)Example
BusAAA 12 : 1
AAA
BrickAA (AAA for large text) 6,1 : 1
AA
Coat of ArmsAA (AAA for large text) 5 : 1
AA
TramAA (AAA for large text) 4,6 : 1
AA
MetroAA for large text 3,3 : 1
A

Grayscale combinations

When using grayscale tokens, be mindful of the contrast. Black tokens below --color-black-50 do not have sufficient contrast on white backgrounds. Lighter blacks can be used on darker backgrounds or as colour of disabled elements.

Table 3: Grayscale contrast
Colour name (en)Text colour tokenColour contrast (WCAG)Example (background)Example (text)
Black--color-whiteAAA 21 : 1
AAA
AAA
Black-90--color-whiteAAA 17,4 : 1
AAA
AAA
Black-80--color-whiteAAA 12,6 : 1
AAA
AAA
Black-70--color-whiteAAA 8,6 : 1
AAA
AAA
Black-60--color-whiteAA (AAA for large text) 5,7 : 1
AAA
AAA
Black-50--color-black-90AA for large text 4,3 : 1
A
A
Black-40--color-black-90AAA 6,1 : 1
AAA
AAA
Black-30--color-black-90AAA 8,2 : 1
AAA
AAA
Black-20--color-black-90AAA 10,8 : 1
AAA
AAA
Black-10--color-black-90AAA 13,8 : 1
AAA
AAA
Black-5--color-black-90AAA 15,4 : 1
AAA
AAA
White--color-black-90AAA 17,4 : 1
AAA
AAA

Focus colour

HDS components use a custom focus colour styling instead of the default browser provided style. The default HDS focus style is 3px wide and accessible on light backgrounds. Since HDS does not offer dark mode, the focus style colour may require customising when using HDS components on darker backgrounds. The white focus colour is recommended if the default colour does not meet the contrast requirement. The WCAG requirement for user interface element contrast is 3 : 1. Additionally, a lighter 2px wide focus style can be used for sub-components where space is limited and a thicker focus might take up too much room.

Table 4: Focus colour contrast
Colour name (en)Background colour tokenColour contrast (WCAG)Example
Coat of Arms--color-whiteAA 5 : 1
White--color-blackAAA 21 : 1

HDS focus style colour can be customised to better fit the theme of the service. However, the implementor must always ensure that the following WCAG requirements are met: