storybook: showRoots Setting Does Not Work as Expected
Describe the bug When utilizing showRoots, not getting the expected result in Storybook navigation when using default export and named export or name param on a story.
To Reproduce Steps to reproduce the behavior:
- Set
showRootstotrue - Create a story similar to what is under Code snippets.
- See error
Expected behavior Expected: Root-level Components title, My Button nav item Result: Collapsible Components item, My Button sub-nav item
See Screenshots for expected result vs actual result.
Screenshots
Expected:

Actual:

With Unwanted Collapsible Nav Item:

Code snippets
export default {
title: 'Components'
};
export const Button = () => <Button {...} />;
Button.story = {
name: 'My Button',
};
Additional context The only way I’m able to get showRoots to work is if I add an additional 3rd collapsible item in the title of the default export. For example, I’d have to do:
export default {
title: 'Components/Buttons'
};
export const Button = () => <Button {...} />;
Button.story = {
name: 'My Button',
};
This creates an unwanted collapsible item Buttons in the navigation (See 3rd screenshot attached). Reading the documentation, showRoots seems to be the setting we would use to enforce the default export title would always appear as expected, but it doesn’t seem to work as expected. Thanks for all the awesome work you all do on this project!
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 1
- Comments: 21 (11 by maintainers)
Would be nice if anyone could post a one-stop comment detailing how to set up the stories structure so that we can get that gray section heading @danielyearwood originally posted. I am not really interested in how the
showRootsoption works exactly, just wanna get the visual effect. Scrolled through the whole discussion thread and couldn’t seem to find that.@shilman I do want the visual treatment that comes with it. Without it, how would I achieve the bold top-level treatment for each section of the navigation and also the spacing between each section? That visual hierarchy helps to improve the readability and usability of the navigation, so I’m looking to preserve that. From what I’ve been able to tell, if I don’t do that, then everything is lumped together in a long list which makes it harder for an end user to tell that these are sections of grouped content. Instead it appears as if everything is related to each other. It’s hard to convey with bullet points. Here’s a better example of what I’m looking to achieve: