Hello Everyone, In this post, I am going to show you some code sample that you can used to determine whether user in classic or in lightning experience, means which UI has been used by a logged in user. So let’s begin.

User in classic or in lightning experience

Here, I am writing about some property that belongs to User class. This can be used in Visualforce pages or in apex classes but with different syntaxes.

UITheme - Returns the look and feel the user is supposed to see.

UIThemeDisplayed - Return the look and feel the user actually sees. 

In Visualforce Page:

 {!$User.UiTheme}
OR
{!$User.UIThemeDisplayed}

In Apex:

 System.debug('**'+UserInfo.getUiTheme());
OR
System.debug('^^'+UserInfo.getUiThemeDisplayed());
  • 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 - AppExchange theme. 

Output:

Hope you like this post, for any query or suggestions please feel free to comment.

Thank you.