Menu

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

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:

  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.

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:

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

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.

Defining your theme

Base themes

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

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

const configuration = {
        theme: {
            isLight: false
        }
};

Flex.manager.updateConfig(configuration);

Overriding base theme colors

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.

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

Flex.manager.updateConfig(configuration);

Overriding individual components

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.

const configuration = {
    theme: {
        componentThemeOverrides: {
            MainHeader: {
                Container: {
                    background: "#ff0000",
                    color: "#00ff00"
                }
            },
            SideNav: {
                Container: {
                    background: "#4a4e60"
                }
                Icon: {
                    background: "#4a4e60"
                },
            }
        }
    }
};

Flex.manager.updateConfig(configuration);

See the complete list of customizable components and properties.

Applying your theme

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

Applying your theme in a Flex Plugin

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

CustomTheme.js

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

Flex.manager.updateConfig(configuration);

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

ThemePlugin.js

export default class ThemePlugin extends FlexPlugin {

  init(Flex, Manager) {
    const configuration = {...};

    // apply theme
    Manager.updateConfig(configuration);
  }
}

Applying themes to self-hosted installations of Flex

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

// refer to previous examples for setting your theme configuration
const configuration = {...}; 

Twilio.Flex.runDefault(configuration);

Next Steps

Rate this page:

Need some help?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd by visiting Twilio's Stack Overflow Collective or browsing the Twilio tag on Stack Overflow.

Thank you for your feedback!

Please select the reason(s) for your feedback. The additional information you provide helps us improve our documentation:

Sending your feedback...
🎉 Thank you for your feedback!
Something went wrong. Please try again.

Thanks for your feedback!

thanks-feedback-gif