
Product
Introducing Socket Fix for Safe, Automated Dependency Upgrades
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
storybook-theme-switch-addon
Advanced tools
Switch easily between multiple themes declared in your css files
This addon allows you to switch easily between multiple themes declared in your CSS files. It's especially useful in Tailwind CSS if you have more themes in separate files.
In addition, on every theme change, your URL updates with a query param that points currently selected theme.
The idea and code parts were inspired by storybook-stylesheet-toggle addon.
Install the package:
npm i storybook-theme-switch-addon
Add the next addon to your .storybook/main.(js,ts)
file:
module.exports = {
addons: ["storybook-theme-switch-addon"],
};
Configure your themes in .storybook/preview.(js,ts)
by adding globalTypes to preview object:
globalTypes: {
stylesheets: {
themes: [
{
id: "primary-theme",
title: "Primary theme",
url: "./primary-theme.css",
},
{
id: "secondary-theme",
title: "Secondary theme",
url: "./secondary-theme.css",
},
{
id: "tertiary-theme",
title: "Tertiary theme",
url: "./tertiary-theme.css",
},
],
},
},
Remember to configure your storybook to serve static files in public
directory:
const config: StorybookConfig = {
{...options},
staticDirs: ["../public"],
};
yarn start
runs babel in watch mode and starts Storybookyarn build
build and package your addon codeFAQs
Switch easily between multiple themes declared in your css files
The npm package storybook-theme-switch-addon receives a total of 647 weekly downloads. As such, storybook-theme-switch-addon popularity was classified as not popular.
We found that storybook-theme-switch-addon 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.
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.
Product
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
Security News
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.
Product
We’re excited to announce a powerful new capability in Socket: historical data and enhanced analytics.