Create a custom CSS file to use the Lightning Design System in Visualforce.
To use the Design System in Visualforce you have two options:
<apex:slds />to your page and wrap your code in a container
<div class="slds-scope"> ... </div>.
See this code in context on Trailhead and learn more in our Visualforce Developer Guide.
- Or (not recommended…): create a CSS file with a custom scoped outer wrapper. A tool to create your custom CSS is available here.
If you want to dive straight in, here are a few things to note when working with the Lightning Design System in Visualforce:
- When using the component sample code from this site, be sure to replace all static resource paths with the Visualforce URLFOR syntax, as summarized in the FAQ.
- Apex tags such as
- To use the SVG spritemap icons, add the attributes
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"to the
<html>element as documented in the Trailhead module. Do not add the attributes to individual
<svg>elements as can cause a page rendering bug.
- To use SVG spritemap image icons with Internet Explorer, use the svg4everybody script.
- Currently, if you need to use the Salesforce header or sidebar, you can not specify the
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"on the
<html>element. In this case, the SVG icons are not supported.
Details on all the above, as well as introductions to many of the Lightning Design System components, are documented in the Trailhead module.
Finally, we’d love to hear your feedback. Please share your thoughts about any aspect of the Lightning Design System via our GitHub issues.