Theming
In OneCX, theming controls how the content of a page looks. The OneCX shell, working together with the OneCX Theme Management application, provides the theme. A theme’s look is expressed as a set of CSS variables (design tokens) — OneCX’s own suite of theme variables. Each workspace can use a different theme, and the theme’s variables are exposed on every page — with different values depending on the workspace being accessed.
How theming works
The shell makes the active theme’s variables available on the page automatically, based on the workspace being accessed. An application does not have to do anything to apply a theme — there is no import, provider, or build step on its side.
Regardless of whether an application is built with Angular or React, consuming a theme is the same thing: reference the corresponding CSS variable in the application’s own styles, as shown in Utilizing Theme Variables below.
What an application must do
The only responsibility of a OneCX-compatible application is to use the theme variables in its own styles instead of hard-coded color, font, or spacing values. Doing so means the application automatically adopts whatever theme is active for the workspace and restyles itself when the theme changes. Hard-coded styles, by contrast, do not follow the active theme and look out of place when the theme differs.
Theme Variables
Theme variables are CSS variables available on the page for any application.
Below is a list of the theme variables available on the page:
- Basic Variables
CSS variable |
Description |
|
Primary color of non-text content. |
|
Secondary color of non-text content. |
|
Default background color of non-text content. |
|
Alternate background color of non-text content. |
|
Default background color on hover of non-text content. |
- Text-related Variables
CSS variable |
Description |
|
Default font family for text content. |
|
Default font size for text content. |
|
Primary font text color. |
|
Secondary font text color for elements in lower design hierarchy, usually less prominent. |
|
Font text color on solid (opaque) surfaces. |
CSS variable |
Description |
|
Background color of a button in hover state. |
|
Background color of a button in active state. |
|
Background color of a button with danger severity. |
- Message-related Variables
CSS variable |
Description |
|
Background color of a message with info severity. |
|
Background color of a message with success severity. |
|
Background color of a message with warning severity. |
|
Background color of a message with error severity. |
- Misc Variables
CSS variable |
Description |
|
Color of divider HTML elements, such as |
|
Background color of the document’s body, used for the content pane’s background color. |
|
Background color of the overlays. |
- Topbar Variables
CSS variable |
Description |
|
Background color of the topbar. |
|
Background color of the topbar’s left side. |
|
Color of the text in the topbar. |
|
Color of the text of the items located in the topbar. |
|
Background color for the items located in the topbar on hover state. |
|
Background color of the vertical menu hiding toggle. |
|
Color of the text in the vertical menu hiding toggle. |
|
Color of the topbar’s logo. |
CSS variable |
Description |
|
Background color of the sidebar (left side of the shell). |
|
Text color of the menu, located in the sidebar (left side of the shell). |
|
Text color of the menu item, located in the sidebar (left side of the shell). |
|
Background color of the menu item, located in the sidebar (left side of the shell). |
|
Background color of the menu item in hover state, located in the sidebar (left side of the shell). |
|
Text color of the menu item in active state, located in the sidebar (left side of the shell). |
|
Background color of the menu item in active state, located in the sidebar (left side of the shell). |
|
Border color of the inline menu, located in the sidebar (left side of the shell). |
Utilizing Theme Variables
Regardless of whether your application is built with Angular or React, using a theme variable just means referencing the corresponding CSS variable in your styles — injecting and applying the variables' values is handled automatically. When creating styles for UI components, it’s important to consider whether a style should be theme-aware. Example of a stylesheet using a theme variable:
button {
background-color: var(--primary-color);
}
The example above sets the background color for each button element to the value corresponding to the --primary-color theme variable.
Related
To apply a theme to an application step by step, see Apply Theming and Expose Component Styles.
For details on customizing the OneCX PrimeNG theme, see the PrimeNG Theming Customization feature page for how the OneCX theme maps to PrimeNG and how to apply optional token overrides.