XUND
Guides

Colours

Use your own colours, turn on dark mode, and see how the colours that XUND set up for your app work with them.

The app shows every colour from one of 56 colour keys. You can set each key separately for the light and the dark colour scheme. With the JS API, you set the colour scheme and your own colours. With the script embed, you set only the colour scheme. The Colour keys reference lists every key with its defaults and the elements that it paints.

The examples on this page use await; run them inside an async function or a <script type="module">.

What you can customise

OptionJS APIScript embed
Colour scheme: light, dark or autocustomization.colorSchemecolor-scheme attribute
Change the colour scheme while the app runsxundApp.setColorScheme()—
Your own light colourscustomization.colors.light—
Your own dark colourscustomization.colors.dark—

Quick start

Set your brand colour and turn on the automatic colour scheme:

const xundApp = await XUND.scic.init({
  …,
  customization: {
    colorScheme: 'auto',
    colors: {
      light: { primary: '#00857c', heading: '#00524c' },
      dark: { primary: '#4fd1c5', onPrimary: '#06201d' },
    },
  },
})

xundApp.setColorScheme('dark')
  • colors.light and colors.dark are both optional. Each one is an object of colour keys to CSS colours.
  • A key that you do not set keeps its default, or it follows the key that it depends on — see Keys follow other keys.
  • colorScheme is light when you do not set it. Thus dark mode is off until you turn it on.

With the script embed, set only the colour scheme:

<script … color-scheme="auto"></script>

The script embed does not support colors.

Start with these keys

Most other keys follow a small set of keys. Set these first, then check the result:

KeyWhat it is
primaryYour brand colour. Buttons, titles, sliders, the progress line and icons follow it.
onPrimaryText and icons on primary.
backgroundThe page behind the app.
surfaceThe card with the questions and the report. The header and the button backgrounds follow it.
textBody text. The labels of outlined buttons follow it.
textMutedDe-emphasised text, placeholders and the labels of the next steps.
headingQuestion titles, dialog titles and the labels of the reached steps.
borderBorders and dividers. In light mode, the borders of input fields and outlined buttons follow it.
danger, warning, successThe emergency, caution and positive colours.

The example below sets only primary, onPrimary, background, surface, text, textMuted, heading and border. The example has no set-up colours. The keys progressFill, buttonConfirmBackground, buttonSecondaryBorder and icon are not set. They follow primary.

LightDark
A pain-scale question with a teal brand colour in light mode. Labels show the keys primary, heading, surface, background, progressFill, icon, buttonSecondaryBorder and buttonConfirmBackground.The same question with the dark teal colours. The same keys are labelled.

What each core colour changes

Each picture shows one screen of the app. In the picture, one key has a test colour. A box marks each area that changed. The label on the box gives the key name.

  • Select a box or a key name below a picture to open the key in the Colour keys reference.
  • The test colours are not recommended colours. They only show which areas change.
  • When you set a key, the keys that follow it change too. Thus a picture can show more areas than the key description lists. See Keys follow other keys.

primary

The start screen with a pink test colour for primary. Setting primary changes: the page title Hello!, the two card titles, the Start Symptom Check and Start Illness Check buttons, the menu icon in the header, and the light band behind the cards.
Keys in this picture: primary

onPrimary

The start screen with a test colour for onPrimary. Setting onPrimary changes: the labels of the Start Symptom Check and Start Illness Check buttons.
Keys in this picture: onPrimary

background

The start screen with a light green test colour for background. Setting background changes: the page area behind the header, the cards and the light band.
Keys in this picture: background

surface

A pain-scale question with a light test colour for surface. Setting surface changes: the header bar and the card with the question.
Keys in this picture: surface

surfaceRaised

The Imprint dialog with a light pink test colour for surfaceRaised. Setting surfaceRaised changes: the background of the dialog.
Keys in this picture: surfaceRaised

text

The top of a report with a pink test colour for text. Setting text changes: the text of the urgency box, the Sex, Age and Main symptom cards, the illness name and its explanations, the Possible label and the Hide details button.
Keys in this picture: text

textMuted

The Imprint dialog with a pink test colour for textMuted. Setting textMuted changes: the close icon of the dialog and the note about the printed instructions for use.
Keys in this picture: textMuted

heading

A pain-scale question with a pink test colour for heading. Setting heading changes: the question title and the labels of the reached steps in the header, 1. Profile and 2. Symptoms.
Keys in this picture: heading

border

A single-choice question with a pink test colour for border. Setting border changes: the borders of the answer buttons Male and Female.
Keys in this picture: border

focusRing

A pain-scale question. The Confirm button has keyboard focus. Setting focusRing to a pink test colour changes: the focus outline around the Confirm button.
Keys in this picture: focusRing

danger

The emergency screen with a purple test colour for danger. Setting danger changes: the Potential emergency box at the top of the card, the title Symptoms related to this emergency, and the list of emergency symptoms. The title and the list use dangerText, which follows danger in light mode.
Keys in this picture: danger

All core keys in light and dark mode

In these pictures, all core keys have a test colour at the same time. The first picture shows light mode. The second picture shows dark mode.

The top of a report in light mode. Each core key has its own test colour: primary for the section titles, the progress line and the probability bar; background for the page; surface for the header and the report card; surfaceRaised for an icon disc; text for the body text; heading for the step labels; border for the Hide details button; danger for the emergency boxes.
Keys in this picture: primary, background, surface, surfaceRaised, text, heading, border, danger
The same report in dark mode with the core test colours in colors.dark. The same areas change as in light mode. The border of the Hide details button does not change, because in dark mode it does not follow border.
Keys in this picture: primary, background, surface, surfaceRaised, text, heading, danger

Keys follow other keys

When you set a key, the keys that follow it change too, unless you set them yourself. For example, in light mode these keys follow primary: primarySubtle, link, linkHover, highlight, controlBorderFocus, focusRing, icon, headerIcon, sideMenuBackground, progressFill, buttonConfirmBackground, buttonSecondaryBorder and buttonSecondaryText.

The When not set column of the Colour keys reference shows what each key follows. The light and the dark scheme can have different rules. For example, link follows primary in light mode, but it has its own value in dark mode.

focusRing is calculated. It is primary when primary has a contrast of at least 3:1 against surface. Otherwise it is text. Thus the keyboard focus outline stays visible when your brand colour is very light. In the side menu, the focus outline uses sideMenuText, not focusRing.

Accepted values

Each value is a CSS colour in one of these formats:

FormatExamples
Hex with 3, 4, 6 or 8 digits#0a7, #0a7c, #00aa77, #00aa77cc
rgb() and rgba()rgb(0, 170, 119), rgba(0, 170, 119, 0.5), rgb(0 170 119 / 50%)
hsl() and hsla()hsl(162, 100%, 33%), hsla(162, 100%, 33%, 0.5), hsl(162deg 100% 33%)
Keywordstransparent, white, black
  • Hex digits can be upper case or lower case.
  • In rgb(), a channel is a number from 0 to 255 or a percentage. The opacity is a number from 0 to 1 or a percentage.
  • In hsl(), the hue is a number with or without deg. Saturation and lightness must be percentages.
  • Other colour names, for example red, are not accepted.
  • A value can have a maximum of 64 characters. The app removes spaces at the start and at the end.

Console messages

An invalid entry does not stop the app. The app ignores the entry and the key keeps its default. The app writes a message to the browser console of your page:

InputLevelMessage
An unknown keywarning[XUND web app] Unknown colour "brandColor" in colors.light, it is ignored. Valid colours: primary, onPrimary, …
An invalid valueerror[XUND web app] Invalid colour for colors.light.primary: "#12"
An unknown colour setwarning[XUND web app] Unknown colour set "darkMode" in colors. Use 'light' or 'dark'.
colors is not an objecterror[XUND web app] colors must be an object with a light and/or a dark colour set.
colors.light or colors.dark is not an objecterror[XUND web app] colors.light must be an object of colour names to CSS colours.
An invalid colour schemeerror[XUND web app] Invalid colorScheme "night". Use 'light', 'dark' or 'auto'.

The warning for an unknown key lists all 56 valid keys. A value that is not a string shows without quotes in the message.

Where the colours come from

The app combines three layers, key by key. A later layer wins over an earlier layer:

  1. The XUND defaults. The built-in light and dark colours.
  2. The colours that XUND set up for your app. Light mode only. Ask XUND which colours were set up for your app.
  3. Your colours from the JS API. customization.colors.light and customization.colors.dark.

In dark mode, the app does not use layer 2. It starts from the XUND dark colours and then applies colors.dark.

Set the related keys too if XUND set up colours for your app. Each set-up colour is a fixed value for its key. It does not follow your primary from the JS API. For example, if XUND set up a colour for buttonConfirmBackground, the Confirm button keeps this colour when you set primary. To change the button, also set buttonConfirmBackground in colors.light.

Dark mode

Dark mode uses the XUND dark colours. Dark mode is off when you do not set a colour scheme.

Turn it on

ValueResult
lightThe light colours. This is the default.
darkThe dark colours.
autoThe app follows the colour setting of the device. When the user changes this setting, the app changes immediately.
  • JS API: set customization.colorScheme.
  • Script embed: set the color-scheme attribute.
  • JS API: call xundApp.setColorScheme('light' | 'dark' | 'auto') while the app runs, for example from the theme switch of your page. You can call it immediately after init. It also works when you did not set colorScheme.

If the value is not light, dark or auto, the app writes an error to the console. With setColorScheme(), the app then keeps the current colour scheme.

Adjust the dark colours

Set your dark colours in colors.dark:

const xundApp = await XUND.scic.init({
  …,
  customization: {
    colorScheme: 'auto',
    colors: {
      dark: { primary: '#4fd1c5', onPrimary: '#06201d', logoBackdrop: '#ffffff' },
    },
  },
})
  • Set your brand colour for dark mode. The app does not calculate dark colours from your light colours or from your set-up colours.
  • Use a lighter brand colour for dark mode than for light mode. If your brand colour is light, use a dark onPrimary.
  • danger, warning and success have the same default fills in both schemes. Thus the urgency levels look the same.
  • The XUND logo changes to its white version in dark mode. The app shows your own logo as it is. If your logo has dark ink, give it a light background with logoBackdrop.
  • Images that need a light background (the CE mark, the Thieme logo, partner-service images) show on imageBackdrop. In dark mode, its default is a light colour.
  • The map in Health solutions uses a dark map style in dark mode.

The XUND defaults in light and dark mode:

LightDark
The top of a Symptom Check report with the XUND light colours: a light header card, the red Potential emergency box and a blue section title.The same report with the XUND dark colours. The red emergency fill is the same as in light mode.

Examples

Each example below sets only a small number of keys. All other keys keep their default, or they follow the keys that are set. Copy the colors entry into customization. Then change the values to your brand colours.

All texts in these examples have a contrast of at least 4.5:1 (WCAG AA). The keyboard focus outline has a contrast of at least 3:1.

Calm green

A calm green brand colour on a light green page. In dark mode, the surfaces have a dark green tint.

LightDark
The start screen in light mode with a green page title, green card titles and green Start buttons on a light green page.The start screen in dark mode with light green titles and light green Start buttons with dark labels on dark green surfaces.
A pain-scale question in light mode with a green progress line, a green slider and a green Confirm button.The same question in dark mode with a light green progress line, slider and Confirm button on a dark green card.
colors: {
  light: { primary: '#2f7d5b', heading: '#1f5a40', background: '#eef5f1' },
  dark: { primary: '#6fcf9f', onPrimary: '#0b1f15', heading: '#c9f0dc', background: '#0e1714', surface: '#16211d', surfaceRaised: '#1d2a25', border: '#2c3d36', surfaceSubtle: '#121c19' },
}

Deep purple

A deep purple brand colour on a light lavender page. In dark mode, the surfaces have a dark purple tint.

LightDark
The top of a report in light mode with purple section titles and a purple progress line on a light lavender page.The same report in dark mode with light purple section titles on dark purple surfaces. The red emergency box does not change.
The start screen in light mode with the side menu open. The side menu is purple with white labels.The same screen in dark mode with the side menu open on dark purple surfaces.
colors: {
  light: { primary: '#5b3fa6', heading: '#3d2a75', background: '#f4f1fa', border: '#ddd5ee' },
  dark: { primary: '#b7a3f5', onPrimary: '#1a1033', heading: '#e6ddff', background: '#120e1d', surface: '#1c1630', surfaceRaised: '#251d3d', border: '#3a3058', surfaceSubtle: '#171228' },
}

Warm coral

A warm orange brand colour on a light peach page. In dark mode, the surfaces have a dark brown tint.

LightDark
The Health solutions list in light mode with three sample results and orange icons.The same list in dark mode with orange icons on dark brown cards.
A single-choice question in light mode with a dark orange question title and the answers Male and Female.The same question in dark mode with a light peach question title on a dark brown card.
colors: {
  light: { primary: '#c2410c', heading: '#7c2d12', background: '#fdf5f0', border: '#f0dccf' },
  dark: { primary: '#fb923c', onPrimary: '#2a1205', heading: '#fde3d1', background: '#17110e', surface: '#221915', surfaceRaised: '#2b201b', border: '#433229', surfaceSubtle: '#1c1411' },
}

Good to know

  • Check the contrast of each pair that you set, for example onPrimary on primary, text and textMuted on surface, and onStatus on danger. For text, use a contrast of at least 4.5:1 (WCAG AA).
  • In light mode, background is transparent by default, so your page shows through behind the app. To get an opaque page, set background.
  • If XUND set up a background image for your app, the app shows the image. A set-up background colour sets background.

For the complete list of keys, see Colour keys.

Last updated on

On this page