Storybook addon
Design token storybook addonInstallation
| Install | yarn add @atlaskit/storybook-addon-design-system |
|---|---|
| Source | Bitbucket.org, (opens new window) |
| npm | @atlaskit/storybook-addon-design-system, (opens new window) |
| Bundle | unpkg.com, (opens new window) |
Storybook v8
Install a latest v1 version of the addon (e.g.,
1.1.0).Register the addon with your Storybook configuration in the
.storybook/main.jsfile.module.exports = { addons: [ + '@atlaskit/storybook-addon-design-system' ] };
By default, the theme is set to auto (which matches the browser's theme). However, you can easily
override this default by specifying a custom theme using the adsTheme parameter in your
.storybook/preview.js file.
Example Usage
In your .storybook/preview.js file, you can set the adsTheme parameter to either 'light' or
'dark':
const preview: Preview = {
parameters: {
adsTheme: 'light' | 'dark',
}
// ... other parameters
}
export default preview;
Storybook v7
Install a pre-1.0 version of the addon (e.g.,
0.8.0).Register the addon with your Storybook configuration in the
.storybook/main.jsfile.module.exports = { addons: [ + '@atlaskit/storybook-addon-design-system' ] };Initialise the
globalTypes.adsThemeproperty in the global contextDisable the built in
backgroundsadd on, as it conflicts with the ADS theming
Both step 3 and step 4 can be done in
the preview.js file:
+ import { withDesignTokens } from '@atlaskit/storybook-addon-design-system';
const preview = {
globalTypes: {
+ adsTheme: {
+ description: 'Atlassian Design System theming options',
+ defaultValue: 'light',
},
},
decorators: [
+ withDesignTokens
],
parameters: {
+ /**
+ * Disabling the builtin backgrounds addon so it doesn't override the ADS theming
+ * See: https://storybook.js.org/docs/essentials/backgrounds#disable-backgrounds
+ */
+ backgrounds: { disable: true },
},
};
export default preview;
Storybook v6 and below
Install a pre-1.0 version of the addon (e.g.,
0.8.0).Register the addon with your Storybook configuration in the
.storybook/main.jsfile.module.exports = { addons: [ + '@atlaskit/storybook-addon-design-system' ] };Add the decorator to
.storybook/preview.js, which is responsible for applying the logic which has the ability to modify the DOM of your stories.+ import { withDesignTokens } from '@atlaskit/storybook-addon-design-system'; const { addDecorator } = require('@storybook/react'); + addDecorator(withDesignTokens);