Auto-Generated Documentation for the Flex UI 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.
The Flex UI exposes 3 main levels of customization:
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:
1interface ThemeConfigProps {2isLight?: boolean; // Represents if light or dark theme3tokens?: Tokens; // Paste tokens4componentThemeOverrides?: Object; // Object containing component style overrides5}6
Where:
Tokens: For usage documentation, see Create a custom theme using the Paste Theme Designer.
componentThemeOverrides: For a list of components you can override, see Flex UI API Reference.
Base themes provide a set of colors as a starting point for your contact center. Flex UI has two themes:
You can configure the desired base theme in the Flex configuration object.
1const configuration = {2theme: {3isLight: false4}5};67Flex.manager.updateConfig(configuration);8
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.
1const configuration = {2theme: {3isLight: false,4tokens: {5backgroundColors: {6colorBackground: "rgb(255, 0, 0)",7},8"textColors": {9"colorText": "rgb(0, 0, 255)",10}11}12}13};1415Flex.manager.updateConfig(configuration);16
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.
1const configuration = {2theme: {3componentThemeOverrides: {4MainHeader: {5Container: {6background: "#ff0000",7color: "#00ff00"8}9},10SideNav: {11Container: {12background: "#4a4e60"13}14Icon: {15background: "#4a4e60"16},17}18}19}20};2122Flex.manager.updateConfig(configuration);23
See the complete list of customizable components and properties.
Once you've defined a theme, you'll need to apply it to Flex UI.
Define your color theme by specifying a Boolean value for isLight
, along with optional tokens and component overrides.
CustomTheme.js
1const configuration = {2theme: {3isLight: false,4tokens: {5backgroundColors: {6colorBackground: "rgb(255, 0, 0)",7},8"textColors": {9"colorText": "rgb(0, 0, 255)",10}11},12componentThemeOverrides: {13MainHeader: {14Container: {15background: "#ff0000",16color: "#00ff00"17}18},19SideNav: {20Container: {21background: "#0000ff"22},23Icon: {24background: "#ffc300",25color: "#ff5733"26},27}28}29}30}3132Flex.manager.updateConfig(configuration);
Then set your custom theme inside the Flex configuration and apply it during plugin initialization.
ThemePlugin.js
1export default class ThemePlugin extends FlexPlugin {23init(Flex, Manager) {4const configuration = {...};56// apply theme7Manager.updateConfig(configuration);8}9}10
Include your custom theme in the configuration object's theme
property when initializing Flex.
1// refer to previous examples for setting your theme configuration2const configuration = {...};34Twilio.Flex.runDefault(configuration);5