Overriding UI elements

Authenticators providing UI implement the same pattern regarding styling. It is possible to style a single authenticator and/or use a global pattern making all authenticators use the same styles.

Making the authenticator read the updated files

In order to make the authenticator read the custom file instead of the default file the configuration parameter overlay_dir must be used on each authenticator.

Add parameter "overlay_dir":<path_to_custom_directory>.

In the custom directory create a folder, "assets", and place the updated file. Restart system.

It is possible to use the same override file for multiple authenticators.

Favicon

in the assets folder of your overlay_dir, place the favicon.ico.

All of the authenticator frontend/UI applications use the same type of configuration files.

The preferred way of configuring the files is using the overlay_dir.

css_overrides.css

Configure the css_overrides.css file in the assets/ folder of your overlay_dir

The file is empty by default. To override the css variables used in the applications see all the default values below. Note, if you wish to only override for example the button background color you do not need to include the rest of the variables.

  • Colors need to be in HSL format. To convert between hex/rgb to hsl, use an online tool like https://convertacolor.com/

  • Do not include the color space, hsl() when defining your custom color.

  • Use space-separated syntax, not commas between values. So 336deg 86% 60% without commas

  • For example, to use this pink color hsl(336deg 86% 60%) as button background set the variable as

:root {
  --color-button-background: 336deg 86% 60%;
}

Default values/available variables

@font-face {
  font-family: 'Inter';
  font-weight: 100 900;
  font-display: fallback;
  font-style: normal;
  font-named-instance: 'Regular';
  src: url('fonts/Inter/Inter-roman.var.woff2') format('woff2');
}

:root {
  --color-primary: 188deg 95% 16%;
  --color-accent: 157deg 100% 40%;

  --color-background: 242deg 34% 14%;
  --color-surface: 0deg 0% 100%;
  --color-backface: 0deg 0% 96%;
  --color-on-primary: 0deg 0% 100%;
  --color-on-surface: var(--color-primary);

  --color-button-background: 242deg 34% 14%;
  --color-button-background-hover: 242deg 34% 20%;
  --color-button-text: 0deg 0% 100%;
  --color-button-text-hover: 0deg 0% 90%;
  --color-link: 188deg 93% 22%;
  --color-link-hover: 188deg 93% 30%;

  --button-radius: 0rem;

  --background-image: url('bg_login.svg') no-repeat center center/cover fixed;
  --background-fallback-color: var(--color-background);
  --fonts-font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI',
    Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji',
    'Segoe UI Symbol';
}
html {
  font-family: var(--fonts-font-family);
  color: hsl(var(--color-on-surface));
  background-color: hsl(--background-fallback-color);
  background: var(--background-image);
}

@media (min-width: 521px) and (max-height: 915px) {
  :root {
    font-size: 95%;
  }
}
@media (min-width: 521px) and (max-height: 880px) {
  :root {
    font-size: 90%;
  }
}
@media (min-width: 521px) and (max-height: 830px) {
  :root {
    font-size: 85%;
  }
}
@media (min-width: 521px) and (max-height: 760px) {
  :root {
    font-size: 82%;
  }
}

Examples

Example: To update the button backgrounds define in your css_overrides.css:

:root {
  --color-button-background: 242deg 34% 14%;
  --color-button-background-hover: 242 34% 20%;
  --color-button-text: 0deg 0% 100%;
  --color-button-text-hover: 0deg 0% 90%;
}

Example: To change background image

Make sure image is available in the assets folder (using the overlay method preferably) and define in your css_overrides.css

:root {
  --background-image: url('new_background_image.png') no-repeat center center fixed;
}

ui_config_overrides.json

Configure the ui_config_overrides.json. Use overlay to provide the custom file and place the file in <overlay_dir>/assets/ui_config_overrides.json. The data in ui_config_overrides.json will be merged with the default values (below)

Customizing translations

There are two possible ways to customize the locale files, either by

  1. Overlaying locale files completely, providing all translation keys.

  2. Merging the default locale file with a custom file. The default file will be merged with the custom file, with the keys in the custom file taking precedence.

Add more languages

Default provided languages are English and Swedish. Language files must be present in <overlay_dir>/assets/locales/ E.g. assets/locales/en.json

To add more languages add to the array in supportedLanguages and place file (using overlay method) in locales folder. E.g. add the following to the supportedLanguages array {code: 'de', name: 'Deutsch'} and add a file called assets/locales/de.json

Custom translation keys

To customize translations the files can be overlayed to specify different complete file with all translation keys, or use localesMergePath to extend and merge with the provided default files.

Useful when overriding specific translation keys only, and not having to provide all translation keys.

If one single file is used for multiple authenticators/applications, where you define all strings to be overridden in the same file, you can either 1. use the same overlay_dir for all authenticators/applications, or, 2. use /authn/assets/locales/ and overlay there.

Exemple of custom extension/merge:

Default language file contains the translations keys

{
    "selector.header": "Choose authentication method",
    "selector.error": "An error occured",
    "change_language": ""
}

The overlay_dir contains a ui_config_overrides.json with localesMergePath: "assets/custom_locales/" (see ui_config_overrides above)

A file is placed in <overlay_dir>/assets/custom_locales/en.json containing the following:

{
    "selector.header": "A different header"
}

The resulting merged language file used in the application will contain the following:

{
    "selector.header": "A different header",
    "selector.error": "An error occured",
    "change_language": ""
}

For each language that will be customized, add language files <overlay_dir>/assets/custom_locales/<lang>.json

Last updated