Sorry, but you either have no stories or none are selected somehow.
If the problem persists, check the browser console, or the terminal you've run Storybook from.
Carbon is available as an npm package, install it into your project with:
You will need to install the following dependencies in your project, these are peer-dependencies of carbon-react and are required.
There is a peer dependency on draft-js
any project intending to use either the TextEditor
or Note
components is required to install it as well.
We recommend using our global stylesheet which could be imported:
then the GlobalStyle
component could be placed next to the content of the app:
Carbon requires the Sage UI
and CarbonIcons
fonts to display correctly. These will not be automatically loaded by Carbon, so you will be required to load these into your application yourself.
Your build system must support CSS and file loading for this to work, e.g. webpack
with css-loader
and file-loader
. This is pre-configured if you are using create-react-app
, but it is possible to use other bundling solutions such as parceljs
if you wish.
The font face definitions for both fonts are included in Carbon and can be directly imported into your code using one of the following snippets:
Note the Sage UI
font files themselves are loaded from the @sage/design-tokens library. If this has not been installed in your project beforehand, text will be rendered in the browser's default sans-serif font.
React and React DOM are imported from the React library, which forms the basis for Carbon's components.
Carbon supports two theming systems - the latest which uses Design Tokens in form of CSS custom properties maintained by designers, and legacy themes which use old theme properties from the ThemeProvider from the styled-components library. Currently both systems are being supported to aid projects using older versions of Carbon with upgrading.
The themes available in Carbon include:
@sage/design-tokens
library, otherwise styles fallback to the old mint theme for compatability.Carbon provides the Carbon Provider component that uses the ThemeProvider
from the styled-components library to supply theme styles to your components. Themes are defined within the Carbon library and can be imported like the following snippet. mintTheme
is provided by default.
Default mintTheme
:
The latest sageTheme
:
A basic project index.js
file would resemble this example.
This can also be found in our Codesandbox template.