Hey Please try it :
Using Decorators: Storybook allows the use of decorators that essentially wrap stories with extra markup or components. You can utilize a decorator to switch between different styles:
import { withCssResources } from '@storybook/addon-cssresources';
export default {
title: 'Your Story',
decorators: [withCssResources],
parameters: {
cssresources: [{
id: dark,
code: <style>${require('!to-string-loader!css-loader!sass-loader!src/styles/themes/kendo-dark.scss')}</style>,
picked: true,
},
{
id: light,
code: <style>${require('!to-string-loader!css-loader!sass-loader!src/styles/themes/kendo-light.scss')}</style>,
picked: false,
}],
}
}
Then, you can switch between the two styles using the CSS Resources addon panel.
Note: To use the CSS Resources addon, you'll need to install it with npm install @storybook/addon-cssresources and add it to your addons list in .storybook/main.js:
module.exports = {
addons: ['@storybook/addon-cssresources/register'],
};
Switching themes using parameters: If you'd like to switch the entire theme of your Storybook based on parameters, you could use something like:
export default {
title: 'Your Story',
parameters: {
themes: {
default: 'light',
list: [
{ name: 'light', class: 'kendo-light', color: '#ffffff' },
{ name: 'dark', class: 'kendo-dark', color: '#000000' },
],
Decorator: Story => {
const themeClass = document.querySelector('body').getAttribute('class');
require(src/styles/themes/${themeClass}.scss);
return <Story />;
},
},
},
};
This method may require custom webpack configuration to ensure that the require statement correctly processes the SCSS files.
might be helpful to check this link: https://storybook.js.org/docs/angular/configure/features-and-behavior