tags
¥Parent: main.js|ts configuration
类型:{ [tagName: string]: { defaultFilterSelection?: 'include' | 'exclude' } }
¥Type: { [tagName: string]: { defaultFilterSelection?: 'include' | 'exclude' } }
为你的故事定义自定义 tags,或更改内置标签的默认配置。
¥Define custom tags for your stories, or alter the default configuration of built-in tags.
// 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)'],
tags: {
// 👇 Define a custom tag named "experimental"
experimental: {
defaultFilterSelection: 'exclude', // Or 'include'
},
},
};
export default config;[tagName]
类型:string
¥Type: string
标签名称。这可以是任何静态(即非动态创建)字符串,可以是内置标签,也可以是你自己设计的自定义标签。
¥The name of the tag. This can be any static (i.e. not created dynamically) string, either a built-in tag or a custom tag of your own design.
[tagName].defaultFilterSelection
类型:'include' | 'exclude'
¥Type: 'include' | 'exclude'
设置 Storybook 侧边栏中标签的默认筛选选择状态。如果设置为 include,则带有此标签的故事将被包含在内。如果设置为 exclude,则带有此标签的故事将被排除,必须通过在侧边栏筛选菜单中选择该标签才能显式包含。如果未设置,则该标签没有默认选项。
¥Set the default filter selection state for a tag in the Storybook sidebar. If set to include, stories with this tag are selected as included. If set to exclude, stories with this tag are selected as excluded, and must be explicitly included by selecting the tag in the sidebar filter menu. If not set, the tag has no default selection.

