Implementing User-Toggleable Light/Dark Modes in Constellation 25.1

Hi Team,

I am currently working with Pega Constellation 25.1 and have a requirement to enable a user-controlled Light/Dark theme toggle at runtime.

Since Constellation uses Design Tokens and App Studio usually only allows one active theme per portal, I’m looking for the best way to handle this.

  1. Is there a built-in way in 25.1 to support “prefers-color-scheme” (system dark mode)?

  2. If not, what is the recommended approach for a user-controlled toggle? Should I use a Custom DX Component in the header to swap CSS variables?

  3. Where is the best place to save the user’s theme preference (Operator record or a Data Page)?

Looking forward to your advice and any best practices!

@hemalathag8810 There is no such way OOTB currently. Building a DX component is certainly an option. But our product team is also looking at implementing this natively into the platform, no promises made - but could be an idea to weigh the implementation cost of adding a DX component vs waiting for native support.

Did you implemented this?

@Pradeep_Bhatt keep an eye out for '26. We are planning a '26 new feature webinars in July, where we will showcase some of the features in this space.

@MarcCheong Hi, any setting we need to enable to see Portal Themes? no icon (Light/Dark theme toggle) at my end?

Since Pega Constellation 25.1 does not natively support runtime theme toggling, you must build a custom DX Component placed in the portal header to handle the switch. This component will dynamically modify the application’s underlying CSS variables and design tokens on the document body when toggled. To ensure the selected theme persists across future sessions, save the user’s theme preference directly to a custom property on their Operator record. You can then load this saved preference during the login sequence using a thread-level Data Page to instantly apply the chosen mode. This direct approach successfully gives users full control over their visual workspace while working within the current platform architecture.

Very good question.

For those reading this, this is an image of Infinity '26, so here we are referring to the new feature Theme Switching in Runtime Portal.

This isn’t very well documented (I’m getting this fixed).

  • Run time
  • Design time
    • You are likely not seeing it because you have not configured your dark theme? I noticed when I went in, this was empty and I had to set it; and when it was empty at run time the icon was not there (which is expected outcome)

We have a Hybrid Portal where we have Constellation Portal as our main Portal but we have UI-Kit case types that are also supported. Is it possible to implement similar Token behavior via Skin option.

Thanks for the update. This is a great addition to the product. I was wondering how the custom components will handle theming and whether they will automatically align with the established design theme.

@hemalathag8810

Custom components can automatically adapt to the selected Light or Dark theme by using Pega’s theme configuration.

  1. Automatic theme adaptation

Suppose theme.components.card.background is configured as:

  • Light mode: Red
  • Dark mode: Green

If your custom component uses this token for its background, it will automatically display Red in Light mode and Green in Dark mode.

2. Using theme tokens for different purposes

Suppose your Pega application has the following theme configuration:

Even though foreground-color is configured as Blue and Orange, if you use theme.components.card.backgroundfor your component’s text color, the text will appear Red in Light mode and Green in Dark mode.

The component applies whichever theme token you specify, regardless of its intended purpose.

3. Using hardcoded colors

If you hardcode a color, such as color: purple, your component’s text will remain Purple in both Light and Dark modes, regardless of the selected theme.

Note: To maintain consistent styling and ensure automatic theme adaptation, use the appropriate theme tokens instead of hardcoded colors.

@LantzAndreas / @MarcCheong

In Pega Constellation 26, we have Light and Dark theme options. I would like to know how to detect the currently selected theme within a custom DX component.

I tried using the useTheme() hook from styled-components, which returns the theme configuration (base and components). However, I couldn’t find an explicit property indicating whether the current theme is Light or Dark.

My requirement: I want to apply custom colors based on the selected theme without relying on Pega’s predefined theme color tokens.

For example:

  • Light mode: color: purple
  • Dark mode: color: green

Is there an official Pega API, theme property, or recommended approach to detect the selected theme and automatically update custom component styles when users switch between Light and Dark modes, without refreshing the browser?

Any guidance or sample implementation would be greatly appreciated.

Anything is possible. However, Traditional UI Kit does not natively feature a simple “out-of-the-box toggle” or automatic system-level switching for light and dark modes in the same way modern Constellation design system does.

As are result you would have to build this yourself in UI Kit, which is not my area of expertise, BUT you’d hit a variety of challenges (mentioned below) that in my opinion would be more effort than benefit.

Migrating the blended UI Kit case types, might be a better use of the effort vs such a custom implementation. It would also require heavy expertise in Pega, UI Kit and custom CSS to achieve.

Potential challenges of building a UI Kit light/dark toggle for UI Kit Application

  • Hardcoded Mixins: Standard UI Kit components rely heavily on hardcoded inline styles and static mixin classes generated by the skin engine. You will likely need multiple CSS overrides to handle headers, grids, modals, and field borders.

  • Component Formats: Built-in form controls (standard dropdowns, autocomplete, calendar pickers) have complex styling structures that may require extensive custom CSS to look natural in a dark theme.

  • Upgrade/Maintenance Overhead: Large custom CSS files in the skin can make future platform updates more difficult to maintain compared to Constellation’s design token system

  • Regression issues and bugs: The point of Blended UI is to utilise existing investments in UI Kit cases, via your Constellation Application. This comes at no extra investment, you get to use what you built. By refactoring your UI Kit application, you are putting more investment in legacy architecture AND potentially breaking things in the process.

  • Blended UI Complexity: Over coming all of the above. You have the added challenge of Blended UI. How would the UI Kit application know Constellation’s theme?

    • The right hooks may not be in place and you’d likely be establishing your own mechanisms for a cross-origin/cross-frame communication to sync the theme state. Makes me nervous just saying it aloud.