Frameworks
The Carbon React library provides front-end developers and engineers a collection of reusable React components to build websites and user interfaces. Adopting the library enables developers to use consistent markup, styles, and behavior in prototype and production work.
Resources
Install
If you prefer Yarn:npm install @carbon/react --save
yarn add @carbon/react
Getting started
These components require the use of webpack, or a similar module bundler such as Vite, in your project.
Components do not import any of the styles themselves. Styles are provided through
@carbon/react
as Sass modules. You will likely need to install the Dart Sass package.
npm install sass --save-dev// or via yarn:yarn add sass --dev
- Once
sass
is added and configured,@use
the SCSS to bring in styling within anindex.scss
.
./index.scss@use '@carbon/react';
- In most cases you’ll need to import this file within the root file of your app
./main.jsximport './index.scss';import React from 'react';import ReactDOM from 'react-dom';import App from './App';ReactDOM.render(<React.StrictMode><App />
- Import components and begin building!
./App.jsximport { Button } from '@carbon/react';import React from 'react';function App() {return (<div><Button>Hello world</Button></div>);
Development
Please refer to the Contribution Guidelines before starting any work.
Using the server
We recommend the use of React Storybook for developing components.
yarn storybook
Open browser to
http://localhost:9000/
.Develop components in their respective folders (
/components
or/internal
).Write stories for your components in
/.storybook
.
List of available components
View available React Components here. Usage information is available when you select “Docs”.
Troubleshooting
If you experience any issues while getting set up with @carbon/react
, please
head over to the
GitHub repo
for more guidelines and support. Please
create an issue if your
issue does not already exist.