Newer Version Available
Determining the Salesforce Style That Users See in JavaScript
If you use a lot of JavaScript in your pages and apps, identifying the Salesforce theme
that a user sees in JavaScript code is important. Identifying the current user experience context
allows you to correctly manage navigation in your JavaScript code.
The UITheme.getUITheme() JavaScript function returns a string containing one of the following values to identify the current user interface theme.
- 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 string values returned are the same values returned by the Visualforce $User.UITheme and $User.UIThemeDisplayed global variables.
The following markup checks if the current user experience context is the Lightning Experience theme.
1function isLightningDesktop() {
2 return UITheme.getUITheme === "Theme4d";
3}