Skip to content

Latest commit

Β 

History

7,640 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Lightning Design System for React

Accessible, localization-friendly, presentational React components

🚧 Modernization in Progress β€” This library is being updated to React 19, TypeScript, and modern tooling. Most components are ready, but some features are still being completed. See ROADMAP.md for details.

Now with SLDS 2 and Dark Mode support!

Highlights

  • SLDS 2 Compatible β€” Works with the latest Salesforce Lightning Design System
  • Dark Mode β€” Built-in dark mode support with prefers-color-scheme detection
  • React 19 β€” Modern React with functional components and hooks
  • TypeScript β€” Full type definitions for improved developer experience
  • Accessible β€” WCAG 2.1 AA compliant with keyboard navigation and screen reader support

Install

npm install @salesforce/design-system-react

Note: SLDS 2 styles are currently bundled with this package. When the official SLDS 2 npm package is released, you'll install it separately.

Requirements

  • Node.js: >= 20.19.0 (or >= 22.12.0)
  • React: 19.x

Getting Started

Welcome to this community-supported project! This library is the React implementation of the Salesforce Lightning Design System.

Usage

ES Modules (Recommended)

import { Button, IconSettings } from '@salesforce/design-system-react';

function App() {
  return (
    <IconSettings iconPath="/assets/icons">
      <Button label="Hello Button" />
    </IconSettings>
  );
}

Individual Component Imports

For tree-shaking and smaller bundles:

import Button from '@salesforce/design-system-react/components/button';
import IconSettings from '@salesforce/design-system-react/components/icon-settings';

Styling

Add the SLDS 2 stylesheet to your page from the official @salesforce-ux/design-system-2 package. The bundled Lightning Blue theme is the SLDS 2 default (Cosmos is the alternate):

<link
  rel="stylesheet"
  href="/node_modules/@salesforce-ux/design-system-2/dist/css/bundled/slds2.lightning-blue.css"
/>

Note: This replaces the previously bundled slds-plus.css stopgap. Styling now comes from the published SLDS 2 npm package. Storybook is wired up the same way β€” see .storybook/preview-head.html.

Using SLDS 1 instead?

If you need SLDS 1 compatibility, use the original design system package:

<link 
  rel="stylesheet" 
  href="/node_modules/@salesforce-ux/design-system/assets/styles/salesforce-lightning-design-system.min.css" 
/>

Dark Mode

Dark mode is supported out of the box. Components automatically respond to SLDS dark mode styling when you apply the appropriate theme class:

<!-- Light mode (default) -->
<div class="slds-scope">...</div>

<!-- Dark mode -->
<div class="slds-scope slds-theme_dark">...</div>

Components also respect the user's system preference via prefers-color-scheme when configured with the SLDS theme tokens.

Icons

Icons are loaded from external SVG sprite files. Set the path with <IconSettings>:

import IconSettings from '@salesforce/design-system-react/components/icon-settings';

ReactDOM.createRoot(document.getElementById('root')!).render(
  <IconSettings iconPath="/assets/icons">
    <App />
  </IconSettings>
);

Serve the icons from your public folder:

// Express.js example
app.use('/assets/icons', express.static('node_modules/@salesforce-ux/design-system/assets/icons/'));

Development

Prerequisites

  • Node.js >= 20.19.0
  • npm >= 10.x

Setup

git clone [email protected]:salesforce/design-system-react.git
cd design-system-react
npm install

Commands

Command Description
npm run dev Start Vite dev server
npm run storybook Start Storybook at http://localhost:6007
npm run test Run tests with Vitest
npm run test:ui Run tests with Vitest UI
npm run lint Lint all files
npm run typecheck TypeScript type checking
npm run build Build the library

Tech Stack

Accessibility

This library follows WCAG 2.1 guidelines and is tested for accessibility.

  • Automated testing with axe-core
  • Keyboard navigation support
  • Screen reader compatibility (JAWS, NVDA, VoiceOver)
  • ARIA attributes and roles

Security

Please report any security issues to [email protected].

Contributing

Please read CONTRIBUTING.md before submitting pull requests.

Got Feedback?

License

Releases

Packages

Used by

Contributors

Languages