- Notifications
You must be signed in to change notification settings - Fork434
Salesforce Lightning Design System for React
License
salesforce/design-system-react
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
$ npm install @salesforce-ux/design-system @salesforce/design-system-react
Welcome to this community-supported project! 👋 This library is theReact implementation of theSalesforce Lightning Design System. This library has a peer dependency on@salesforce-ux/design-system
,react
, andreact-dom
. It is tested with React 16 and has a stable API despite its version number. Pleasepolyfill this library in order to meet your target environment needs.
- Usage
- Getting started
- Documentation and interactive examples
- Contributing
- Codebase overview
- Create React App setup
- Browser compatibility and polyfills
- Usage with Webpack
- Open Sourcing Design System React - Medium article
For a no hassle setup and compatibility with Create React App, transpiled ES6 and CommonJS module versions have been included within the NPM package. If using this setup, please re-write theimport
statement in the documentation site examples. Use the following namedimport
syntax to access the transpiled components from/lib/index.js
:
import { Button } from '@salesforce/design-system-react';<Button label="Hello Button" />
Please viewCreate React App Setup for more information on using this library with Create React App.
Advanced usage requires that your babel presets are set up correctly.create-react-app
and environments that do not transpile code withinnode_modules
are not compatible with the component import below. All the examples on thedocumentation site use this syntax. You can use the Babel preset,@salesforce/babel-preset-design-system-react
, to get started.This preset will keep Babel compatible with Design System React and allow ES6 module benefits such as tree-shaking. This library is not browser-ready and should be polyfilled to your target environment.
import Button from '@salesforce/design-system-react/components/button';<Button label="Hello Button" />
{"presets": ["@salesforce/babel-preset-design-system-react"]}
The current preset version is only compatible with Babel 6. Please see thisissue comment for Babel 7.
This library does not contain any Cascading Style Sheets (CSS). You will need to add<link rel="stylesheet" type="text/css" href="/node_modules/@salesforce-ux/design-system/assets/styles/salesforce-lightning-design-system.min.css" />
to your page and serve that file from a publicly available folder.
Typically, scripts should be downloaded in the background without blocking the DOM. With React, this works best withserver side rendering. SLDS recommends placeholder stencils while scripts are initializing if the HTML cannot be served immediately. If you can serve the HTML, then icon SVGs should not be bundled and served like any other file. Set a pathcontext
for all child components with<IconSettings>
at the top of your render tree:
import IconSettings from '@salesforce/design-system-react/components/icon-settings';ReactDOM.render( <IconSettings iconPath="/assets/icons"> <MyApp /> </IconSettings>, document.getElementById('app'))// `/assets/icons` will be prepended to `/standard-sprite/svg/symbols.svg#account` within the SVG path<svg aria-hidden="true"> <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/assets/icons/standard-sprite/svg/symbols.svg#account"></use></svg>
// ExpressJS exampleapp.use('/assets/icons', express.static('node_modules/@salesforce-ux/design-system/assets/icons/'));
If you use a module bundler, like Webpack, you can let your module bundler manage SVG sprite file paths and send that path into<IconSettings>
. This requires configuring your module bundler to manage your public assets.
import IconSettings from '@salesforce/design-system-react/components/icon-settings';import standardSprite from '@salesforce-ux/design-system/assets/icons/standard-sprite/svg/symbols.svg';......ReactDOM.render( <IconSettings standardSprite={standardSprite}> <MyApp /> </IconSettings>, document.getElementById('app'))
Prior to v0.7.0, SLDS icons were bundled with the JavaScript. The 400KB+ icons bundle fromSLDS is no longer included. You will need to download the SLDS CSS and icons separately.
Bundled script files are providedonly for convenience. Do not use in production.
design-system-react.min.js
(700KB+) - includes icons in the JavaScriptdesign-system-react-components.min.js
(~400KB) - no icons.
git clone git@github.com:salesforce/design-system-react.gitcd design-system-reactnpm installnpm startopen http://localhost:9001 http://localhost:8001
Please read theCONTRIBUTING.md andTest README first. Then, create an issue to tell others you are working on a bug. If you would like to contribute a new component, create an issue with a list of proposed props to discuss with maintainers. Issues not addressed with pull requests may be closed eventually. Check outwho's contributing to the project.
Audit conducted in November, 2019 on all current component examples not intended solely for testing by Salesforce Marketing Cloud (MC) Accessibility Specialist and project team.
- Methods: Automated testing with axe; Manual testing with keyboard, JAWS, and NVDA
- Results: 100% accessibility
Quarterly audits will be conducted beginning Feb 1, 2020 on any new or updated components by MC Accessibility Specialist.
- Methods: Automated testing with axe; Manual testing with keyboard, JAWS, and NVDA
- Goal: 100% accessibility
Project team will conduct internal accessibility testing in development process for new and updated components.
If you have support questions, please post a question toStackOverflow and tag withdesign-system-react
. If you find any bugs, create aGitHub Issue.
Please report any security issue tosecurity@salesforce.com as soon as it is discovered. This library limits its runtime dependencies in order to reduce the total cost of ownership as much as can be, but all consumers should remain vigilant and have their security stakeholders review all third-party dependencies.
Thank you to all the contributors to this one ofmany open source projects at Salesforce, but special thanks to the following:
- @garygong Gary Gong
- @kevinparkerson Kevin Parkerson
- @interactivellama Stephen James
- @davidlygagnon David Ly-Gagnon
- @futuremint David Woodward
- @donnieberg Donielle Berg
- @tweettypography David Brainer
- @ivanbogdanov Ivan Bogdanov
- Source code is licensed underBSD 3-Clause
- All icons and images are licensed underCreative Commons Attribution-NoDerivatives 4.0
- The Salesforce Sans font is licensed under ourfont license
About
Salesforce Lightning Design System for React
Topics
Resources
License
Code of conduct
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.