Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

Override Flex UI 2.x.x themes, branding and styling


(information)

Info

Auto-Generated Documentation for the Flex UI(link takes you to an external page) is now available. The auto-generated documentation is accurate and comprehensive and may differ from what you see in the official Flex UI documentation. It includes a comprehensive overview of Theme options(link takes you to an external page).

The Flex UI exposes 3 main levels of customization:

  1. Base Themes: Flex UI 2.x.x supports two themes: Dark and Light.
  2. Base Theme Color Overrides: Global color overrides that are inherited by all Flex UI components.
  3. Component Theme Overrides: Granular color overrides that allow you to customize a specific component.
(information)

Info

If you're migrating from Flex UI 1.x.x, 2.x.x has a new configuration key called config.theme.

You can achieve these three levels of customization by updating the Flex theme configuration via config.theme. config.theme is defined by the following interface:


_10
interface ThemeConfigProps {
_10
isLight?: boolean; // Represents if light or dark theme
_10
tokens?: Tokens; // Paste tokens
_10
componentThemeOverrides?: Object; // Object containing component style overrides
_10
}

Where:

Tokens: For usage documentation, see Create a custom theme using the Paste Theme Designer(link takes you to an external page).

componentThemeOverrides: For a list of components you can override, see Flex UI API Reference(link takes you to an external page).


Defining your theme

defining-your-theme page anchor

Base themes

base-themes page anchor

Base themes provide a set of colors as a starting point for your contact center. Flex UI has two themes:

  • Light
  • Dark

Configuring a base theme

configuring-a-base-theme page anchor

You can configure the desired base theme in the Flex configuration object.


_10
const configuration = {
_10
theme: {
_10
isLight: false
_10
}
_10
};
_10
_10
Flex.manager.updateConfig(configuration);

Overriding base theme colors

overriding-base-theme-colors page anchor

You can also create your own variation of a theme by passing Paste token values. For Tokens documentation and details on how to generate them, see Create a custom theme using the Paste Theme Designer(link takes you to an external page).


_15
const configuration = {
_15
theme: {
_15
isLight: false,
_15
tokens: {
_15
backgroundColors: {
_15
colorBackground: "rgb(255, 0, 0)",
_15
},
_15
"textColors": {
_15
"colorText": "rgb(0, 0, 255)",
_15
}
_15
}
_15
}
_15
};
_15
_15
Flex.manager.updateConfig(configuration);

Overriding individual components

overriding-individual-components page anchor

Flex theming also supports granular customizations at the individual component level. In the following code sample, Flex will override the MainHeader background color and text color, as well as the SideNav background color and icon background color.


_22
const configuration = {
_22
theme: {
_22
componentThemeOverrides: {
_22
MainHeader: {
_22
Container: {
_22
background: "#ff0000",
_22
color: "#00ff00"
_22
}
_22
},
_22
SideNav: {
_22
Container: {
_22
background: "#4a4e60"
_22
}
_22
Icon: {
_22
background: "#4a4e60"
_22
},
_22
}
_22
}
_22
}
_22
};
_22
_22
Flex.manager.updateConfig(configuration);

See the complete list(link takes you to an external page) of customizable components and properties.


Once you've defined a theme, you'll need to apply it to Flex UI.

Applying your theme in a Flex Plugin

applying-your-theme-in-a-flex-plugin page anchor

Define your color theme by specifying a boolean value for isLight, along with optional tokens and component overrides.

CustomTheme.js


_32
const configuration = {
_32
theme: {
_32
isLight: false,
_32
tokens: {
_32
backgroundColors: {
_32
colorBackground: "rgb(255, 0, 0)",
_32
},
_32
"textColors": {
_32
"colorText": "rgb(0, 0, 255)",
_32
}
_32
},
_32
componentThemeOverrides: {
_32
MainHeader: {
_32
Container: {
_32
background: "#ff0000",
_32
color: "#00ff00"
_32
}
_32
},
_32
SideNav: {
_32
Container: {
_32
background: "#0000ff"
_32
},
_32
Icon: {
_32
background: "#ffc300",
_32
color: "#ff5733"
_32
},
_32
}
_32
}
_32
}
_32
}
_32
_32
Flex.manager.updateConfig(configuration);

Then set your custom theme inside the Flex configuration and apply it during plugin initialization.

ThemePlugin.js


_10
export default class ThemePlugin extends FlexPlugin {
_10
_10
init(Flex, Manager) {
_10
const configuration = {...};
_10
_10
// apply theme
_10
Manager.updateConfig(configuration);
_10
}
_10
}

Applying themes to self-hosted installations of Flex

applying-themes-to-self-hosted-installations-of-flex page anchor

Include your custom theme in the configuration object's theme property when initializing Flex.


_10
// refer to previous examples for setting your theme configuration
_10
const configuration = {...};
_10
_10
Twilio.Flex.runDefault(configuration);



Rate this page: