Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

271
Views
Sorting in Storybook: Possible to force an order for nested stories?

My Storybook uses the following grouping for stories:

Introduction
Styleguide
Atoms
  Component
    ๐Ÿ“„ README
    ๐Ÿ“ Examples
  Component
    ๐Ÿ“„ README
    ๐Ÿ“ Examples
Molecules
  Component
    ๐Ÿ“„ README
    ๐Ÿ“ Examples
Organisms
  Component
    ๐Ÿ“„ README
    ๐Ÿ“ Examples
  • Basically three groups: Atoms, Molecules, and Organisms.
  • Each group should have alphabetized components. This currently works.
  • Each component has a README mdx file, and then all stories nested under Examples.

Iโ€™m currently sorting stories like this:

options: {
    storySort: {
        method: 'alphabetical',
        order: ['Introduction', 'Styleguide', 'Atoms', 'Molecules', 'Organisms'],
        locales: 'en-US',
    }
},

This gets me close, but the README and Examples within component stories appear in alphabetical order when I want README to appear first.

Is this possible?

about 4 years ago ยท Juan Pablo Isaza
1 answers
Answer question

0

I had a similar problem, and I could find a way of doing as you requested, after finding this info on the storybook documentation: enter image description here

For your specific case, I think that you could do something like this:

options: {
    storySort: {
        method: 'alphabetical',
        order: ['Introduction', 'Styleguide', 'Atoms', ['Readme', '*'], 'Molecules', ['Readme', '*'], 'Organisms', ['Readme', '*']],
        locales: 'en-US',
    }
},

Basically, you just have to add , ['Readme', '*'] after every group that you like to sort by using the Readme first custom order. This just indicates storybook to display the Readme story first, and then the rest of the stories.

This approach solves the problem, but I think that the solution could be improved by writing your own storySort functions, as indicated on this comment in github

I hope this answer would be helpful for your scenario too.

Regards

about 4 years ago ยท Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
ยฉ 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!