# Component Specification

Specifies one interface component completely enough that someone who has never seen it can build it, use it and test it — and records the states nobody has decided instead of inventing them.

## Deliverable

One Markdown document, `component-specification.md`, in the structure set out under **Output** below. It takes the variants and one-offs that **Design System Audit** finds as its starting point, and the states that **User Flow Specification** requires as its checklist, and it gives **Interface Copy Specification** the content rules its strings must obey.

## Required inputs

- **The component** — its name and what it is for, with access to its current design or implementation.
- **Where it is used** — the screens, flows or contexts in which it appears, so variants are derived from use rather than from taste.
- **The tokens and styles available** — the colours, spacing, type and other values the system already defines.
- **The targets it must meet** — the platforms and the accessibility conformance level, as the requester names them.

If the component, its places of use or the targets are absent, stop and report it. If the tokens are not supplied, continue and mark every visual property `token unknown`; the specification never invents a value.

## Optional inputs

- Design system documentation that already covers this component or its neighbours
- Known defects or complaints about it
- Content constraints: limits on length, languages, text that is user-supplied
- Breakpoints the system defines
- Analytics or research showing how the component is actually used

Absent optional inputs do not stop the specification. Each becomes a line saying what could not be checked and who holds the material that would check it.

## Execution

**1 — Inventory the component as it exists.** Every distinct appearance in use, with where it occurs. Where **Design System Audit** has been run, start from its register; otherwise collect the appearances from the places of use.

**2 — Name the anatomy.** Its parts, each marked required or optional, and what each is called. Two people should be able to point to the same part from the name.

**3 — Derive the variants.** The axes along which it genuinely differs in use — for example size, emphasis or intent — and only the values that occur or were requested. A variant nobody uses is not specified.

**4 — Specify every state of every variant.** At least default, hover, focus, pressed, disabled, loading, error and empty, plus any the component has. Each state is either specified, with what changes, or recorded as `undecided`. A state is never invented to fill a gap, and a state that does not apply says why.

**5 — Bind appearance to tokens.** For every visual property: the token it draws on, or `one-off` when it draws on none, or `token unknown` where none were supplied.

**6 — Specify the interaction.** Pointer, touch and keyboard: which keys do what, the order focus moves in, and where focus goes when the component opens, closes or changes. The accessible name, role and value, and what assistive technology announces on each state change.

**7 — Set the content rules.** Which parts accept content, what happens when it is too long, too short or absent, how text wraps or truncates, and what expansion other languages need. Limits are taken from inputs; where none exist the rule is `unknown`.

**8 — Specify its response to space.** At each breakpoint the system defines: what changes, what stays and what is hidden. Without defined breakpoints, record `unknown` and state what the component needs to be told.

**9 — Write the usage rules.** When to use it, when not to, and what existing component to use instead. Name only components that exist.

## Output

`component-specification.md`, in this order:

- **1. Component** — name, purpose and where it is used
- **2. Anatomy** — parts, required or optional
- **3. Variants** — each axis and its values, with where each occurs
- **4. States** — per variant: each state specified or `undecided`
- **5. Tokens** — per visual property: token, `one-off` or `token unknown`
- **6. Interaction** — pointer, touch, keyboard, focus and announcements
- **7. Content rules** — limits, overflow, empty content and localisation
- **8. Responsive behaviour** — per breakpoint: what changes
- **9. Usage rules** — when to use it, when not and what instead
- **10. What could not be checked** — missing inputs and who holds them

## Validation

The specification is ready when all of these hold:

- Every appearance found in section 1 belongs to a variant in section 3 or is listed as a one-off
- Every variant has every state in section 4, specified or `undecided`
- Every visual property in section 5 names a token, `one-off` or `token unknown`
- Section 6 says what focus does and what is announced, for every state that changes either
- No dimension, colour, duration or threshold appears that no input supplied
- Every component named in section 9 exists in the inputs

Fail the run if a state is specified that nobody decided, or if a value appears that is not a supplied token.

## Failure handling

- **No places of use supplied** — stop. Report that variants cannot be derived from use without knowing the use, and name what the requester must supply.
- **The component has no documented states** — record each as `undecided`, list the questions for the owners, and do not propose answers as if they were decisions.
- **Tokens missing or incomplete** — mark the affected properties `token unknown` and list the tokens the system must define.
- **No accessibility target named** — specify the behaviour the component needs, record the target as `unknown`, and state that conformance cannot be claimed.
- **Partial material** — specify what the material supports, mark the rest `NOT SPECIFIED — pending <material>`, and deliver.
