Quickly Identify the Salesforce Theme That Users See in JavaScript

If you use a lot of JavaScript in your pages and apps, identifying the Salesforce user experience helps you manage navigation in your JavaScript code. Detecting the Salesforce theme used to require multiple steps and utility functions. The streamlined process involves below new function:

UITheme.getUITheme() : returns a string that indicates the current user’s interface theme.

$User.UITheme() : returns the look and feel the user is supposed to see


Use these variables to identify the CSS used to render Salesforce web pages to a user. Both variables return one of the following values.

  • Theme1—Obsolete Salesforce theme
  • Theme2—Salesforce Classic 2005 user interface theme
  • Theme3—Salesforce Classic 2010 user interface theme
  • Theme4d—Modern “Lightning Experience” Salesforce theme
  • Theme4t—Salesforce mobile app theme
  • Theme4u—Lightning Console theme
  • PortalDefault—Salesforce Customer Portal theme
  • Webstore—Salesforce AppExchange theme


The following example shows how you can render different layouts based on a user’s theme:

Do you find this post helpful ?

View Results

Loading ... Loading ...

For any queries, add your questions on Question/Answer page or in comment section. You can also connect to Technical Experts directly with Live Chat.

Hope it will help someone in need. #HappyLearning
Posted in Configuration, Global Variables, VisualforcePage.

Leave a Reply


This site uses Akismet to reduce spam. Learn how your comment data is processed.

Notify of