storybook an open source tool used to build test and visualize ui components in isolation modern web developers love component frameworks because they organize html css and javascript code into reusable chunks like lego bricks however a complex codebase can still easily descend into chaos causing components to lose their meaning in life storybook allows developers to extract components into a sandbox where they can be explored and tested without distractions instead of viewing components through the lens of a giant complex component tree that is your application you get a guidebook that breaks everything down individually no need to
worry about data dependencies or business logic this makes it much easier to share your work with other developers or clients who can validate that things actually work the way they're supposed to in addition it has a test runner based on jest and playwright that can automatically verify whether your component renders without errors and also validate concerns like accessibility measure performance and can even do visual regression testing in the cloud to pinpoint everything you broke with that last css tweak to get started create a project with your favorite front-end framework like react angular view spelt and
so on or open an existing one then run npx storybook init next find a ui component then create a matching file ending dot stories.js a story is just a function that describes how to render the component in many cases a component will have multiple different variations to show in the story export a function for each one of these variations that works but we can actually change the arguments to a component dynamically directly in the ui by creating a template that maps arguments to the component we can now change the component's behavior on the fly directly
in the storybook ui it's also possible to write stories in markdown with mdx this allows you to not only visualize the component but also document it at the same time and there's a huge collection of add-ons to customize the behavior of your storybook you might use actions to keep track of browser events or viewport to analyze components on responsive layouts and the measure add-on can help you visually debug css layout and alignment issues within your stories when it comes to testing you could spot check with your own eyeballs or use the test runner to write
automated tasks and run them on your ci server and finally share your work with the world by publishing it as a static web application this has been storybook in 100 seconds hit the like button if you want to see more short videos like this thanks for watching and i will see you in the next one