如何在React版Storybook的CSF格式故事中添加说明文案?
你可以直接用Storybook CSF规范内置的 parameters.docs.description.story 字段给单个故事添加说明文案,该字段支持原生Markdown语法,渲染后会显示在对应故事的文档区域,完全不会混入代码示例中。
针对你的场景,写法如下:
export const FewAssets = (args) => ( <Selector assets={[fixtures[0], fixtures[1]]} /> ); FewAssets.args = {}; FewAssets.parameters = { docs: { description: { story: `### Few Assets With only a few assets, the slider works the same way but without moving the thumbnails. ` } } };
如果你需要给整个组件级添加统一的说明文案,写在默认导出的 parameters.docs.description.component 字段即可:
export default { title: 'Components/Selector', component: Selector, parameters: { docs: { description: { component: '此处为组件整体说明,会展示在所有故事的文档顶部' } } } }
你所用的6.3.x版本已经完整支持该配置,无需额外安装依赖或调整其他配置。
内容的提问来源于stack exchange,提问作者Sir Robert
相关产品推荐
相关产品推荐

