Writing a component spec before you build it: anatomy, states and behaviour checklist
A short written spec before design and code start can save days of back-and-forth. It does not need to be long; it needs to be complete.
1. Purpose and usage
- What problem does the component solve?
- When should it be used, and when should something else be used instead?
2. Anatomy
- Label each part: container, label, icon, helper text, trailing action.
- Mark which parts are optional.
3. Variants and sizes
- List visual variants (primary, secondary, subtle) and sizes, and why each exists.
- Resist adding a variant without a real use case.
4. States
- Default, hover, focus, active/pressed, disabled, loading, error, selected.
- Note which states can combine (selected and disabled, for instance).
5. Content rules
- Maximum label length, truncation versus wrapping, behaviour with long translations.
6. Behaviour and interaction
- Keyboard support: which keys do what.
- Mouse and touch behaviour, including target sizes.
- Animation, if any.
7. Accessibility
- Role and accessible name, how state is announced, contrast requirements.
8. Responsive behaviour
- What changes at narrow widths?
9. Open questions
- Unresolved decisions, so reviewers know what feedback is needed.
A useful practice exercise: pick an existing component in a well-known open-source system and write its spec from scratch, then compare it with their documentation. You will often spot states you forgot.
Do you write specs before building, or document after the fact? Which section of a spec do teams most often skip?
Comments · 3
The states section is the one teams skip and regret. Empty, loading, error and disabled all need design decisions, and finding that out mid-build is costly.
As a beginner this would have saved me a lot of guessing about what a component should do when something goes wrong. A checklist is gold.
Add keyboard and screen reader behaviour to the checklist. It's much cheaper to specify upfront than retrofit.