Akshay Pasunuri
ServiceNow Employee
ServiceNow Employee

AkshayPasunuri_0-1745413700286.gif

 

  • In order switch images automatically when you switch theme from user preferences, you need to use Custom Illustration component.
  • In this article, I will guide you through a step by step process on how to configure the style variables in different themes available in your instance & on how to use Custom Illustration component.
  • In this example, we will consider
    • 2 themes (Polaris & Coral) from 'sys_ux_theme' table
    • 3 images (polaris-banner.svg, coral-banner.svg, default-banner.svg) from 'db_image' table

Screenshot 2025-04-22 at 4.16.12 PM.png

 

💡 The idea is to have a variable with same name but different image paths in Style variables of each theme.

 

Step - 1: Create a token for 'polaris-banner.svg' in Polaris theme

 

  • All -> Now Experience Framework -> Themes. 
  • Open 'Polaris' theme record.
  • Under 'Compositional App Theme' related records, locate Style with name - 'Imagery' & Open that record.

Screenshot 2025-04-22 at 4.38.46 PM.png

  • In "Style" field, add one more variable with name '--now-illustration-custom-application-banner-path' in properties.
    • The value for that property should be the 'Name' value for 'polaris-banner.svg' record from db_image table.
    • Whatever text remains after excluding the starting string '--now-illustration-custom-' becomes the token for the image.

Screenshot 2025-04-22 at 5.07.11 PM.png

 

Step-2: Use Custom illustration component in UIB page

Pre-work: I have created a sample page, with application title & some info message at the top with placeholder for image at the right. We will now add Custom Illustration component to have a banner feel

Screenshot 2025-04-22 at 5.43.31 PM.png

  • Add Custom Illustration component inside Header container beside Title & Info container.
  • For 'SVG image source' give the value 'default-banner.svg'.
    • This will be the backup image incase the Custom Illustration component is not able to find image/asset with passed token.
  • Give some hardcoded Width & Height values in pixels for now.
  • Preview the page in new tab and see the result. You will observe something similar to belowScreenshot 2025-04-22 at 6.02.52 PM.png
  • Now come back to UIB page, Select Custom Illustration component & edit the 'Token Id' field - Give the value from Step-1 i.e `application-banner-path` & Save the changes.
  • Preview the page in new tab and see the result once again. You will observe something similar to belowScreenshot 2025-04-22 at 6.07.34 PM.png

Step-3: Check the result by switching between Coral & Polaris Themes

  • The interesting thing here is that since we added the "Token Id" only in Polaris theme, when we switch to Coral theme we will see the 'default-banner.svg'
Version history
Last update:
‎04-23-2025 06:08 AM
Updated by:
Contributors