This addon for storybook allows you to change the theme used with Carbon
Components!
Supports
React
Vue
No reason to suspect others are not supported, but have not been tested. If you
use with another framework then please post an update to the README.md.
We are always looking for contributors to help us fix bugs, build new features,
or help us improve the project documentation. If you're interested, definitely
check out our
Contributing Guide
and
Carbon's Developer Handbook!
👀
Usage
.storybook/main.js:
module.exports = {
// other addons...addons: ['@carbon/storybook-addon-theme/preset.js'],
};
Global Decorator
.storybook/preview.js:
import { withCarbonTheme } from'@carbon/storybook-addon-theme/withCarbonTheme';
import {
PARAM_KEYasCARBON_THEME_PARAM_KEY,
CARBON_THEMES,
} from'@carbon/storybook-addon-theme/constants';
const decorators = [
/// other decorators...
withCarbonTheme,
];
const globals = {
// other globals...// default value of the theme selector
[CARBON_THEME_PARAM_KEY]: CARBON_THEMES.g10,
};
export { decorators, globals };
SCSS
.storybook/index.scss
Carbon 11
@use'@carbon/styles' as styles;
@use'@carbon/styles/scss/theme' as *;
[storybook-carbon-theme] {
@include styles.theme(styles.$white);
/* make sure background and color are set if theme in use */background-color: $background;
color: $text-primary;
}
[storybook-carbon-theme='g10'],
.sb--use-carbon-theme-g10 {
@include styles.theme(styles.$g10);
}
[storybook-carbon-theme='g90'],
.sb--use-carbon-theme-g90 {
@include styles.theme(styles.$g90);
}
[storybook-carbon-theme='g100'],
.sb--use-carbon-theme-g100 {
@include styles.theme(styles.$g100);
}
This package uses IBM Telemetry to collect de-identified and anonymized metrics
data. By installing this package as a dependency you are agreeing to telemetry
collection. To opt out, see
Opting out of IBM Telemetry data collection.
For more information on the data being collected, please see the
IBM Telemetry documentation.
We found that @carbon/storybook-addon-theme demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.It has 0 open source maintainers collaborating on the project.
Package last updated on 06 Nov 2024
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.