The following tasks will help you get started using Design System React within Create React App 1.x. If you are using Create React App 2.x, please follow this instruction link https://github.com/salesforce/design-system-react/blob/master/docs/create-react-app-2x.md
Do you have tips to share with other Create React Users users? Please share with the rest of the Create React community and add to the list below.
- Create a new app
create-react-app my-react-app
- Install NPM modules
cd my-react-app && npm install @salesforce-ux/design-system @salesforce/design-system-react
- Copy SLDS CSS file to
public
foldercp node_modules/@salesforce-ux/design-system/assets/styles/salesforce-lightning-design-system.min.css public/
- Copy SLDS icons folder to
public
foldercp -r node_modules/@salesforce-ux/design-system/assets/icons public/
- Copy SLDS fonts folder to
public
foldercp -r node_modules/@salesforce-ux/design-system/assets/fonts public/
- Add CSS file to
index.html
<link rel="stylesheet" type="text/css" href="/salesforce-lightning-design-system.min.css">
- Copy examples from Design System React website into
app.js
. - Update imports to named imports (CommonJS build) of Design System React.
import { Button, IconSettings } from '@salesforce/design-system-react';
- Modify the
iconPath
prop ofIconSettings
to output the correct path to the icons in the public folder.<IconSettings iconPath="/icons">{// doc site examples}</IconSettings>