Exercise 1Styling a Visualforce page for the Lightning Experience
In this exercise you will learn:
- How to run the same Visualforce page in Salesforce Classic and in the Lightning Experience
- What you should pay attention to when running the same Visualforce page in the two environments
- How to add Salesforce Lightning Design System (SLDS) styles to a Visualforce page
Step 1 - Run the Leads Visualforce Page in Salesforce Classic
- If you are currently using the Lightning Experience, switch back to Salesforce Classic.
- Select the Dreamhouse Classic application and click the Leads tab. This is a simple Visualforce page displaying a list of Leads.
Step 2 - Run the Leads Visualforce Page in the Lightning Experience
- Switch back to the Lightning Experience.
- Click the Setup icon and choose Setup.
- Click on Apps and choose App Manager.
- Click the Actions dropdown for the Dreamhouse Classic app and click Upgrade. Name the new application Dreamhouse Lightning and click Save (this may take a minute to complete).
- Click on the App Launcher icon, and choose your new Dreamhouse Lightning app.
- Click the Leads tab. The page works but has the Salesforce Classic look and feel.
- Right-click on the data table in the page and click Inspect.
- Locate the
<table> tag and notice it has a list class. Classes are CSS rules that define the look of the items on the page.
Step 3 - Style the Visualforce Page with the Salesforce Lightning Design System
- Click the Gear icon (upper right corner) and select Developer Console.
- Choose File > Open > Pages, select DreamhouseLeads. and click Open. Familiarize yourself with the code.
Add the following directive on the line after the opening
<apex:page> tag to include the Salesforce Lightning Design System (SLDS) style sheet:
<apex:pageBlock> tag with the following
<div class="slds-scope"> ... </div>
Add the following attributes to the
styleClass="slds-button slds-button--neutral" to the two
styleClass="slds-table slds-table--bordered slds-table--cell-buffer" to the
Save the page. Go back to the Leads tab and refresh the page. You can see that SLDS styles have begun to be applied.
- Switch back to Salesforce Classic and click the Leads tab again. Notice that you now have Lightning styles within your Salesforce Classic environment.
We will address that issue in the next exercise.
Not working as expected? Check out this file to see what the code should look like at this stage. Feel free to cut and paste it in your own page.