Four layers: tokens, primitives, composites, patterns. Build from the bottom, because a pattern built first is a screenshot: it looks like the product, it is assembled from values that do not exist yet, and every one of those values gets invented inside it.
Dimitar is building the component library for a telecom's self service product in Sofia. Three teams, two web applications, 1,340 screens already in production, and a previous attempt that shipped 22 components and was used on about sixty of them.
What to build first is a count
Instrument the product and build in order of how often each element appears. A script over the rendered pages counts buttons, fields, rows, links, cards and everything else, and the answer arrives in a morning.
One kit, three teams
Four layers, and why the order they are built in decides the rest
Nothing here is a step. Each layer holds up the one above it, and anything built before its supports invents them privately.
- Patternsa whole search screen, a checkout: assembled from the layer below and owned by product teams
- Compositesa table row, a filter bar, a field with its label, hint and message: the layer the kit is mostly made of
- Primitivesthe button, the input, the checkbox: ten of these cover 71 of every 100 element instances
- Tokensthe values everything above resolves to, and the only layer that survives a rebrand unchanged
The previous attempt at this kit started at the top with a hero banner. Everything under it was invented inside that one component and never reached the tier where the rest of the product could use it.
Modular Type Scale & CSS Flex/Grid Motion Lab
Test harmonic typography ratios and live Flexbox/Grid layouts with 1-click CSS export.
On this product the ten most common elements are 71 of every 100 instances. Building those ten first covers most of the product before anybody has an opinion about a hero banner, and it produces a kit whose first release is immediately worth adopting.
The count also settles the arguments at the other end: a component nobody uses is a maintenance cost with no benefit. It has to be versioned, documented, tested in two places and kept in step with the tokens, and it earns none of that back.
Two sources, and what has to match
The design file and the code are two sources, and the API is what must match. Neither can be generated from the other reliably: a design file has no logic and a codebase has no canvas, and every attempt to make one the master produces a tool that works for six months.
Shared API contract
Design files and code cannot generate each other; their API surface must match
Neither source holds both canvas and logic, so property names, allowed values, and tokens must stay identical by inspection.
Even a single extra size value in the design file creates screens that engineers cannot build as drawn.
What has to be identical is the surface: the property names, their allowed values, and the token values underneath. If the design file calls it emphasis with three values and the code calls it variant with four, then a handover is a translation, done differently by each person who does it.
So diff the props of five components and count the divergences. Five is enough to find out whether the two are in step; on this library the first diff found three, including a size property that had four values in the design file and three in code, which is a component that cannot be built as drawn.
A prop that exists in one source and not the other is a divergence somebody will hit, and they will hit it at the least convenient moment, which is while building a screen against a deadline with the design open beside them.
Versions on both sides
Version the code package, and give the design library a written version too. The code side is a solved problem: a version number, a changelog, and consumers who upgrade when they choose.
Synchronized releases
Code packages ship versions; the design library needs a written version too
Without an explicit version on the design side, changes silently push to everyone and break parity with code.
- Versioned code package
- Cover-page design version
- Versioned code packageCarries semantic number, changelog, and consumer-controlled upgrades
- Cover-page design versionText layer with number and date updated on publish so screens declare their baseline
A simple text layer on the cover page lets every developer verify which library version a screen was drawn against.
The design side has no version numbers at all in most tools, which publishes changes to everybody the moment they are made. The cheapest fix is a text layer on the library's cover page carrying a number and a date, updated on publish, so a designer can say which version a screen was drawn against and a developer can check.
Adoption is a number
Adoption is measured, not announced. The same script that counted elements counts how many of them came from the kit, and the resulting share is the only honest statement about whether the library exists in the product or in a file.
Measured, not announced
Publishing a library file is visible; real adoption lives in production DOM counts
Only counting what share of live rendered elements come from the kit tells whether teams actually use it.
- Component library publishedFiles, tokens, and docs exist on paper
- Share of rendered kit elementsMeasured by the same DOM census script across production
- Risk of an unwelcome numberWhy teams skip measuring real adoption
- Evidence for next six monthsOnly honest case for funding ongoing library work
An unmeasured library exists in a design file rather than in the product.
It is also the number that makes the case for the next six months of work, and it is the one nobody measures, because measuring it can produce an unwelcome answer.
What to open
A script over the rendered DOM is the first tool, free, and it counts what is on the pages that exist. It replaces asking three teams which components they need, which produces a wish list of things people would like to design rather than a census of what is already on the screen.
What to open
Two free scripts turn wish lists and manual checks into daily evidence
Running a DOM census and querying the design tool API replaces guesswork with automated parity diffs.
- 01Run a DOM census scriptCounts real components on existing pages instead of team wish lists
- 02Fetch props via design tool APIPulls component properties as data without clicking forty panels
- 03Diff design vs code on every publishCatches prop and value drift on the exact day it appears
Both tools cost nothing beyond an existing account and take minutes to script.
The design tool's own API is the second, free with an account, and it returns the component properties as data. That is what makes the parity diff a script rather than a person opening the properties panel forty times, and a diff that runs on every publish is a diff that catches a divergence on the day it appears.
Where it stalls: chosen from a list of components
The first ten components are chosen from a list of components rather than from the product. Everybody knows what a design system contains, because they have seen other design systems: a button, a card, an accordion, a hero, a testimonial, a pricing table.
Where kits stall
Building a generic system checklist misses what the product is made of
Teams copy familiar marketing components from other design systems and leave out the rows and fields used everywhere.
- Generic system checklist
- Actual portal screens
- Generic system checklistButton, card, accordion, hero, testimonial, pricing table
- Actual portal screensTable rows, filter chips, and four field variants on every screen
The mismatch is a sampling error, cured in one morning by counting rendered screens before building.
So the first release is that list, made carefully, and it does not intersect with what the product is made of. The teams look at it, find that it does not contain the row, the filter chip or the four field variants they use on every screen, and carry on.
Nothing about this is a failure of skill. It is a sampling error with a very specific cure, which is to count before building, and the count takes a morning.
What it looks like when it goes wrong
The previous attempt shipped 22 components including a hero banner, a testimonial card and a pricing table. The product is a self service portal for existing customers: it has no heroes, no testimonials and one pricing page. About sixty of the 1,340 screens could have used any of the three. Meanwhile the table row, which appears on 400 screens, and the field with its four states, which appears on nearly all of them, were both on the roadmap for the following quarter. The library was well built and it was a library for a different product.
Previous attempt numbers
22 components built for marketing, while 400 table-row screens waited
The first kit shipped polished blocks for a different kind of product and deferred what the portal actually rendered.
- 22Components shipped in first kitIncluded hero banner, testimonial card, and pricing table
- 1,340Total screens in the portalOnly about sixty could use those three marketing blocks
- 400Screens using the table rowDeferred to next quarter along with the four-state field
Nothing failed in craft; the kit simply solved the wrong product.
Every component in it references values from a tier below, and how those are named and structured is values named once and used everywhere. Each of the ten needs a page answering the questions a stranger will have, which is what a component's page has to answer. And keeping the two sources in step for years, with three teams contributing, is contribution, versioning and drift. How much the whole thing is allowed to bend is one level up, in a shared kit, and the rules for using it.