Newer Version Available
Identifying the Salesforce Style Your Users See
There are two global variables that can help you identify which style a user sees: $User.UITheme and $User.UIThemeDisplayed. The difference between the two variables is that $User.UITheme returns the look and feel the user is supposed to see, while $User.UIThemeDisplayed returns the look and feel the user actually sees. For example, a user can have the preference and permissions to see the Lightning Experience look and feel, but if they’re using a browser that doesn’t support that look and feel, for example, older versions of Internet Explorer, $User.UIThemeDisplayed returns a different value.
- 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 that applies to Customer Portals only and not to Experience Builder sites
- Webstore—AppExchange theme
1<apex:page standardController="Account">
2 <apex:variable var="newUI" value="newSkinOn"
3 rendered="{!$User.UIThemeDisplayed = 'Theme3'}">
4 <apex:stylesheet value="{!URLFOR($Resource.myStyles, 'newStyles.css')}" />
5 </apex:variable>
6 <apex:variable var="oldUI" value="oldSkinOn"
7 rendered="{!$User.UIThemeDisplayed != 'Theme3'}">
8 <apex:stylesheet value="{!URLFOR($Resource.myStyles, 'oldStyles.css')}" />
9 </apex:variable>
10 <!-- Continue page design -->
11</apex:page>- Using the rendered attribute you can “toggle” which sections display.
- Since the <apex:stylesheet> tag doesn't have a rendered attribute, you’ll need to wrap it in a component that does.
1<apex:page showHeader="true" tabstyle="Case">
2 <apex:pageMessage severity="error" rendered="{!$User.UITheme = 'Theme3' &&
3 $User.UIThemeDisplayed != 'Theme3'}">
4 We've noticed that the new look and feel is enabled for your organization.
5 However, you can't take advantage of its brilliance. Please check with
6 your administrator for possible reasons for this impediment.
7 </apex:pageMessage>
8 <apex:ListViews type="Case" rendered="{!$User.UITheme = 'Theme3' &&
9 $User.UIThemeDisplayed = 'Theme3'}"/>
10</apex:page>