You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Storybook v7:如何让示例故事仅在Docs标签展示而非单独标签

解决Storybook v7中故事仅显示在Docs标签的方法

在Storybook v7里,要让Example故事只出现在Docs标签内、不生成独立的标签页,只需要给该故事添加tags: ['docsOnly']配置即可。

修改后的Component.stories.tsx代码如下:

const meta: Meta<typeof Component> = {
  title: 'Component',
  component: Component,
};
export default meta;
type Story = StoryObj<typeof Component>;

export const Example: Story = {
  args: {
    title: 'Component Title',
  },
  // 添加这行配置
  tags: ['docsOnly']
};

添加docsOnly标签后,这个示例故事就不会在导航栏和组件页面生成单独的标签,只会作为Docs标签里的内置示例展示,刚好满足你不想重复显示的需求。

内容的提问来源于stack exchange,提问作者marcus-linmarkson

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.20 20:32:35