{
    "componentChunkName": "component---src-templates-blog-post-tsx",
    "path": "/blog/2017-12-29-quickly-build-component-libraries-with-storybook/",
    "result": {"data":{"blogPost":{"title":"Quickly Build Component Libraries with Storybook","slug":"/blog/2017-12-29-quickly-build-component-libraries-with-storybook/","authorNodes":[{"name":"Jeffrey Cherewaty","slug":"/people/jeffrey-cherewaty/"}],"markdown":{"html":"<p>As long as humans have been building things, we've tried to break up the work. When we can carve out smaller tasks, we can share the work among more people and focus on the quality of each little piece.</p>\n<p>Tools and technologies have reached a point where nearly everyone building for the web is thinking in components. But when you've got a large team all creating and using components, how do you keep the usage consistent? Designers have had a tool for that problem for decades. Style guides set down rules and guidelines for projects, so they spoke with a consistent look and voice.</p>\n<p>By combining a style guide with a library of components, you can create a comprehensive design system.</p>\n<h2 id=\"enter-storybook\" style=\"position:relative;\"><a href=\"#enter-storybook\" aria-label=\"enter storybook permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Enter Storybook</h2>\n<p>Prominent companies that have built large design systems usually have to build all new tools for their component libraries. When you have multiple templating languages to deal with and dozens of different product teams, your design system has constraints that no out-of-the-box solution provides.</p>\n<p>At Frontside, we're frequently working on brand-new projects instead, so we push open-source solutions that let developers immediately focus on delivering features. For component libraries featuring Vue or React, there's now a one-size-fits-most tool: <a href=\"https://storybook.js.org\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Storybook</a>.</p>\n<h2 id=\"writing-stories\" style=\"position:relative;\"><a href=\"#writing-stories\" aria-label=\"writing stories permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Writing Stories</h2>\n<p>With Storybook, developers create \"stories\" that illustrate and describe different versions of each component. In practice, it feels a lot like writing tests: what are all the possible iterations of this component? Because it aligns with test-driven development philosophy, Storybook makes a great base for adding visual regression testing.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">import React from 'react';\nimport { storiesOf } from '@storybook/react';\nimport Checkbox from './Checkbox';\n\nstoriesOf('Checkbox', module)\n  .add('Basic Usage', () => (\n    &lt;Checkbox\n      onChange={() => {}}\n      checked=true\n      label='Check Me'\n    />\n  ));</code></pre></div>\n<p><a href=\"https://storybook.js.org/basics/writing-stories/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Storybook Docs: Writing Stories</a></p>\n<h2 id=\"addons\" style=\"position:relative;\"><a href=\"#addons\" aria-label=\"addons permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Addons</h2>\n<p>Storybook's addon architecture is where the benefits of having an open-source project really pay off. There's a whole ecosystem of pre-built addons, along with the ability to create your own.</p>\n<h3 id=\"readme-addon\" style=\"position:relative;\"><a href=\"#readme-addon\" aria-label=\"readme addon permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>README addon</h3>\n<p>The codebase we're working with already had great documentation for many of its components. With <a href=\"https://github.com/tuchk4/storybook-readme\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><code class=\"language-text\">storybook-readme</code></a>, just a couple lines of configuration had each component's README appear in the Storybook environment</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">import Readme from './README.md';\n\nstoriesOf('Checkbox', module)\n  .addDecorator(withReadme(Readme))</code></pre></div>\n<h3 id=\"add-a-knob\" style=\"position:relative;\"><a href=\"#add-a-knob\" aria-label=\"add a knob permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Add a knob</h3>\n<p>Another useful Storybook addon: <a href=\"https://github.com/storybooks/storybook/tree/master/addons/knobs\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><code class=\"language-text\">storybook-knobs</code></a>. Component props can be edited within the Storybook UI.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">import { withKnobs, text } from '@storybook/addon-knobs';\n\nstoriesOf('Checkbox', module)\n  .addDecorator(withKnobs)\n  .add('Basic Usage', () => (\n    &lt;Checkbox\n      onChange={() => {}}\n      checked=true\n      label={text('Label', 'Check Me')}\n    />\n  );</code></pre></div>\n<h3 id=\"add-an-action\" style=\"position:relative;\"><a href=\"#add-an-action\" aria-label=\"add an action permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Add an action</h3>\n<p><a href=\"https://github.com/storybooks/storybook/tree/master/addons/actions\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><code class=\"language-text\">storybook-actions</code></a> help drive component action development. Component actions get stubs that show up in the Storybook UI.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">import { action } from '@storybook/addon-actions';\n\nstoriesOf('Checkbox', module)\n  .add('Basic Usage', () => (\n    &lt;Checkbox\n      onChange={ action('checkbox-toggle') }\n      checked=true\n      label='Check Me'\n    />\n  );</code></pre></div>\n<h2 id=\"evolving-tools\" style=\"position:relative;\"><a href=\"#evolving-tools\" aria-label=\"evolving tools permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Evolving Tools</h2>\n<p>Storybook is a big landmark for developing component libraries for the web, and we're looking forward to its evolution, and eventually the next set of tools for design systems.</p>\n<p>Check out this <a href=\"https://youtu.be/RHacQsTxnQ4\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Lunch and Learn</a> to see Storybook in action.</p>\n<p>Need help creating your own design system? <a href=\"https://frontside.com/contact/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Reach out to Frontside.</a></p>","frontmatter":{"date":"December 29, 2017","description":"Design systems have become an effective way to maintain consistency and improve feature delivery time. What can developers on smaller teams do to apply design system concepts?","tags":["design systems","component library","style guide","storybook"],"img":{"childImageSharp":{"fixed":{"src":"/static/4ae1eef3bb398cdd942eab6b3d29e702/a7715/2017-12-29-quickly-build-component-libraries-with-storybook_storybook.jpg"}}}}}}},"pageContext":{"id":"85176778-794f-5fec-b3d4-73c1a2246d0d"}},
    "staticQueryHashes": ["1241260443"]}