Skip to content

Storybook with Web Components in 2026: what it is, how to set it up and when it pays off

What Storybook is, what changed in versions 9 and 10, how to set it up with Web Components and Lit, the custom-elements.json file and when the tool is worth the upkeep.

Ramon Gomes 9 min read Level: Intermediate

Also available in: Español, Français, Português

If you have ever changed the color of a button and found out, two weeks later, that it broke in a modal nobody opened, you know the problem Storybook solves. The component lives scattered across the application, and each of its states only shows up if you click down the right path, with the right data, logged in as the right user.

This article explains what Storybook is, how it works with Web Components in 2026 and, above all, when it is worth the maintenance effort.

What Storybook Is, in One Sentence and One Example

The documentation defines a story like this: it captures the rendered state of a UI component (Storybook). Storybook is the showcase where those stories live, each with its own page, controls and tests.

Photographer in a studio with a white seamless backdrop, photographing a lone armchair under controlled lighting
In a studio, the armchair is photographed alone, with controlled lighting and without the clutter of the living room. Storybook does that with the component.

Think of a furniture photo studio. Nobody photographs the armchair in the middle of someone's living room, with the dog around and the TV on. It goes onto a white backdrop, with controlled lighting, and gets photographed from several angles. Storybook is that studio: it takes the component out of the application and shows each of its variations without depending on an APIContract that defines how one program asks another for data or actions: which endpoints to call, what to send and what comes back. On the web, usually HTTP with JSON., a login or a route.

Stories are written in the CSF format, a regular JavaScript module: the export default describes the component, and each named export is a story. The data that feeds the story is called args, the generic name Storybook uses for React props, Angular inputs or Web Component attributes.

What It Does Beyond Showing the Component

The name is misleading. Storybook started as a catalog and turned into a testing tool, and the last two versions made that explicit.

Version 9, from June 2025, brought what the team called Storybook Test: each story becomes a test run by Vitest, with watch mode, accessibility checks via axe-core and a coverage report. The install shrank to less than half the size of version 8 (Storybook 9). Version 10, from October 2025, went ESM-only, got 29% smaller and requires Node 20.16 or newer (Storybook 10).

From the component to stories, and from stories to documentation, interaction tests, accessibility and visual testing

In practice, a well-written story counts as four things: it is the living documentation of the component, an interaction test case (with the play function), an accessibility test and, if you use Chromatic, a visual test that compares screenshots between versions. Chromatic is the service from the company that maintains Storybook and is paid beyond the free quota. The rest runs locally and for free. I covered where this fits into a testing strategy in the front-end testing guide.

What Changes with Web Components

In the official feature table per framework, Web Components support practically everything React has: controls, actions, interactions, accessibility, automatic docs and coverage. The only column without a checkmark is the GraphQL addon (Storybook).

To get started, at the root of a Vite project:

bash
npm create storybook@latest
npm run storybook

The wizard detects the project and installs the @storybook/web-components-vite framework, which requires Vite 5 or newer (Storybook). If your project still runs Webpack, be aware that Storybook 9 removed that builder for Web Components and the @storybook/web-components-webpack5 package stopped at 8.6.14. If you do not want Vite, there is @web/storybook-builder, from the Modern Web community, which runs on top of @web/dev-server (Modern Web).

A Lit component and its story:

ts
// src/meu-botao.ts
import { LitElement, html } from 'lit';
import { customElement, property } from 'lit/decorators.js';

@customElement('meu-botao')
export class MeuBotao extends LitElement {
  @property({ type: Boolean }) primario = false;
  @property() rotulo = 'Button';

  render() {
    return html`<button part="botao" class=${this.primario ? 'primario' : ''}>${this.rotulo}</button>`;
  }
}
ts
// src/meu-botao.stories.ts
import type { Meta, StoryObj } from '@storybook/web-components-vite';
import { fn } from 'storybook/test';
import { html } from 'lit';
import './meu-botao';

type Args = { primario: boolean; rotulo: string; onClick: () => void };

const meta: Meta<Args> = {
  title: 'Base/MeuBotao',
  component: 'meu-botao',
  tags: ['autodocs'],
  args: { primario: false, rotulo: 'Save', onClick: fn() },
  render: (args) => html`
    <meu-botao ?primario=${args.primario} rotulo=${args.rotulo} @click=${args.onClick}></meu-botao>
  `,
};
export default meta;

type Story = StoryObj<Args>;

export const Primario: Story = { args: { primario: true } };
export const Secundario: Story = {};

Three differences from React show up in this code. component is the tag name, as a string, not the class; Storybook itself rejects anything else. The template uses Lit syntax: ? for a boolean attribute, . for a property and @ for an event. And the Actions panel only logs an event if you bind the arg to it in the template, like @click=${args.onClick}. A CustomEvent fired by the component needs its own arg, bound the same way.

The File That Makes the Documentation Write Itself

In React, Storybook reads the prop types and builds the documentation table and the controls. In a Web Component, that role is played by custom-elements.json, the Custom Elements Manifest: a file that describes the attributes, properties, events, slots, parts and CSS variables of each component. The ArgTypes page of the documentation confirms that, for Web Components, inference comes from this file (Storybook).

Generating the file takes one command, with the Open Web Components analyzer (open-wc):

bash
npx cem analyze --litelement

And registering it in .storybook/preview.ts:

ts
import { setCustomElementsManifest } from '@storybook/web-components-vite';
import customElements from '../custom-elements.json';

setCustomElementsManifest(customElements);

export default {};

Here is an honest criticism: the framework page for version 10.6 does not explain this step. The function exists in the Storybook code and works, but the walkthrough lived in an old README of the docs addon. If you arrive through the current documentation, it takes a while to figure out why the props table is empty.

Luthier sitting at the workshop bench, testing the sound of a freshly assembled guitar, with other instruments hanging on the wall
The luthier tests each instrument before it leaves the workshop. A story with the play function does the same with the component: it clicks, types and checks.

When It Is Worth It, and When It Is Not

The numbers show a big tool with a niche use. In the week of November 5 to 11, 2026, the storybook package had about 35 million downloads on npm, and the Web Components framework with Vite, about 287 thousand. Less than 1%. Support is official and alive, but the community, the examples and the addons think about React first. When Storybook 10 launched the new story format, CSF Factories, it shipped for React only at first.

The Web Components design systems I checked by opening their sites use Storybook: Spectrum Web Components, from Adobe, Carbon Web Components, from IBM, and Fluent UI Web Components, from Microsoft. Not everyone goes that way. Web Awesome, the successor to Shoelace, builds its own documentation with Eleventy, and Ionic does not use Storybook either.

When Storybook pays off in a Web Components project and when it is too much structure

I would adopt Storybook when:

  • The design system is consumed by teams with different stacks. A single Web Components Storybook documents the component for people using React, Angular or plain HTML, which is exactly the promise of Web Components.
  • There is a design or product person who needs to see the states without running the application.
  • The components have many hard-to-reproduce states, like error, loading, empty and different permissions.

And I would leave it for later when:

  • It is half a dozen components used by a single app. A Vitest test file and an internal examples page do the job with fewer dependencies.
  • The team does not have time to keep up with versions. There were two majors with breaking changes in a little over a year: 9 dropped Webpack for Web Components and 10 went ESM-only.

The State of JS 2025 survey has a line that sums up people's relationship with the tool well: Storybook is an interesting case of a project trying its hardest to address user frustrations, still with a slight drop in satisfaction compared to the previous year, but falling more slowly (State of JS 2025). It remains among the most used testing tools at work, in second place in the 2024 edition (State of JS 2024).

What About the Alternatives?

For Web Components, the direct alternatives have almost disappeared. Pattern Lab and Fractal have archived repositories, and Backlight.dev, which was strong in Web Components, shut down in June 2025. Ladle is active and lightweight, but React only; Histoire covers Vue and Svelte. In practice, for Web Components in 2026, the choice is between Storybook and writing your own documentation page, like Web Awesome did.

Frequently Asked Questions

What is Storybook and what is it used for?

It is an open source tool for developing, documenting and testing UI components in isolation from the application. Each story shows a state of the component and can serve as documentation, an interaction test and an accessibility test.

Does Storybook work with Web Components without React?

Yes. The @storybook/web-components-vite framework does not depend on React and renders stories with Lit syntax.

Which package should I use: @storybook/web-components-vite or @storybook/web-components?

In main.ts, the framework is @storybook/web-components-vite. @storybook/web-components is the renderer, which the framework already includes and re-exports.

Can you use Storybook with Webpack for Web Components?

Not officially since version 9. The alternatives are @web/storybook-builder, from the Modern Web community, or migrating the project to Vite.

How do I generate controls and automatic docs for Web Components?

Generate custom-elements.json with npx cem analyze and register the file with setCustomElementsManifest in .storybook/preview.ts.

How do I capture Web Component events in the Actions panel?

Create an arg with fn(), from storybook/test, and bind that arg to the event in the story template, for example with @click=${args.onClick}. For custom events, do the same with the event name.

Does Storybook test accessibility?

Yes, with the @storybook/addon-a11y addon, which uses axe-core and runs alongside the Vitest tests.

What is the current version of Storybook?

In November 2026, the stable one is 10.6 and 11 is in beta. Version 9 brought testing with Vitest, and 10 went ESM-only, requiring Node 20.16 or newer.

References

Source: https://ramongomessilva.com.br/blog/storybook-with-web-components · Accessed on December 02, 2026

Share Share on LinkedIn Share on X
Cite this article

Ready-made reference, with today as the access date.

ABNT

Brazilian standard (NBR 6023). Use it in theses and academic papers submitted in Brazil.

GOMES, Ramon. Storybook with Web Components in 2026: what it is, how to set it up and when it pays off. Ramon Gomes, 12 nov. 2026. Disponível em: https://ramongomessilva.com.br/blog/storybook-with-web-components. Acesso em: 2 dez. 2026.

APA

American Psychological Association style. Common in scientific papers and journals, especially in the social, behavioral and health sciences.

Gomes, R. (2026, November 12). Storybook with Web Components in 2026: what it is, how to set it up and when it pays off. Ramon Gomes. https://ramongomessilva.com.br/blog/storybook-with-web-components

BibTeX

Format for LaTeX users (Overleaf, for example). Paste it into your .bib file or import it into Zotero or Mendeley.

@online{gomes2026storybookwithweb,
  author = {Gomes, Ramon},
  title = {{Storybook with Web Components in 2026: what it is, how to set it up and when it pays off}},
  organization = {Ramon Gomes},
  year = {2026},
  month = nov,
  date = {2026-11-12},
  url = {https://ramongomessilva.com.br/blog/storybook-with-web-components},
  urldate = {2026-12-02}
}
Found a mistake?

Wrong fact, broken link, outdated information: tell me and I will fix it.

10 to 2,000 characters. If you can, point to the right source.

Only so I can reply. It never shows on any page of the site.

Written by

Ramon Gomes

Software Engineer

Full stack software engineer. I like taking a messy problem, listening to the people who live with it and shipping something that holds up day to day. These days I split my time between my own products, applied AI and client work.

Available for projects

Need Something Like This Built?

I build websites, systems, apps and AI automations, from design to deploy. Tell me what you need or see what I offer.

Related Articles