---
sourceDocument: Brazil Build or modify applications
sourceDocumentLink: https://www.servicenow.com/docs/r/application-development

 Release :

    - brazil

ft:locale :

    - en-US

ft:publication_title :

    - Brazil Build or modify applications

ft:clusterId :

    - cadev

bundleId :

    - cadev

workflow :

    - Development, Data, and Analytics


---

# theme.js configuration reference

# theme.js configuration reference {#ariaid-title1}

Release version: Brazil  
Updated September 29, 2026  
![](https://www.servicenow.com/docs/portal-asset/ico-clock) 4 minutes to read
Summarize  
![AI sparkle icon](https://servicenow.com/docs/portal-asset/ai-sparkle-icon) Summarized using AI  
This content was generated using new OpenAI-powered functionality. Results are provided on an as is basis and are not guaranteed to be accurate or complete.  

## Summary of theme.js configuration reference

Thetheme.jsfile in a Lux application defines your application's branding by specifying base colors, shape radii, fonts, and logos in a single root-level file.
This approach centralizes branding so that the framework automatically generates all color, radius, and font tokens used across components, enabling consistent styling and easy restyling without modifying individual component CSS.
Show full answer Show less  
ServiceNow customers use their own application-level `theme.js` file (not the framework's internal token definitions) to control key brand inputs that propagate throughout the UI.

## Key Features

* **Brand inputs:** Define `primarycolor`, `accentcolor`, `neutralcolors`, shape radii (`selectorradius`, `fieldradius`, `boxesradius`, `borderwidth`), fonts, logos, favicons, and `tokenoverrides`.
* **Automatic token generation:** Base colors like `primarycolor` are expanded into 11-step light and dark color scales for semantic tokens, ensuring accessibility and consistency.
* **Token overrides:** Customize or add design tokens globally or scoped by theme mode (light/dark) or density (comfy/cozy) without changing component code.
* **Theme application:** Export the theme from your application lifecycle module or set it statically on your layout class.
* **Theme precedence:** Instance-level themes override application code themes, which override layout-level static themes, with the framework default last.
* **Runtime theme switching:** The framework supports toggling between light and dark modes using a service that persists user preference, with built-in toggles available in navigation layouts.
* **Shadow DOM styling:** Use the provided `themeContext` to reactively apply theme mode within shadow roots via a `theme-variant` attribute for proper CSS scoping.

## Practical Use and Implementation

To rebrand your Lux application:

* Modify the `theme.js` file at your project root with your brand colors, shape parameters, fonts, and optional token overrides.
* Export this theme from your application lifecycle module or attach it statically to your layout class.
* Leverage `tokenoverrides` to adjust specific design tokens without touching component CSS, allowing seamless rebranding.
* Use the built-in theme toggle or the theme service API to enable runtime switching between light and dark modes.
* Understand that instance-level themes managed by administrators can override your code-defined themes, enabling rebranding without redeploying code.
* Use semantic tokens in your CSS rather than raw color stops to ensure consistent application of your brand palette across all UI elements.

## Additional Details

* The theme data is stored as JSON on the `sysaixtheme` record and parsed at request time for server-side rendering and client-side application.
* CSS tokens declared in your application's Tailwind styles override theme tokens, so use theme tokens for brandable values and Tailwind CSS for fixed styles.
* New custom properties can be added via `tokenoverrides` and accessed using CSS `var()` syntax for extended theming capabilities.  
A Lux application declares its brand in one file at the project root, and the framework generates every color, radius, and font token from it. Restyling a Lux application goes through that file rather than through component CSS.
Important:  
Two files carry the name theme.js, and this page is about your application's own root theme.js, which holds four keys of brand input. The framework's internal token-definitions module, libraries/theme-generation/src/algorithm/theme.js, is documented in design-tokens.html. If you are looking for `ROOT_TOKENS`, look there.

## Scaffolded theme file {#theme-js-configuration-reference__theme-js-configuration-reference-scaffolded-theme-file}

A scaffolded application ships with the following file.

    // theme.js
    export const AppTheme = {
      primary_color: '#032D42',
      neutral_colors: {use_hex_value: true, hex_value: '#F8F7F4'},
      shape: {
        selector_radius: '0.75rem',
        field_radius: '0.5rem',
        boxes_radius: '1rem',
        border_width: '1px'
      }
    };

That is the whole file. The generated palette propagates to every component in the application.

## theme.js Fields {#theme-js-configuration-reference__theme-js-configuration-reference-fields}

{#theme-js-configuration-reference__table-theme-js-configuration-reference-theme-js-fields__entry__3}

| Field | Type | What it controls |
|-|-|-|
| `primary_color` | Hex string | Brand color. Drives the `--primary-*` scale, buttons, links, and focus rings. |
| `accent_color` | Hex string | Secondary calls to action, through the `--accent-*` scale. |
| `neutral_colors` | `{use_hex_value: true, hex_value: '#...'}` | Base for the `--neutral-*` scale, which most surface, text, and border tokens resolve through. |
| `shape` | Object | Four radius and width keys: `selector_radius` for check boxes, radios, and toggles, `field_radius` for inputs and buttons, `boxes_radius` for cards and panels, and `border_width`. |
| `fonts` | Array | Font families to register as `@font-face`. |
| `light_logo` / `dark_logo` | Attachment reference | Per-scheme logo shown in the nav header. |
| `light_favicon_url` / `dark_favicon_url` | URL | Per-scheme favicon. |
| `token_overrides` | Object | Override for individual token values. |
[ ]

{#theme-js-configuration-reference__table-theme-js-configuration-reference-theme-js-fields}

Only `primary_color` is required. Every other field falls back to a Lux default.

The four `shape` keys map onto the tokens documented in .

## Applying the theme {#theme-js-configuration-reference__theme-js-configuration-reference-applying-the-theme}

Export the theme from your application's lifecycle module. Nothing else is required.

    // application.js
    import {AppTheme} from './theme.js';

    export default {
      appTheme: AppTheme,
      applicationLayout: 'aiux-nav-layout'
    };

When your application has no lifecycle module, set the theme as a static on your layout class instead.

    // pages/layout.js
    import {AIUXAppLayoutElement} from '@servicenow/aiux-components-core';
    import {AppTheme} from '../theme.js';

    export default class AppLayout extends AIUXAppLayoutElement {
      static appTheme = AppTheme;
    }

## Precedence {#theme-js-configuration-reference__theme-js-configuration-reference-precedence}

The following table lists the four theme sources, highest precedence first.
{#theme-js-configuration-reference__table-theme-js-configuration-reference-theme-source-precedence__entry__2}

| Source | Notes |
|-|-|
| A theme provisioned on the instance | Wins over everything in code, so an admin can rebrand the same application without a code change |
| application.js's `appTheme` export | Wins over the layout static |
| `static appTheme` on an `AIUXAppLayoutElement` subclass | Fallback when there is no lifecycle module |
| The framework default theme | Applies when none of the other sources is present |
[Table 1. Theme source precedence]

{#theme-js-configuration-reference__table-theme-js-configuration-reference-theme-source-precedence}

## Generated color scales {#theme-js-configuration-reference__theme-js-configuration-reference-generated-color-scales}

`primary_color`, `accent_color`, and `neutral_colors` are base colors rather than tokens. Each is expanded into an 11-stop scale, `50` through `950`, generated twice, once for light mode and once for dark, so contrast holds in both. The semantic tokens are defined in terms of those stops.

That expansion is why one hex value is enough to rebrand an application, and why component styles should use a semantic token rather than a raw stop. See .

## token_overrides {#theme-js-configuration-reference__theme-js-configuration-reference-token-overrides}

`token_overrides` sets any design token without a change to component code. Every built-in token is defined with an override hook already in place, so a key matching a known token replaces that token's value everywhere it is consumed. A key matching nothing is emitted as a new custom property you can `var()` yourself.

Keys at the top level apply everywhere. Nest them under `light`, `dark`, `comfy`, or `cozy` to scope an override to one color scheme or density mode.

    export const AppTheme = {
      primary_color: '#032D42',
      token_overrides: {
        '--radius-lg': '1.5rem',        // known token: every card gets rounder
        '--font-sans': '"Demo Grotesk"',
        '--brand-glow': '0 0 12px #63DF4E', // unknown key: new property, use via var()

        light: {'--color-primary': '#032D42'},
        dark: {'--color-primary': '#63DF4E'},
        comfy: {'--space-unit': '0.4rem'},
        cozy: {'--space-unit': '0.1rem'}
      }
    };

## Key to selector {#theme-js-configuration-reference__theme-js-configuration-reference-key-to-selector}

{#theme-js-configuration-reference__table-theme-js-configuration-reference-token-overrides-keys-and-the-selectors-they-emit__entry__2}

| Source key | Selector emitted |
|-|-|
| Root-level keys | `:root` |
| `light` | `[data-theme="light"]` |
| `dark` | `[data-theme="dark"]` |
| `comfy` | `[data-density="comfy"]` |
| `cozy` | `[data-density="cozy"]` |
[Table 2. token_overrides keys and the selectors they emit]

{#theme-js-configuration-reference__table-theme-js-configuration-reference-token-overrides-keys-and-the-selectors-they-emit}

A theme with no `token_overrides`, or with an empty object, emits no override block.

## Key resolution {#theme-js-configuration-reference__theme-js-configuration-reference-key-resolution}

`generateTokenOverrideBlocks()` checks each key against `ROOT_TOKENS`, `DATAVIS_ROOT_TOKENS`, `LIGHT_THEME_TOKENS`, `DARK_THEME_TOKENS`, `DENSITY_COMFY`, and `DENSITY_COZY`. A match is renamed to `--theme-level-<name>`, which feeds the `var(--theme-level-<name>, <default>)` indirection already baked into that token. A non-match passes through unprefixed.

## Application CSS precedence {#theme-js-configuration-reference__theme-js-configuration-reference-application-css-precedence}

Tokens declared in your application's tailwind.app.css sit above the theme in the cascade, so a value pinned there isn't affected by whatever a theme sets. Use `token_overrides` for what a rebrand should be able to change, and tailwind.app.css for what it should not.

## Storage and request flow {#theme-js-configuration-reference__theme-js-configuration-reference-storage-and-request-flow}

The field is stored as a JSON blob on the `sys_aix_theme` record. It is an empty string, rather than `null` or `undefined`, when a theme declares no overrides.

A theme's theme.js, or an admin-authored theme record, declares `token_overrides`. `collectThemeRecords()` stringifies it into the `sys_aix_theme.token_overrides` column at build time, and theme-reader.js parses it back on every request. `getAppThemeCSS()` calls `generateThemeCSS()`, which includes the override block in the server-rendered `<style id="theme-token-overrides">` tag. On a client-side theme change, `applyTheme()` regenerates and swaps the same block without a full reload.

The mechanism is implemented, with the font route noted in the preceding note.

## Switching light and dark at runtime {#theme-js-configuration-reference__theme-js-configuration-reference-switching-light-and-dark-at-runtime}

Theme mode lives on the `data-theme` attribute. The framework exposes a service for flipping it, and the user's choice persists across reloads.

    import {
      setThemeMode,
      getThemeMode,
      themeContext
    } from '@servicenow/aiux-components-core';

    _toggleTheme() {
      setThemeMode(getThemeMode() === 'dark' ? 'light' : 'dark');
    }

Most applications don't need to write that code, because the nav layout ships a theme toggle that you turn on with `features.themeToggle`.

## Reacting to the theme mode {#theme-js-configuration-reference__theme-js-configuration-reference-reacting-to-the-theme-mode}

Consume `themeContext` and reflect the value onto your own host as `theme-variant`.

    static contexts = [themeContext];

    willUpdate() {
      this.setAttribute('theme-variant', themeContext.get()?.mode ?? 'light');
    }

    static styles = css`
      :host([theme-variant='dark']) .panel {
        box-shadow: none;
      }
    `;

Use `theme-variant` on the host rather than `data-theme`. The generated theme CSS declares `[data-theme]` rules at the document level, and those outrank a `:host` rule for the same token. Reflecting your own attribute keeps the override inside your shadow root, where it applies.

