Skip to content

Storybook 8: How to render multiple components inside a single <Canvas/> #26683

Answered by JReinhold
dmitriybo asked this question in Help
Discussion options

You must be logged in to vote

8.1 introduces a new Tags feature that provides a viable workaround for this.

https://storybook.js.org/docs/writing-stories/tags

You can write a story that renders whatever you want, ie. render your button 10 times with different variants in the same story. Then reference that with <Canvas of={ButtonStories.AllButtonVariants} />. Finally, give the story the tags ["!dev", "!test"] to exclude it from the sidebar and test-runner tests.

This isn't exactly what you're asking for, but for anyone out there that want a more flexible canvas that can render more stories/content, please open an RFC that details which problems you want solved and how the existing solutions are inadequate.

Replies: 3 comments 6 replies

Comment options

You must be logged in to vote
4 replies
@dmitriybo
Comment options

@valentinpalkovic
Comment options

@Mauladen
Comment options

@dmitriybo
Comment options

Comment options

You must be logged in to vote
2 replies
@dev-nicolaos
Comment options

@JReinhold
Comment options

Answer selected by shilman
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
6 participants