Faragiri
English

Choose a language 2

Learn Documenting a system Design systems

A Helsinki broadcaster's tag component with four of five sections, used as a button on sixty pages, and a quarter spent putting it back.

7Sections
5Min read
4Depth

Recommended Before This

0 / 2

Five sections: what it is, when not to, the API, the states, the contract. A page missing any of them sends somebody to ask a person, and a system whose documentation sends people to a person is a system with a support desk rather than a set of components.

Aino writes the pages for a public broadcaster's design system in Helsinki: 38 components, three product teams, and about a hundred people who might open one of those pages in a given month.

The section everybody omits

When not to use it is the section that prevents the most misuse, and it is the one that does not get written, because it is the only one that requires imagining somebody being wrong.

One component, one page

Five sections holding up one page

Take any one away and somebody has to ask a person, which is the cost the page exists to remove.

a component page
  • What it isone sentence and two examples of where it belongs, written rather than generated
  • When not tothe wrong use, why it fails, and a link to the right component: the section that gets quoted
  • The APIevery prop, value and default, extracted from the source so it cannot drift
  • The stateslive and copyable, one per state, because a picture does not show what focus does
  • The contractwhich keys work, what is announced, and what the consumer has to supply

one page per component, in this order

The second column is the only one that cannot be generated and the only one that requires imagining somebody being wrong, which is why it is the one that is missing.

Modular Type Scale & CSS Flex/Grid Motion Lab

Test harmonic typography ratios and live Flexbox/Grid layouts with 1-click CSS export.

It has a fixed shape: a sentence naming the wrong use, a sentence saying why it fails, and a link to what to use instead. For a tag, that is: do not use a tag as a button, because a tag is not focusable and announces as text, and use a quiet button instead.

It is also the section people quote in code review, which is where documentation earns its cost. Nobody quotes the API table in a review; they quote the sentence that says this is not what this is for.

What is generated and what is written

Generate the API table from the code so it cannot drift. Every property, its allowed values, its default, extracted from the source at build time. A hand written table is correct on the day it is written and wrong within two releases, and worse than nothing, because it is trusted.

Two authoring modes

What comes from code vs what needs a human date

Separating generated API facts from dated editorial guidance keeps both from lying in different ways.

Generated from sourceprops, values, defaults
Written and datedguidance and misuse rules
Source of truthExtracted at build time from codeAuthored in prose with a review date
How it goes wrongHand-typed tables drift within two releasesGuidance stays true but stops being complete
Reader signalMatches the current shipped packageShows whether last touched in 2024 or today

Never write prop tables by hand, and never leave prose undated.

Write everything else, and put a date on it. Prose about when a component is appropriate cannot be generated, and it goes stale in a different way: it stays true and stops being complete. A date lets a reader judge, and it makes the difference between a page that was written in 2024 and a page nobody has looked at since 2024 visible.

The shape of the page

One screen and a half before the first live example. A page that opens with three paragraphs of philosophy is a page people scroll past, and scrolling past means missing the section that says when not to use it.

Page layout

One screen and a half to the first live example

Readers scroll past long philosophy intros and miss the warnings if interactive code sits too far down.

design-system/components/tag
  1. 01Tag: compact label for status or category
  2. 02Do not use a tag as a button; use a quiet button instead
  3. 03Default, focus, disabled: interactive and ready to copy
  4. 04Props, allowed values, and defaults from source
  1. 01Component name and one-line summaryorients the reader in seconds
  2. 02When not to use itplaced before examples so scrolling past does not hide it
  3. 03Live, copyable state exampleswithin a screen and a half of the top, showing real focus behaviour
  4. 04Generated API table below the foldfor reference once the developer knows it is the right component

A picture cannot show focus states, and prose cannot replace copyable code.

The examples are live and copyable, one per state. Live, because a picture of a component does not show what it does when focused; copyable, because the fastest possible route from a page to working code is the whole point of the page existing.

The contract

The contract says which keys work and what the consumer must supply. Two halves: what the component does for you, and what it cannot do without you.

Shared responsibility

What the component handles vs what the consumer supplies

Unlabelled icon buttons ship whenever a component page hides what the caller must provide.

  • Component providesbuilt into the kit
    • Supported keyboard keys and shortcuts
    • Built-in focus behaviour and role semantics
    • Screen reader announcements for internal state
  • Consumer suppliesrequired from the caller
    • Accessible name for icon-only controls
    • Context-specific labels that code cannot guess
    • Visible pairing with required props in docs

accessible component behaviour

Put required consumer inputs beside the props table, or half of shipped instances will omit them.

A page that does not name the required label is a page that produces unlabelled components. An icon button cannot know what it is for, so its accessible name has to come from whoever uses it, and if the page does not say so in the same place as the props, half the instances in the product will ship without one.

What to open

Type extraction from the source is the tool for the API half, free in every language with types worth having, and it replaces an API table typed by hand that is wrong within two releases. The generated table is also the specification that the design file's properties get diffed against.

Verification loop

Three free checks before calling a page finished

Type extractors, search logs, and a fresh developer test expose gaps faster than internal reviews.

  1. 01Extract types from codegenerate the API table at build time and diff properties against the design file
  2. 02Read the docs search logcheck hit queries for demand and zero-result queries for missing components or mismatched words
  3. 03Run a stranger build testask someone new to build a screen with one component and count every question they ask

Zero questions is the target, two is normal, and every question points directly to a missing line.

The documentation site's own search log is the other one, free, and it replaces guessing which pages people need. Queries with results tell you which components are being reached for; queries with none tell you which components people expect to exist and which words they use for the ones that do.

Then the test that settles whether any of it worked: a developer building one without asking a question. Give somebody who has never used the system a component and a screen to build, and count the questions. Zero is the target and two is normal, and each question is a section that was missing.

Where it stalls: written by the person who built it

Documentation is the last task on a component, done by the person who just finished building it, in the hour before it ships.

Where it stalls

The builder knows the component too well to warn against it

Misuse looks invisible to the author who spent two weeks building the right path.

Hand the misuse section to someone who watched users struggle rather than the person who wrote the code.

That person cannot write the section about when not to use it, because they have never wanted to use it wrongly. They know precisely what it is for, they have spent two weeks with it, and every possible misuse is obvious enough to them to seem not worth writing down.

The cheap correction is to have somebody else write that one section, after watching two teams use the component for a fortnight. It takes twenty minutes and it is the only section anybody quotes.

What it looks like when it goes wrong

The broadcaster's tag component had four of the five sections and no when not to use it. Tags are small, they have a background, and they look clickable, so three teams used them as buttons for filtering. They are not focusable, they announce as plain text, and the keyboard cannot reach them. The accessibility audit found tags used as controls on about sixty pages, and the remediation took a quarter. The component was correct, the four sections were accurate, and one sentence was missing.

Failure sequence

How one missing sentence turned tags into sixty broken filters

Four accurate sections could not stop three teams from using a non-focusable pill as a button.

  1. 01Four of five sections shippedtag API and states were accurate, but the misuse rule was absent
  2. 02Visual cue misleads teamssmall filled tags looked clickable, so three teams wired them as filters
  3. 03Keyboard access breakstags were unfocusable and announced as plain text across about sixty pages
  4. 04Quarter spent remediatingaccessibility audit caught the pattern long after launch

A component can be technically bug-free and still fail across a product because one warning was never written.

Each of these pages describes something that exists in two sources at once, and keeping those in step is building the kit, in design and in code. The pages themselves have to be maintained by somebody as the components change, which is contribution, versioning and drift. And the craft of writing a rule that a stranger will follow is the same one a brand document needs, which is writing rules other people can follow. How firm the whole thing is meant to be is one level up, in a shared kit, and the rules for using it.

Alongside this

Above this