Building a Storybook design system for Microsoft

Lokman Musliu Founder and CEO of Lucky Media
Lokman Musliu

November 18, 2026 · 7 min read

Building a Storybook design system for Microsoft

Every component library starts with good intentions. A shared Figma file, a tidy folder of React components, a README that someone promises to keep up to date. Six months later, the design file says one thing, the docs say another, and the code does a third. Nobody is quite sure which one is right, so everyone asks the one developer who remembers.

When Microsoft asked us to build the component library behind the Windows and Surface websites, we didn't have six months to let that happen. We had four one-week sprints, fixed launch dates, and pages that millions of people would see. So we made one rule early on: Storybook is the source of truth. Everything else reads from it.

This post is a look behind the scenes at how that Storybook design system works, and the standards we follow on every component. If you're building a library for an enterprise team, you can steal all of it.

You can read the full story in our Microsoft case study.

The problem with "the docs will catch up"

Most libraries treat Storybook as a showroom. You build the component, then you write a few stories to show it off. The tests live somewhere else. The docs live somewhere else. The accessibility checks happen once, by hand, before launch.

That's four separate places to keep in sync, and in practice, nobody does. The showroom ages quietly while the real component moves on.

We flipped it around. A story isn't a demo of the component. A story is the spec. If a state isn't in a story, it doesn't exist. If a story passes, the component works. And because that one file does every job, there's nothing to fall out of step.

Storybook single source of truth

One story, five jobs

Here's what a single story does in our setup:

Job

Who it's for

How it works

Design review

Designers and QA

A published Storybook preview linked on every pull request. Every visual state, in light and dark mode, for each brand

Documentation

Developers

Props tables generated from the component's types and JSDoc

Interaction tests

QA

Scripted clicks, keyboard use and focus checks in a real browser

Accessibility tests

Everyone

An automated accessibility check on every story; a violation fails the story’s test

Visual review

Reviewers

A published Storybook preview linked on every pull request

Let's walk through how each piece connects.

Step 1: Write stories as visual states, not API coverage

The first instinct is to write a story per prop. Resist it. Designers don't think in props; they think in states. "What does the accordion look like with one item open?" "What happens when the German copy is 40% longer?"

So we write a story for each meaningful visual state:

  • Every variant, with a short note on which prop controls it

  • Loading, Disabled, Error and Empty states where they apply

  • A LongCopy story with roughly 40% more text, because translated copy grows

  • An Rtl story for any layout that has a direction (asymmetric columns, absolute positioning)

  • The component with every optional prop left out, to prove it still renders cleanly

The prop-by-prop detail goes in the MDX docs and JSDoc, where developers actually look for it. Storybook stays readable for the people who review the visuals.

Storybook stories as visual states

Step 2: Turn interactive stories into tests

Here's where it gets fun. With Storybook's Vitest integration, every story runs as a test in a real browser. Static stories get a free smoke test: if a story throws, its test fails.

For interactive components, we add a play function. It runs the same interactions a user would, and asserts on the result:

import { expect } from 'storybook/test';

export const KeyboardNavigation: Story = {
    play: async ({ canvas, userEvent }) => {
        const firstTrigger = canvas.getAllByRole('button')[0];

        await userEvent.tab();
        await expect(firstTrigger).toHaveFocus();

        await userEvent.keyboard('{Enter}');
        await expect(firstTrigger).toHaveAttribute('aria-expanded', 'true');
    },
};

No separate test file. No mocked DOM that behaves almost like a browser. The story a designer reviews is the exact story CI tests.

Turn interactive stories into tests

Step 3: Make accessibility a gate, not a checklist

Storybook's a11y addon runs axe against every story. Out of the box, violations are only flagged as to-do items in a panel that nobody opens. We set it to fail the test instead:

// .storybook/preview.tsx

const preview: Preview = {
    parameters: {
        a11y: { test: 'error' },
    },
};

But here's the honest part: a green axe run doesn't mean a component is accessible. On this project, the automated checks passed on components with focus rings nobody could see, click handlers that did nothing from the keyboard, and animations users couldn't pause. Axe can't catch those. People can.

So every component also gets:

  • A keyboard-only pass, with a visible focus ring on every interactive element

  • A screen-reader pass in VoiceOver and NVDA

  • A check that all motion respects prefers-reduced-motion

  • Accessible behavior from a headless primitives library (we use Base UI) instead of hand-rolled ARIA

Automated checks catch the regressions. Manual checks catch the things automation can't see.

Automated AND manual checks

Step 4: Generate the docs from the code

Each component has an MDX page with the same short template: what it's for, its props, layout notes, dark mode, RTL and known limitations. No obvious advice, no copy-pasted code samples that go stale.

The props table comes straight from the component's TypeScript types. The descriptions come from JSDoc comments on the props:

type AccordionProps = {
    /** Allows more than one item to stay open at the same time. */
    multiple?: boolean;
    /** The items to render. Each needs a unique `id`. */
    items: AccordionItem[];
};

One thing to keep in mind is that nested types aren't documented automatically. For example, if a component accepts a prop such as items: AccordionItem[], the AccordionItem type should also be documented separately to make it clear what information and properties each item can include.


Change the prop, and the docs change with it. There's no second place to forget to update.

Generate the Docs from Code

Step 5: Two brands, one codebase

Windows and Surface share most of their components, but not their look. Instead of forking components per brand, each brand gets its own set of design tokens and its own CSS entry point:

/* Components only ever reference tokens */
.card {
    background: var(--color-surface);
    border-radius: var(--radius-card);
}

A component never uses a raw hex value. It asks for surface or heading-1, and the brand decides what that means. Storybook has a brand switcher in the toolbar, so designers can flip between Windows and Surface on the same story.

The important part is in CI: the full test suite runs once per brand. A fix that makes Windows look perfect can't quietly break Surface, because Surface's tests will fail first.

We learned this one the hard way. Some tokens existed in one brand and not the other, and a few tokens emitted no CSS at all. Everything looked fine in one brand and silently fell back to defaults in the other. Running every story under both brands is what surfaced it.

Two brands one codebase

Step 6: Put the quality bar in the repo, not in someone's head

Standards that live in a wiki get skipped on a Friday afternoon. Standards that live in the pull request template get ticked every time.

Every pull request in our library runs the same pipeline:

  1. Lint, format and typecheck, including eslint-plugin-jsx-a11y rules and strict TypeScript

  2. The full story test suite, split into parallel jobs per brand, plus unit and dark mode tests

  3. An automated code review against a written component standard (tokens only, wrapper-owned spacing, no hardcoded copy)

  4. A published Storybook preview, linked on the pull request for designers and reviewers

And before anything ships, a QA expert ticks the manual QA list: four breakpoints (375, 768, 1280 and 1920), Edge, Chrome, Safari and iOS Safari, and a screen-reader pass.

None of these steps is clever on its own. The value is that they're all written down, they all run on every change, and none of them depend on who happens to be reviewing that day.

Put the quality bar in the repo

What this bought us

On this project, the approach paid off in numbers:

  • 33 components in four weeks, across four one-week sprints, with every deadline hit

  • Fewer than one issue per component after delivery, against the usual three to five

  • 90% of new landing pages now built from the library

  • An ongoing partnership with Microsoft, because the foundation held up

You can read the full story in our Microsoft case study.

FAQs

What is Storybook in frontend development?

Storybook is a workshop for building UI components in isolation, outside your app. Each component gets a set of stories, one per state, that designers and developers can review in a real browser. In a mature setup like the one we built for Microsoft, those same stories also run as tests and generate the docs.

How do you build a design system with Storybook?

Start with design tokens for colour, type and spacing, then build components that only use those tokens. Write a story for each meaningful visual state, add interaction and accessibility tests to the stories, and generate the docs from your TypeScript types. That way Storybook becomes the single source of truth for the whole design system.

What are Storybook best practices for a component library?

Write stories as visual states, not one story per prop. Treat accessibility violations as build failures, add `play` functions to interactive stories, and keep prop docs in JSDoc so they can't go stale. Most of all, run the full suite on every pull request so the standards don't depend on who is reviewing.

How do you do accessibility testing in Storybook?

Use the @storybook/addon-a11y addon and set a11y.test to error, so every story fails on an axe violation. Then add manual keyboard and screen-reader passes, because automated tools miss problems like invisible focus rings and animations users can't pause.

Can Storybook run with Vitest?

Yes. Storybook's Vitest integration runs every story as a test in a real browser, including the `play` functions you write for interactions. We split the suite into parallel CI jobs, one set per brand, so a large library still tests quickly.

Should designers use Storybook or Figma?

Both, for different jobs. Figma is where design ideas start, and Storybook shows what actually ships, in every state and in a real browser. On our Microsoft project, designers signed off on Storybook, because that's the version users see.

Need a component library that holds up?

Building a library for one launch is easy. Building one that a large team can trust, extend and hand over is the hard part, and it's the part we enjoy most. If your team is about to start a design system or rescue one that's drifted, our website development team can help you set the standard from day one.

Technologies

ReactTailwindCSS
Lokman Musliu Founder and CEO of Lucky Media
Lokman Musliu

Founder and CEO of Lucky Media

Stay up-to-date

Be updated with all news, products and tips we share!

Let’s chat

We partner with a limited number of brands each quarter to ensure senior-level attention on every project.

Teamwork