基本要素
Storybook essentials 是一套工具,可帮助你在 Storybook 中构建、测试和记录组件。它包含以下内容:
¥Storybook essentials is a set of tools that help you build, test, and document your components within Storybook. It includes the following:
配置
¥Configuration
Essentials 为“零配置”。它附带一个开箱即用的推荐配置。
¥Essentials is "zero-config”. It comes with a recommended configuration out of the box.
上述许多功能都可以通过 参数 进行配置。有关更多详细信息,请参阅每个功能的文档(上面有链接)。
¥Many of the features above can be configured via parameters. See each feature's documentation (linked above) for more details.
禁用功能
¥Disabling features
如果你需要禁用任何基本功能,你可以通过更改 .storybook/main.js|ts 文件来实现。
¥If you need to disable any of the essential features, you can do it by changing your .storybook/main.js|ts file.
例如,如果你想禁用 背景功能,你可以将以下更改应用于你的 Storybook 配置:
¥For example, if you wanted to disable the backgrounds feature, you would apply the following change to your Storybook configuration:
// Replace your-framework with the framework you are using, e.g. react-vite, nextjs, vue3-vite, etc.
import type { StorybookConfig } from '@storybook/your-framework';
const config: StorybookConfig = {
framework: '@storybook/your-framework',
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
features: {
backgrounds: false, // 👈 disable the backgrounds feature
},
};
export default config;你可以为每个单独的功能使用以下键:actions、backgrounds、controls、highlight、measure、outline、toolbars 和 viewport。
¥You can use the following keys for each individual feature: actions, backgrounds, controls, highlight, measure, outline, toolbars, and viewport.
