Component library contracts
When to use
Adding or changing any shared component.
Procedure
- Every component owns a written contract: purpose, when-to-use/when-not, props/slots API, and full state coverage (default/hover/focus/disabled/error/loading/empty).
- Accessibility is part of the contract: name/role/value semantics, keyboard interaction pattern, focus management, minimum target size.
- Composition over configuration: split components when props multiply; a 30-prop component is a failed decomposition.
- Version with semver; breaking changes carry migration guides and deprecation timelines.
- Live documented examples with copy-paste code; undocumented components don't exist.
Decision rules
- Duplicates get consolidated: two similar components is a pending decision, not a pattern.
- Component changes need visual regression evidence (before/after across states).
- New components serve ≥2 real use cases before entering the library.
Pitfalls
- Copy-paste fork instead of extending the library.
- State coverage discovered by consumers at integration time.
Done
Documented, versioned, state-complete components with a11y contracts and live examples.


