Palettes in Ignite UI for Angular
Ignite UI for Angular palettes are sets of --ig-* CSS variables, generated from seed colors, that supply the colors of every component theme.
Overview
A Ignite UI for Angular palette has eight color families: primary, secondary, gray, surface, info, success, warn, and error. Each family exposes its shades as CSS variables named --ig-<family>-<variant>, for example --ig-primary-500.
| Family | Variants |
|---|---|
primary, secondary, info, success, warn, error |
50, 100, 200, 300, 400, 500, 600, 700, 800, 900, A100, A200, A400, A700, seed |
gray |
50–900, seed |
surface |
base, sunken, raised, overlay, container, seed |
The numbered shades run from 50, the lightest, to 900, the darkest. The A100–A700 accent shades are vivid variants for emphasis. The surface family describes layers rather than shades: base is the page and component background, sunken, raised, and overlay are layers relative to it, and container is a translucent fill. Palettes also include numbered surface shades for compatibility, but they are deprecated in favor of the roles, which component themes read.
Every variant has a matching -contrast variable, such as --ig-primary-500-contrast, that resolves to black or white, whichever reads better against that shade at the configured WCAG level.
Contrast colors are CSS relative colors calculated by the browser from their shade, so overriding a shade updates its contrast color along with it. The translucent container is the exception: its contrast color is calculated from the container laid over base, which is what text on it is read against, so it follows changes to either.
Here is an excerpt of the primary family in the light Material palette:
:root {
--ig-primary-500: #09f;
--ig-primary-500-contrast: hsla(from color(from var(--ig-primary-500) var(--y-contrast)) h 0 l / 1);
--ig-primary-600: hsl(from var(--ig-primary-500) h calc(s * 1.26) calc(l * 0.89));
--ig-primary-600-contrast: hsla(from color(from var(--ig-primary-600) var(--y-contrast)) h 0 l / 1);
--ig-primary-seed: #09f;
/* ... */
--ig-wcag-a: 0.31;
--ig-wcag-aa: 0.185;
--ig-wcag-aaa: 0.178;
--ig-contrast-level: var(--ig-wcag-aa);
--y: clamp(0, (y / var(--ig-contrast-level) - 1) * -infinity, 1);
--y-contrast: xyz-d65 var(--y) var(--y) var(--y);
}
Each family also exposes a seed variable that holds the color the palette was generated from, unchanged. In the prebuilt themes, the seed of primary, secondary, and the other color families matches their 500 variant. For gray it does not: --ig-gray-seed records the color the grayscale was derived from, black or white chosen from the surface color’s luminance, while --ig-gray-500 is a generated mid-tone.
The contrast threshold is held in --ig-contrast-level, which defaults to var(--ig-wcag-aa). Override it on any scope to switch to var(--ig-wcag-a) or var(--ig-wcag-aaa).
In Sass, the palette() and adaptive-contrast() mixins accept 'a', 'aa', or 'aaa' directly:
@include palette($palette, $contrast-level: 'aaa');
How Palettes Are Generated
Every Ignite UI for Angular palette, including the ones in the prebuilt CSS themes, is generated by the palette() function of the igniteui-theming Sass library. The function has two generators, and they produce CSS variables that behave differently at runtime:
| Generator | Shades are emitted as | Used by |
|---|---|---|
legacy |
CSS relative colors of 500. Overriding --ig-primary-500 updates every primary shade in the browser. |
Every prebuilt CSS theme and the predefined Sass palettes. |
fitted |
Fixed colors solved for contrast targets. Overriding one variable changes only that shade. | Palettes you generate with palette() in Sass, by default. |
The legacy generator multiplies the 500 shade’s saturation and lightness by fixed values, so the quality of its shades depends on how light or dark the 500 color is. A very dark or very pale 500 produces shades that bunch together or resolve to white. If your brand color is very dark or very pale, generate the palette with the fitted generator in Sass instead: it builds every family to a contrast scale, so such seeds still produce ten distinct shades. Palette Generation explains both generators and shows how to generate a palette. Palettes with Sass covers each workflow in detail.
The rest of this topic describes runtime overrides, which derive new shades only in palettes built with the legacy generator, such as the prebuilt themes.
Defining Palettes
Change a color family by overriding its 500 variant. Every other numbered and accent shade of the family is a relative color of 500, so it updates with it:
:root {
--ig-primary-500: #09f;
}
The derived shades keep the hue of 500 and change only its saturation and lightness, so each family is monochromatic:
:root {
--ig-primary-600: hsl(from var(--ig-primary-500) h calc(s * 1.26) calc(l * 0.89));
}
The seed variable is not derived from 500; it records the color the palette was built from. Override the shades you use, not seed.
Scoping
Override palette variables on :root in your application’s global stylesheet to change the global palette. Any CSS color syntax works:
:root {
--ig-primary-500: #9f349c;
}
Scope overrides to other selectors to run several palettes side by side. For example, define a blue and a red palette on classes:
/* styles.css */
.blue-theme {
--ig-primary-500: #0008ff;
}
.red-theme {
--ig-primary-500: #ff0400;
}
<app-component class="blue-theme"></app-component>
Change the class from blue-theme to red-theme to switch the palette of everything inside the element.
The same approach changes a palette color for a single component. The Material avatar, for example, takes its background from the gray 400 shade, so overriding that shade on the avatar changes its background without touching the rest of the palette:
igx-avatar {
--ig-gray-400: #efefef;
}
Surface Layers
The surface family is a set of named layers instead of numbered shades. Components read these layers, starting with --ig-surface-base:
| Variable | Used for |
|---|---|
--ig-surface-base |
The page background |
--ig-surface-sunken |
Recessed areas |
--ig-surface-raised |
Cards and panels that sit above the page |
--ig-surface-overlay |
Menus, dialogs, and popovers |
--ig-surface-container |
A translucent layer on top of a surface: black over a light surface, white over a dark one |
Each layer has a matching -contrast variable, such as --ig-surface-base-contrast, for the foreground color on that layer.
A layer that has no room for its full step resolves to base. On white and other light surfaces close to it, for example, raised and overlay can match the base color, so use borders or elevations to separate them from the page. Palette Generation explains how the layers are generated.
Dark vs. Light
The gray and surface families decide whether a Ignite UI for Angular palette is light or dark. Light palettes pair a light surface with grays built from a dark color; dark palettes pair a dark surface with grays built from white. Text, borders, and icons take their colors from the grays, so the two families must stay on opposite ends of the gray scale.
Component backgrounds read the surface roles, so override the roles to change the surface at runtime. The roles are fixed colors under both generators, and they are not derived from --ig-surface-500:
Material Light:
:root {
/* the surface roles are light */
--ig-surface-base: #fff;
--ig-surface-raised: #fff;
--ig-surface-overlay: #fff;
--ig-surface-sunken: #f7f7f7;
/* grays are built from a dark color to contrast the surface */
--ig-gray-500: hsl(0, 0%, 62%);
}
Material Dark:
:root {
/* the surface roles are dark */
--ig-surface-base: #222;
--ig-surface-raised: #282828;
--ig-surface-overlay: #2f2f2f;
--ig-surface-sunken: #1c1c1c;
/* grays are built from white to contrast the surface */
--ig-gray-500: hsl(0, 0%, 74%);
}
Components read the surface roles since Ignite UI for Angular 22.3.0. Earlier versions read --ig-surface-500 for their background instead, so on those versions override --ig-surface-500 along with --ig-surface-base.
Change gray and surface carefully: most components use them, and they have the largest effect on the overall look of a theme.
Other Colors
The info, success, warn, and error families color states, such as the validation states of the igx-input-group. Override their 500 variants to change them, and the rest of each family follows:
:root {
--ig-info-500: #1377d5;
--ig-success-500: #4eb862;
--ig-warn-500: #faa419;
--ig-error-500: #ff134a;
}