加入直播:美国东部时间周四上午 11 点,Storybook 9 发布 & 答疑

主题切换插件

Storybook 插件,用于切换主题

在 Github 上查看

Storybook 主题切换插件

示例样式

:root {
  --white: #fff;
  --black: #000;
}

:root [data-theme="dark"] {
  --white: #000;
  --black: #fff;
}

安装

npm i -D theme-switcher-addon

将插件添加到 .storybook/main.js

module.exports = {
  addons: ["theme-switcher-addon"],
};

将参数选项添加到 .storybook/preview.js

export const parameters = {
  theme: {
    selector: ".your-selector",
    dataAttr: "data-your-attribute",
  },
};

使用方法

点击工具栏中的新主题切换按钮来切换主题。

作者
  • belv2c
    belv2c
适用于
    Angular
    React
    Vue
标签