openxiangda-skill-kit 2.0.20 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/skills/openxiangda-v2/SKILL.md +25 -2
- package/skills/openxiangda-v2/references/application-foundation.md +1 -1
- package/skills/openxiangda-v2/references/cli.md +1 -0
- package/skills/openxiangda-v2/references/design-craft.md +1526 -0
- package/skills/openxiangda-v2/references/design-workflow.md +119 -0
- package/skills/openxiangda-v2/references/development.md +1 -1
- package/skills/openxiangda-v2/references/frontend.md +10 -2
- package/skills/openxiangda-v2/references/interaction-patterns.md +2 -2
- package/skills/openxiangda-v2/references/opendesign-methods.md +756 -0
- package/skills/openxiangda-v2/references/product-design.md +3 -3
- package/skills/openxiangda-v2/references/testing.md +1 -1
|
@@ -0,0 +1,1526 @@
|
|
|
1
|
+
# OpenDesign Craft 原文
|
|
2
|
+
|
|
3
|
+
固定上游提交:`07170f8d2213936b7862db04139d27e0af5437ed`;适配版本:1;能力摘要:`bd35b8a8f525210316d9711b6e5773d3b23d5d9b5aea96a66502137ad0d5dc16`。
|
|
4
|
+
|
|
5
|
+
这些原文是设计参考;先读[享搭适配与工作流](design-workflow.md)。上游 preview/outputs 是示例产物,Best Pairings 是可选建议,并不表示这些工具已安装。实际授权与应用事实以当前任务为准。
|
|
6
|
+
|
|
7
|
+
Craft 来自 OpenDesign,并注明改编自 Refero Design 的 MIT 许可 refero_skill;各条目保留原文署名和来源。
|
|
8
|
+
|
|
9
|
+
## typography
|
|
10
|
+
|
|
11
|
+
来源:https://github.com/nexu-io/open-design/blob/07170f8d2213936b7862db04139d27e0af5437ed/craft/typography.md
|
|
12
|
+
|
|
13
|
+
### Typography craft rules
|
|
14
|
+
|
|
15
|
+
Universal typography rules that apply on top of any `DESIGN.md`. The
|
|
16
|
+
active design system decides *which* fonts; this file decides *how* they
|
|
17
|
+
behave at every size.
|
|
18
|
+
|
|
19
|
+
> Adapted from [refero_skill](https://github.com/referodesign/refero_skill)
|
|
20
|
+
> (MIT) — distilled and re-tuned for OpenDesign's token system.
|
|
21
|
+
|
|
22
|
+
#### Type scale
|
|
23
|
+
|
|
24
|
+
Use a multiplicative scale (1.2 or 1.25). Cap at 6–8 sizes per artifact.
|
|
25
|
+
|
|
26
|
+
| Role | Range |
|
|
27
|
+
|---|---|
|
|
28
|
+
| Display | 48–72 px |
|
|
29
|
+
| H1 | 32–48 px |
|
|
30
|
+
| H2 | 24–32 px |
|
|
31
|
+
| H3 | 20–24 px |
|
|
32
|
+
| Body | 15–18 px |
|
|
33
|
+
| Small | 13–14 px |
|
|
34
|
+
| Caption | 11–12 px |
|
|
35
|
+
|
|
36
|
+
#### Line height (leading)
|
|
37
|
+
|
|
38
|
+
| Text size | Line height |
|
|
39
|
+
|---|---|
|
|
40
|
+
| Display / H1 (≥32 px) | `1.0`–`1.2` (tight) |
|
|
41
|
+
| Body (15–18 px) | `1.5`–`1.6` |
|
|
42
|
+
| Small (≤14 px) | `1.5` |
|
|
43
|
+
|
|
44
|
+
##### CJK overrides — these are not optional
|
|
45
|
+
|
|
46
|
+
The table above is Latin leading. Latin display type can go to `1.0`
|
|
47
|
+
because the ascender/descender slack inside the em box keeps lines
|
|
48
|
+
apart. **CJK glyphs fill the em box**, so the same value makes
|
|
49
|
+
consecutive lines touch, and multi-line Chinese headlines visibly
|
|
50
|
+
collide.
|
|
51
|
+
|
|
52
|
+
| Text size | Latin | CJK |
|
|
53
|
+
|---|---|---|
|
|
54
|
+
| Display / H1 (≥32 px) | `1.0`–`1.2` | **`1.3`–`1.4`** |
|
|
55
|
+
| Body (15–18 px) | `1.5`–`1.6` | `1.7`–`1.8` |
|
|
56
|
+
|
|
57
|
+
The CJK floor has **no upper size tier**. It applies to every heading
|
|
58
|
+
level, including the **cover / hero main title** — the single biggest
|
|
59
|
+
headline on a deck's first slide. A Chinese cover title at 72 px,
|
|
60
|
+
96 px, or larger, especially one split into multiple lines with
|
|
61
|
+
`<br>`, is still CJK display text: set `line-height: 1.3`–`1.4` on
|
|
62
|
+
it, never the Latin `1.0`–`1.2`. At 96 px a `1.05` leading makes the
|
|
63
|
+
two lines of a Chinese cover headline visibly collide. This is the
|
|
64
|
+
single most common violation, so check the cover main title first.
|
|
65
|
+
|
|
66
|
+
Negative tracking is Latin-only for the same reason: CJK is already
|
|
67
|
+
set on a fixed em grid, so `-0.02em` on a Chinese headline crowds the
|
|
68
|
+
glyphs instead of tightening the word. Use `0` for CJK display text.
|
|
69
|
+
|
|
70
|
+
When one artifact mixes both — an English kicker over a Chinese
|
|
71
|
+
headline is the common case — set the tight Latin values on the Latin
|
|
72
|
+
element only. Do not inherit them onto the CJK block from a shared
|
|
73
|
+
parent rule.
|
|
74
|
+
|
|
75
|
+
#### Letter-spacing — the rule that makes or breaks craft
|
|
76
|
+
|
|
77
|
+
This is the single most-skipped rule in AI-generated design. **No
|
|
78
|
+
exceptions.**
|
|
79
|
+
|
|
80
|
+
| Context | Letter-spacing |
|
|
81
|
+
|---|---|
|
|
82
|
+
| Body text (14–18 px) | `0` (default) |
|
|
83
|
+
| Small text (11–13 px) | `0.01em` to `0.02em` (positive) |
|
|
84
|
+
| UI labels and button text | `0.02em` |
|
|
85
|
+
| **ALL CAPS** | **`0.06em` to `0.1em` (required)** |
|
|
86
|
+
| Headings 32 px+ | `-0.01em` to `-0.02em` |
|
|
87
|
+
| Display 48 px+ | `-0.02em` to `-0.03em` |
|
|
88
|
+
|
|
89
|
+
ALL CAPS without positive tracking looks cramped and amateur. Display
|
|
90
|
+
text without negative tracking looks loose and weak. These two failures
|
|
91
|
+
are the most reliable AI-slop tells.
|
|
92
|
+
|
|
93
|
+
The `0.06em` floor is not arbitrary: it is the empirical lower bound
|
|
94
|
+
that print and web typographers have converged on for uppercase
|
|
95
|
+
tracking (cf. Bringhurst's *Elements of Typographic Style* §3.2.7,
|
|
96
|
+
which recommends 5–10% of the em for caps; modern screen practice
|
|
97
|
+
rounds the lower end to 0.06em). Anything tighter and the counters
|
|
98
|
+
collide on screen; the upper bound `0.1em` keeps the word from
|
|
99
|
+
disintegrating into letters.
|
|
100
|
+
|
|
101
|
+
#### Font pairing
|
|
102
|
+
|
|
103
|
+
- Maximum 2 typefaces per artifact (display + body, or one variable face
|
|
104
|
+
used at multiple weights).
|
|
105
|
+
- Always declare a system fallback chain. If the active `DESIGN.md`
|
|
106
|
+
ships a webfont URL, the fallback must still produce a coherent look.
|
|
107
|
+
- Never set `font-family: system-ui` alone on a heading — that is the
|
|
108
|
+
textbook AI default; always pair it with an intentional first choice.
|
|
109
|
+
|
|
110
|
+
#### Line length
|
|
111
|
+
|
|
112
|
+
Limit body copy to **50–75 characters** per line. In CSS:
|
|
113
|
+
`max-width: 65ch` is a safe default.
|
|
114
|
+
|
|
115
|
+
#### Three-weight system
|
|
116
|
+
|
|
117
|
+
Most well-crafted UIs use exactly 3 weights:
|
|
118
|
+
- **Read** (400 / 450) — body copy
|
|
119
|
+
- **Emphasize** (510 / 550) — UI text, labels, navigation
|
|
120
|
+
- **Announce** (590 / 600) — headlines, buttons
|
|
121
|
+
|
|
122
|
+
Weight 700+ is rarely needed. If your design uses bold for "emphasis on
|
|
123
|
+
emphasis," it likely lacks weight discipline elsewhere.
|
|
124
|
+
|
|
125
|
+
#### Common mistakes (lint these)
|
|
126
|
+
|
|
127
|
+
- ALL CAPS without `letter-spacing` ≥ `0.06em`.
|
|
128
|
+
- Display text (≥32 px) without negative tracking (Latin only — see the CJK overrides).
|
|
129
|
+
- CJK display text at Latin leading (`≤1.2`), which makes the lines overlap.
|
|
130
|
+
- Multi-line CJK cover / hero titles (72–96 px+, e.g. split with `<br>`) below `1.3` line-height.
|
|
131
|
+
- Negative tracking applied to CJK text.
|
|
132
|
+
- More than 3 type sizes visible above the fold.
|
|
133
|
+
- Mixed serif and slab on the same screen without a clear role split.
|
|
134
|
+
- Body copy in `text-align: justify` (creates rivers; never use on the web).
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
## typography-hierarchy
|
|
138
|
+
|
|
139
|
+
来源:https://github.com/nexu-io/open-design/blob/07170f8d2213936b7862db04139d27e0af5437ed/craft/typography-hierarchy.md
|
|
140
|
+
|
|
141
|
+
### Typography hierarchy craft rules
|
|
142
|
+
|
|
143
|
+
Shared hierarchy contracts that layer on top of `typography.md`. This file does
|
|
144
|
+
not repeat scale ranges or tracking values — those live in `typography.md`.
|
|
145
|
+
This file defines how hierarchy *behaves*: entry points, rhythm, tension, and
|
|
146
|
+
the conditions under which controlled violations are allowed. This contract
|
|
147
|
+
applies per-surface (a page with multiple pacing resets may establish new
|
|
148
|
+
primaries at intentional intervals), not globally.
|
|
149
|
+
|
|
150
|
+
> Opt in via `od.craft.requires: [typography, typography-hierarchy]`.
|
|
151
|
+
> Aesthetic-specific variants (e.g. `typography-hierarchy-editorial`) extend this.
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
#### The core contract
|
|
156
|
+
|
|
157
|
+
Every typographic surface must satisfy all three:
|
|
158
|
+
|
|
159
|
+
1. **One dominant entry point.** The eye needs a place to start. One element
|
|
160
|
+
wins the hierarchy — not two, not three. If everything competes, nothing leads.
|
|
161
|
+
2. **Intentional rhythm between levels.** Hierarchy is not a list of sizes.
|
|
162
|
+
It is the *contrast* between them. Adjacent levels that are too close
|
|
163
|
+
in scale, weight, or spacing produce a flat, undifferentiated surface.
|
|
164
|
+
3. **Recoverable information flow.** Hierarchy may be inverted, collapsed,
|
|
165
|
+
or disrupted — but a reader must still be able to reconstruct the content
|
|
166
|
+
structure without re-reading. If they can't, it's chaos, not tension.
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
#### Hierarchy vectors
|
|
171
|
+
|
|
172
|
+
Scale is one lever. Use all five.
|
|
173
|
+
|
|
174
|
+
| Vector | What it controls | Hierarchy direction |
|
|
175
|
+
|---|---|---|
|
|
176
|
+
| Scale | Size contrast between levels | Large → small reads as primary → secondary |
|
|
177
|
+
| Weight | Mass contrast between levels | Heavier reads as primary (see Controlled violations for weight inversion) |
|
|
178
|
+
| Spacing | Breathing room around an element | More space = more visual importance |
|
|
179
|
+
| Tracking | Tension and velocity | Tighter = faster; wider = ceremonial, slower |
|
|
180
|
+
| Alignment | Relationship to the grid/edge | Breaking alignment signals importance |
|
|
181
|
+
|
|
182
|
+
No single vector is required. A heading may lead through spacing alone if
|
|
183
|
+
scale is deliberately suppressed. A pull quote may lead through alignment
|
|
184
|
+
break. Identify which vectors are active and make sure at least two are
|
|
185
|
+
working in the same direction for the dominant element.
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
#### Semantic role ≠ visual role
|
|
190
|
+
|
|
191
|
+
Allowed. Not an error. Not a lint violation.
|
|
192
|
+
|
|
193
|
+
An `<h1>` may render visually quieter than a nearby `<p>` if the
|
|
194
|
+
composition requires it. Body copy may behave like display typography.
|
|
195
|
+
A label may visually outrank a heading.
|
|
196
|
+
|
|
197
|
+
**The condition:** information flow must remain intact. A user who reads
|
|
198
|
+
linearly must still understand what is important, what supports it, and
|
|
199
|
+
what is incidental — regardless of which element "wins" visually.
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
#### Hierarchy rhythm — the two failure modes
|
|
204
|
+
|
|
205
|
+
##### Flat hierarchy
|
|
206
|
+
|
|
207
|
+
Everything lands at roughly the same visual weight. The surface reads as
|
|
208
|
+
a wall. Usually caused by:
|
|
209
|
+
- Scale steps that are too close (e.g. 18 / 20 / 22 px for three levels)
|
|
210
|
+
- Weight used only once (everything is regular, or everything is medium)
|
|
211
|
+
- Uniform spacing between all elements
|
|
212
|
+
|
|
213
|
+
Fix: increase contrast between levels. Use at least two vectors simultaneously.
|
|
214
|
+
|
|
215
|
+
##### Noise hierarchy
|
|
216
|
+
|
|
217
|
+
Too many elements fighting for dominance. Everything is bold, large, or
|
|
218
|
+
accented. The eye has no resting point and no path.
|
|
219
|
+
|
|
220
|
+
Fix: promote one element deliberately. Demote everything else — including
|
|
221
|
+
things that feel important. Hierarchy is relative, not absolute.
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
#### Controlled violations
|
|
226
|
+
|
|
227
|
+
The following are explicitly allowed when the three core contracts are met:
|
|
228
|
+
|
|
229
|
+
| Violation | Allowed when |
|
|
230
|
+
|---|---|
|
|
231
|
+
| Body copy at display scale | It is the intended entry point and nothing else competes |
|
|
232
|
+
| Heading rendered lighter than body | Intentional visual inversion with intact information flow |
|
|
233
|
+
| Zero scale contrast between levels | Hierarchy is carried entirely by spacing or tracking |
|
|
234
|
+
| No heading-level element visible | Hierarchy is emergent from layout/spacing alone |
|
|
235
|
+
| Primary-level spacing applied to secondary element | Creates deliberate tension while maintaining information flow |
|
|
236
|
+
|
|
237
|
+
**"Information flow remains intact" safeguards:**
|
|
238
|
+
- DOM/reading order still matches content meaning (no layout inversion breaks narrative)
|
|
239
|
+
- Proximity groups the inverted element with its parent/context
|
|
240
|
+
- Only one primary exists in the visual region (no competing co-primaries)
|
|
241
|
+
- A quick scan can identify entry point / support / incidental roles without rereading
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
#### Spacing as hierarchy
|
|
246
|
+
|
|
247
|
+
Spacing is a full hierarchy vector. A typographic level can be elevated
|
|
248
|
+
entirely through surrounding whitespace without changing its size or weight.
|
|
249
|
+
|
|
250
|
+
Rules:
|
|
251
|
+
- Space above an element signals its relationship to what came before.
|
|
252
|
+
- Space below an element signals its relationship to what follows.
|
|
253
|
+
- An isolated element with large surrounding space reads as display-level
|
|
254
|
+
regardless of its font size.
|
|
255
|
+
- Uniform spacing between all elements destroys spatial hierarchy.
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
#### Three-level working model
|
|
260
|
+
|
|
261
|
+
Most surfaces can be mapped to three functional levels:
|
|
262
|
+
|
|
263
|
+
| Level | Role | Typical vectors |
|
|
264
|
+
|---|---|---|
|
|
265
|
+
| **Primary** | Entry point. One at a time per visual region; long-form surfaces may re-establish at intentional pacing resets. | Scale, spacing, or alignment break |
|
|
266
|
+
| **Secondary** | Structure. Subdivides or supports primary. | Weight, scale step, or tracking shift |
|
|
267
|
+
| **Tertiary** | Incidental. Labels, captions, metadata. | Scale reduction, weight reduction, or positive tracking |
|
|
268
|
+
|
|
269
|
+
More than three visible levels above the fold is usually a composition problem,
|
|
270
|
+
not a hierarchy opportunity. Collapse or demote before adding a fourth level.
|
|
271
|
+
|
|
272
|
+
**Long-form surfaces:** May re-establish a primary at intentional pacing resets
|
|
273
|
+
(e.g. a new section with its own headline and breathing room). Never maintain
|
|
274
|
+
two simultaneous primaries within the same visual region.
|
|
275
|
+
|
|
276
|
+
---
|
|
277
|
+
|
|
278
|
+
#### Anti-patterns
|
|
279
|
+
|
|
280
|
+
- **Graduated weight ladder** — regular → medium → semibold → bold → extrabold,
|
|
281
|
+
each level one step heavier. Reads as a default scale, not authored hierarchy.
|
|
282
|
+
Weight should jump, not step.
|
|
283
|
+
- **Uniform section spacing** — every section gap is the same value. No
|
|
284
|
+
hierarchy information is carried by spacing. Vary it deliberately.
|
|
285
|
+
- **Heading as the only hierarchy vector** — the heading is large and bold;
|
|
286
|
+
everything else is flat. The heading does all the work. This is a sign
|
|
287
|
+
that spacing and tracking are not being used as vectors.
|
|
288
|
+
- **Symmetrical emphasis** — two elements receive equal visual weight as
|
|
289
|
+
co-primaries. Pick one. The other becomes secondary.
|
|
290
|
+
- **Size-only hierarchy** — all contrast is in font size alone. Weight,
|
|
291
|
+
spacing, tracking, and alignment are uniform across levels. Fragile —
|
|
292
|
+
any layout constraint that collapses the size contrast destroys the hierarchy.
|
|
293
|
+
|
|
294
|
+
---
|
|
295
|
+
|
|
296
|
+
#### Lint
|
|
297
|
+
|
|
298
|
+
- [ ] One element is unambiguously dominant above the fold.
|
|
299
|
+
- [ ] At least two hierarchy vectors are active on the dominant element.
|
|
300
|
+
- [ ] No two adjacent levels share the same scale, weight, AND spacing.
|
|
301
|
+
- [ ] Spacing between levels varies — at least one gap is ≥1.5× the others or
|
|
302
|
+
represents one typographic scale step (e.g. one token unit like `gap-md` vs `gap-sm`). (guidance)
|
|
303
|
+
- [ ] Semantic/visual role inversions remain structurally readable.
|
|
304
|
+
- [ ] Flat hierarchy: scale steps between levels are ≥1.25× apart OR compensated by a weight or spacing jump. (guidance)
|
|
305
|
+
- [ ] Noise hierarchy: no more than one element reads as primary above the fold.
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
## color
|
|
309
|
+
|
|
310
|
+
来源:https://github.com/nexu-io/open-design/blob/07170f8d2213936b7862db04139d27e0af5437ed/craft/color.md
|
|
311
|
+
|
|
312
|
+
### Color craft rules
|
|
313
|
+
|
|
314
|
+
Universal color rules applied on top of the active `DESIGN.md`. The
|
|
315
|
+
design system supplies the palette tokens; this file enforces how to
|
|
316
|
+
*use* them.
|
|
317
|
+
|
|
318
|
+
> Adapted from [refero_skill](https://github.com/referodesign/refero_skill)
|
|
319
|
+
> (MIT). All examples reference OpenDesign's standard tokens
|
|
320
|
+
> (`--bg`, `--surface`, `--fg`, `--muted`, `--border`, `--accent`).
|
|
321
|
+
|
|
322
|
+
#### Palette structure
|
|
323
|
+
|
|
324
|
+
A coherent palette has four layers. Plan all four before writing any CSS.
|
|
325
|
+
|
|
326
|
+
| Layer | Share of pixels | Tokens |
|
|
327
|
+
|---|---|---|
|
|
328
|
+
| **Neutrals** | 70–90% | `--bg`, `--surface`, `--fg`, `--muted`, `--border` |
|
|
329
|
+
| **Accent** (one) | 5–10% | `--accent` only — never invent a second accent |
|
|
330
|
+
| **Semantic** | 0–5% | `--success`, `--warn`, `--danger` |
|
|
331
|
+
| **Effect** | <1% | gradients, glows; rarely justified |
|
|
332
|
+
|
|
333
|
+
#### Accent discipline
|
|
334
|
+
|
|
335
|
+
The single biggest readability failure in AI-generated UIs is accent
|
|
336
|
+
overuse. Hard caps:
|
|
337
|
+
|
|
338
|
+
- **At most 2 visible uses of `--accent` per screen.** Typical pair:
|
|
339
|
+
one eyebrow / chip + one primary CTA. Or one accent card + one tab
|
|
340
|
+
pill. Pick a pair, not a flood.
|
|
341
|
+
- Links count as accent; demote to `--fg` underline if you also have a
|
|
342
|
+
CTA on the same screen.
|
|
343
|
+
- Hover/focus rings count as accent. Ration accordingly.
|
|
344
|
+
|
|
345
|
+
#### Contrast minimums
|
|
346
|
+
|
|
347
|
+
Run these as gates, not goals:
|
|
348
|
+
|
|
349
|
+
| Pair | Minimum |
|
|
350
|
+
|---|---|
|
|
351
|
+
| Body text (≤16 px) on background | **4.5:1** |
|
|
352
|
+
| Large text (>18 px or 14 px bold) | **3:1** |
|
|
353
|
+
| UI components against adjacent surfaces | **3:1** |
|
|
354
|
+
|
|
355
|
+
When the brand color clashes (low-contrast indigo on light background is
|
|
356
|
+
common), darken the accent to a `600`-level shade for text use; reserve
|
|
357
|
+
the brand-bright variant for fills only.
|
|
358
|
+
|
|
359
|
+
#### Dark themes
|
|
360
|
+
|
|
361
|
+
Avoid pure black and pure white — both cause vibration and eye strain.
|
|
362
|
+
|
|
363
|
+
| Token | Dark theme | Light theme |
|
|
364
|
+
|---|---|---|
|
|
365
|
+
| Background | `#0f0f0f` (not `#000`) | `#fafafa` (not `#fff`) |
|
|
366
|
+
| Foreground | `#f0f0f0` (not `#fff`) | `#111111` (not `#000`) |
|
|
367
|
+
|
|
368
|
+
On dark surfaces, prefer **semi-transparent white borders** over solid
|
|
369
|
+
dark borders — a 1px `rgba(255,255,255,0.08)` reads as structure
|
|
370
|
+
without adding visual noise.
|
|
371
|
+
|
|
372
|
+
#### Semantic color naming
|
|
373
|
+
|
|
374
|
+
Always name tokens by **purpose**, never by hue:
|
|
375
|
+
|
|
376
|
+
```css
|
|
377
|
+
/* good */
|
|
378
|
+
--accent: #2f6feb;
|
|
379
|
+
--success: #17a34a;
|
|
380
|
+
|
|
381
|
+
/* bad — locks you out of theming */
|
|
382
|
+
--blue-500: #2f6feb;
|
|
383
|
+
--green-500: #17a34a;
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
#### Anti-defaults
|
|
387
|
+
|
|
388
|
+
- **Indigo `#6366f1`** (Tailwind `indigo-500`) is the most reliable
|
|
389
|
+
AI-slop tell. The active `DESIGN.md` provides `--accent`; use it. If
|
|
390
|
+
the brief truly needs indigo, make the user say so explicitly. If
|
|
391
|
+
your `DESIGN.md` encodes indigo as `--accent`, that is intentional —
|
|
392
|
+
the linter only flags hardcoded hex, so `var(--accent)` uses are
|
|
393
|
+
unaffected even when the resolved color happens to be `#6366f1`.
|
|
394
|
+
- **Two-stop "trust" gradient** (purple → blue, blue → cyan, etc.) on a
|
|
395
|
+
hero is the second most reliable tell. A flat surface + one
|
|
396
|
+
type-driven hierarchy beats it every time.
|
|
397
|
+
- **Decorative gradients with no functional purpose**. Gradients should
|
|
398
|
+
separate hierarchies (header → body, primary CTA → secondary), not
|
|
399
|
+
decorate empty space.
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
## state-coverage
|
|
403
|
+
|
|
404
|
+
来源:https://github.com/nexu-io/open-design/blob/07170f8d2213936b7862db04139d27e0af5437ed/craft/state-coverage.md
|
|
405
|
+
|
|
406
|
+
### State coverage craft rules
|
|
407
|
+
|
|
408
|
+
Universal rules for what every interactive surface must render. The active
|
|
409
|
+
`DESIGN.md` decides how each state looks; this file decides which states must
|
|
410
|
+
exist and what they must contain. The single most reliable AI-design failure
|
|
411
|
+
is shipping only the populated state.
|
|
412
|
+
|
|
413
|
+
> Distilled from WCAG 2.2, NN/g, Material Design 3, Apple HIG, and Baymard
|
|
414
|
+
> Institute checkout research.
|
|
415
|
+
|
|
416
|
+
#### The five required states
|
|
417
|
+
|
|
418
|
+
Every surface that fetches, transforms, or accepts data must render all five.
|
|
419
|
+
|
|
420
|
+
| State | Triggered when | Must contain |
|
|
421
|
+
|---|---|---|
|
|
422
|
+
| **Loading** | Data is in flight | Skeleton, spinner, or shell — plus a 15 s "taking longer than expected" fallback |
|
|
423
|
+
| **Empty** | No records yet, or query returned nothing | Headline, plain explanation, primary CTA |
|
|
424
|
+
| **Error** | Fetch failed, server failure, validation rejection | Plain-language cause, recovery action, preserved user input |
|
|
425
|
+
| **Populated** | Data present, primary case | The state the design was actually drawn for |
|
|
426
|
+
| **Edge** | Extreme volume, long strings, missing optional fields, RTL or long-word content, partial network | Layout that does not break |
|
|
427
|
+
|
|
428
|
+
Render-and-screenshot test: every list, table, card, form, and panel in the
|
|
429
|
+
artifact has all five. Missing states are the most common silent failure of
|
|
430
|
+
AI-generated UI.
|
|
431
|
+
|
|
432
|
+
**Test matrix.** Concrete edge scenarios the surface must survive:
|
|
433
|
+
|
|
434
|
+
| Skill type | Edge scenario |
|
|
435
|
+
|---|---|
|
|
436
|
+
| Dashboard / table | 10,000+ rows, all numeric columns, sort + filter applied |
|
|
437
|
+
| Mobile card / list | 200-char title, missing avatar, missing secondary CTA |
|
|
438
|
+
| Form | All optional fields empty, all required fields at max length |
|
|
439
|
+
| Search results | Single-character query, query with only special chars, 1,000+ result count |
|
|
440
|
+
| Detail view | Missing all optional metadata, RTL primary content with LTR embeds |
|
|
441
|
+
|
|
442
|
+
#### Form-specific states
|
|
443
|
+
|
|
444
|
+
Forms add three states on top of the five.
|
|
445
|
+
|
|
446
|
+
| State | Triggered when | Behavior |
|
|
447
|
+
|---|---|---|
|
|
448
|
+
| **Untouched** | Field has not yet had focus | Default styling; no validation messages |
|
|
449
|
+
| **Dirty (valid)** | User typed and field passes validation | Persistent helper text remains; no success-coloring |
|
|
450
|
+
| **Submitted-pending** | Submit clicked, awaiting server | Submit button enters loading state; fields lock against re-submission |
|
|
451
|
+
|
|
452
|
+
Validation timing: validate **on blur**, not on first keystroke. For password
|
|
453
|
+
and similar live fields, validate on each keystroke *only after the first
|
|
454
|
+
blur*. Remove the error message the instant input becomes valid.
|
|
455
|
+
|
|
456
|
+
#### Empty state composition
|
|
457
|
+
|
|
458
|
+
Empty is not the absence of state. It is its own state with a job.
|
|
459
|
+
|
|
460
|
+
- **First-use empty** — illustration + headline + value sentence + primary CTA. The empty is the onboarding moment.
|
|
461
|
+
- **No-results empty** — echo the query, suggest alternatives, never leave a true blank.
|
|
462
|
+
- **Cleared empty** — celebratory phrasing, optional next-action.
|
|
463
|
+
- **Error-as-empty** — never. An error is its own state with recovery information; do not collapse error into empty.
|
|
464
|
+
|
|
465
|
+
**Server-driven vs client-driven.** When a search or query API can return fallback content in the empty payload (suggestions, related categories, popular results), prefer that over a client-side echo. Algolia, Elastic, and most modern search backends support this — the server has more context for what "no results, but maybe try X" should mean.
|
|
466
|
+
|
|
467
|
+
#### Error state composition
|
|
468
|
+
|
|
469
|
+
Every error must answer three questions, in this order:
|
|
470
|
+
|
|
471
|
+
1. **What happened.** "Your card was declined." Not "Something went wrong."
|
|
472
|
+
2. **Why, if knowable.** "Insufficient funds." Or "Network unreachable — check your connection."
|
|
473
|
+
3. **What the user can do.** A retry button, an alternative path, or a support link.
|
|
474
|
+
|
|
475
|
+
Preserve user input across the error. The form must not clear on submit
|
|
476
|
+
failure.
|
|
477
|
+
|
|
478
|
+
Severity tiers:
|
|
479
|
+
|
|
480
|
+
- **Field-level** — red border, inline message, focus moves to the field.
|
|
481
|
+
- **Form-level** — error summary banner at top + per-field markers.
|
|
482
|
+
- **Section-level** — inline panel with retry, surrounding sections still functional.
|
|
483
|
+
- **Page-level** — full error state with illustration and recovery CTA.
|
|
484
|
+
- **App-level** — persistent banner or modal for critical loss-of-functionality.
|
|
485
|
+
|
|
486
|
+
Match severity to surface scope. A field validation failure does not warrant
|
|
487
|
+
a page-level error.
|
|
488
|
+
|
|
489
|
+
**Retry discipline.** A retry surface is not a button alone. It has timing rules:
|
|
490
|
+
|
|
491
|
+
- First retry fires immediately on user click.
|
|
492
|
+
- Second and third retries use exponential backoff: 2 s, 4 s, 8 s max.
|
|
493
|
+
- After 3 failed retries, replace "Retry" with "Contact support" plus a copyable error ID. The user has done their job; the system now needs a human.
|
|
494
|
+
- Show "Last attempted: Xs ago" on the error surface after the first retry, so the user knows how stale the failure is.
|
|
495
|
+
|
|
496
|
+
#### Loading state thresholds
|
|
497
|
+
|
|
498
|
+
Pick the indicator by expected duration, not by what's available in the
|
|
499
|
+
component library.
|
|
500
|
+
|
|
501
|
+
| Duration | Indicator |
|
|
502
|
+
|---|---|
|
|
503
|
+
| 0–300 ms | None. Render synchronously; users perceive no delay. |
|
|
504
|
+
| 300 ms – 2 s | Subtle spinner or skeleton. |
|
|
505
|
+
| 2 – 10 s | Skeleton matched to expected layout, or labelled spinner ("Loading payments…"). |
|
|
506
|
+
| 10 – 30 s | Determinate progress bar with cancel option. |
|
|
507
|
+
| 30 – 60 s | Progress bar with explicit cancel affordance. The "taking longer than expected" notice already appeared at 15 s; do not repeat it. |
|
|
508
|
+
| 60 s+ | Stop animation. Show error with retry, cancel, or continue. |
|
|
509
|
+
|
|
510
|
+
Never leave a spinner running indefinitely. Start a timeout on every request.
|
|
511
|
+
|
|
512
|
+
#### ARIA and focus rules
|
|
513
|
+
|
|
514
|
+
State changes must be announced and focused correctly.
|
|
515
|
+
|
|
516
|
+
| Change | ARIA | Focus action |
|
|
517
|
+
|---|---|---|
|
|
518
|
+
| Inline error on submit | `role="alert"` on the message | Move focus to first error field |
|
|
519
|
+
| Toast / non-urgent confirmation | `role="status"` (polite live region) | Do not move focus |
|
|
520
|
+
| Critical error or destructive confirmation | `role="alertdialog"` (assertive) | Move focus to dialog |
|
|
521
|
+
| Loading begins | `role="status"` announcement ("Loading…") | Do not move focus to spinner |
|
|
522
|
+
| Loading ends, content appears | — | Move focus to loaded content if action was user-initiated |
|
|
523
|
+
|
|
524
|
+
Live region containers must exist in the DOM before content is injected.
|
|
525
|
+
Adding `aria-live` simultaneously with content does not trigger an
|
|
526
|
+
announcement.
|
|
527
|
+
|
|
528
|
+
#### Common mistakes (lint these)
|
|
529
|
+
|
|
530
|
+
- Surface renders only the populated state; loading, empty, error, and edge are absent.
|
|
531
|
+
- Empty state is a literal blank or "No data" text with no headline, explanation, or action.
|
|
532
|
+
- Error message reads "Something went wrong" with no cause or recovery.
|
|
533
|
+
- Spinner with no timeout; runs indefinitely on slow or failed requests.
|
|
534
|
+
- Submit clears form fields on validation failure, forcing re-entry.
|
|
535
|
+
- Inline validation fires on first keystroke instead of on blur.
|
|
536
|
+
- Full-page loading replaces the chrome when only one section is fetching.
|
|
537
|
+
- Toast appears at a different screen position than previous toasts in the same artifact.
|
|
538
|
+
- Color alone conveys error state — no icon, no text label.
|
|
539
|
+
- Auto-dismissing toast cannot be paused on hover or focus (WCAG SC 2.2.1).
|
|
540
|
+
|
|
541
|
+
|
|
542
|
+
## accessibility-baseline
|
|
543
|
+
|
|
544
|
+
来源:https://github.com/nexu-io/open-design/blob/07170f8d2213936b7862db04139d27e0af5437ed/craft/accessibility-baseline.md
|
|
545
|
+
|
|
546
|
+
### Accessibility baseline craft rules
|
|
547
|
+
|
|
548
|
+
Universal rules for the legal floor of accessibility plus the craft
|
|
549
|
+
commitments that go beyond it. The active `DESIGN.md` decides brand
|
|
550
|
+
appearance; this file decides which rules an artifact has to clear
|
|
551
|
+
before it ships.
|
|
552
|
+
|
|
553
|
+
> Grounded in primary sources: WCAG 2.2 Understanding pages,
|
|
554
|
+
> ISO/IEC 40500:2025, ADA Title II 2024 + 2026 IFR, EN 301 549 v3.2.1,
|
|
555
|
+
> WAI-ARIA 1.3 + AccName 1.2 + Core AAM 1.2, WebAIM Million 2026
|
|
556
|
+
> (February 2026 crawl), A11yn (arXiv 2510.13914), APCA W3C silver
|
|
557
|
+
> branch.
|
|
558
|
+
|
|
559
|
+
#### Prior art and scope
|
|
560
|
+
|
|
561
|
+
Existing OSS a11y guidance for AI agents (`fecarrico/A11Y.md`,
|
|
562
|
+
`awesome-copilot agents/accessibility.agent.md`,
|
|
563
|
+
`Community-Access/accessibility-agents`) tends to inline a checklist of
|
|
564
|
+
WCAG SCs without versioning the legal floor or specifying which
|
|
565
|
+
constraints survive on iOS / Android / Flutter. This file scopes
|
|
566
|
+
narrower: the compliance floor an OD artifact must clear, with
|
|
567
|
+
jurisdiction notes and native-mobile parity. Heuristic rules and
|
|
568
|
+
linter-checked items live in sibling craft files
|
|
569
|
+
(`anti-ai-slop.md`, `state-coverage.md`); WCAG SC numbers map to
|
|
570
|
+
specific rules below rather than being re-listed.
|
|
571
|
+
|
|
572
|
+
#### The legal floor changes by jurisdiction
|
|
573
|
+
|
|
574
|
+
- **EU (EAA, enforcement live 2025-06-28):** EN 301 549 v3.2.1 is the OJ-cited harmonised standard; it references **WCAG 2.1 AA**. EN 301 549 v4.1.1 (which incorporates WCAG 2.2's nine new SCs) is OJ-citation-targeted late 2026 / 2027. Until then, EAA references WCAG 2.1. The Web Accessibility Directive (WAD, EU 2016/2102) covers public-sector bodies separately and also points at EN 301 549.
|
|
575
|
+
- **US public sector — ADA Title II 2024 final rule:** **WCAG 2.1 AA**. The 2026-04-20 IFR slipped deadlines: 2027-04-26 for jurisdictions with population ≥ 50,000; 2028-04-26 for sub-50,000 and special districts.
|
|
576
|
+
- **US federal procurement — Section 508 (Revised 508 Standards):** harmonised with EN 301 549 → references **WCAG 2.0 AA** in the current published rev. The Access Board has WCAG 2.x updates in flight; until they ship, federal IT procurement floor is WCAG 2.0.
|
|
577
|
+
- **US private sector — ADA Title III:** no federal regulation specifies a technical standard. Settlements and DOJ guidance routinely cite **WCAG 2.1 AA** as the de-facto target, but the legal mechanism is case-by-case, not rule-based.
|
|
578
|
+
- **ISO/IEC 40500:2025** (October 2025) ratified WCAG 2.2 verbatim. Does not by itself change EU or US legal floors.
|
|
579
|
+
|
|
580
|
+
**Practical rule for craft:** target **WCAG 2.2 AA** as the working
|
|
581
|
+
ceiling. It clears the WCAG 2.1 AA legal floor in both jurisdictions
|
|
582
|
+
and prepares for v4.1.1. Anything below 2.2 AA is craft debt.
|
|
583
|
+
|
|
584
|
+
#### Color contrast
|
|
585
|
+
|
|
586
|
+
| Pair | WCAG 2.x AA minimum |
|
|
587
|
+
|---|---|
|
|
588
|
+
| Normal text below 18 pt regular / 14 pt bold (covers most body and UI text) | 4.5:1 |
|
|
589
|
+
| Large text (≥18 *pt* regular ≈24 px, or ≥14 *pt* bold ≈18.5 px) | 3:1 |
|
|
590
|
+
| Non-text UI components and graphical objects | 3:1 |
|
|
591
|
+
| Focus indicator vs adjacent and unfocused state | 3:1 |
|
|
592
|
+
|
|
593
|
+
Thresholds are **inclusive** — exactly 4.5:1 or 3:1 passes. Don't round
|
|
594
|
+
up: 2.999:1 fails because rounding is not a permitted mechanism.
|
|
595
|
+
|
|
596
|
+
"Large text" means **18 pt** regular, not 18 px. 18 px regular needs
|
|
597
|
+
4.5:1; 14 pt bold (≈18.5 px) qualifies for 3:1, 14 px bold does not.
|
|
598
|
+
|
|
599
|
+
**APCA as a parallel design check.** APCA's Lc value catches font-weight
|
|
600
|
+
and stem-thickness effects that WCAG 2.x luminance ratios miss. Body
|
|
601
|
+
copy at Lc ≥60 is a reasonable parallel pass; APCA's actual lookup
|
|
602
|
+
table is size- and weight-dependent (heavier weights at larger sizes
|
|
603
|
+
clear at lower Lc, thin small text needs Lc ≥75+). APCA is not part
|
|
604
|
+
of WCAG, EN 301 549, ADA, or Section 508 compliance as of 2026-05 —
|
|
605
|
+
keep WCAG 2.2 AA as the compliance floor and treat APCA as
|
|
606
|
+
design-review only. If you ship APCA tooling, use the `apca-w3`
|
|
607
|
+
package; the SAPC repo is non-commercial.
|
|
608
|
+
|
|
609
|
+
#### Touch targets
|
|
610
|
+
|
|
611
|
+
| Bar | SC | Size |
|
|
612
|
+
|---|---|---|
|
|
613
|
+
| AA (legal floor) | 2.5.8 Target Size (Minimum) | **24×24 CSS px** |
|
|
614
|
+
| AAA (craft commitment) | 2.5.5 Target Size (Enhanced) | 44×44 CSS px |
|
|
615
|
+
| iOS HIG | — | 44×44 pt |
|
|
616
|
+
| Material 3 | — | 48×48 dp |
|
|
617
|
+
|
|
618
|
+
WCAG 2.5.8 lists five exceptions where the 24×24 minimum doesn't
|
|
619
|
+
apply: **Spacing** (a 24-CSS-px exclusion circle around the target
|
|
620
|
+
doesn't intersect adjacent ones), **Equivalent** (an alternative
|
|
621
|
+
control of sufficient size achieves the same function), **Inline**
|
|
622
|
+
(target sits inside a sentence, e.g. links in body copy), **User
|
|
623
|
+
agent control** (browser default like a native scrollbar), and
|
|
624
|
+
**Essential** (the smaller size is required to convey information,
|
|
625
|
+
e.g. a map pin). The Spacing exception is the one icon-button
|
|
626
|
+
toolbars rely on; the others are narrower than they read and
|
|
627
|
+
shouldn't be used to justify undersized primary actions.
|
|
628
|
+
|
|
629
|
+
#### Focus visibility
|
|
630
|
+
|
|
631
|
+
Removing the focus outline via CSS is a **triple failure**: 1.4.11
|
|
632
|
+
Non-text Contrast, 2.4.7 Focus Visible, and 2.4.13 Focus Appearance
|
|
633
|
+
(AAA). Use `:focus-visible` for keyboard users; suppress the outline
|
|
634
|
+
for mouse clicks only when an alternative non-color affordance exists.
|
|
635
|
+
|
|
636
|
+
For AAA (2.4.13): indicator area must equal at least a 2 CSS px
|
|
637
|
+
perimeter of the component, contrast ≥3:1 between focused and
|
|
638
|
+
unfocused states. A 1-px outline at 3:1 doesn't qualify.
|
|
639
|
+
|
|
640
|
+
#### Form input labels
|
|
641
|
+
|
|
642
|
+
WebAIM Million 2026 (which uses WAVE, not axe-core): **51% of top 1M
|
|
643
|
+
home pages have at least one missing form-input label; 33.1% of all
|
|
644
|
+
6.9M inputs are unlabeled**. The page-level rate moved from 48.2%
|
|
645
|
+
(2025) to 51% (2026) — missing-label prevalence is one of the few
|
|
646
|
+
categories WebAIM explicitly calls out as rising in 2026, against an
|
|
647
|
+
overall errors-per-page count of 56.1.
|
|
648
|
+
|
|
649
|
+
Default form-error wiring (WCAG 2.2 + ARIA APG):
|
|
650
|
+
|
|
651
|
+
```html
|
|
652
|
+
<label for="email">Email</label>
|
|
653
|
+
<input id="email" type="email" required
|
|
654
|
+
aria-describedby="email-hint email-error"
|
|
655
|
+
aria-invalid="true">
|
|
656
|
+
<span id="email-hint">Used for receipts only.</span>
|
|
657
|
+
<span id="email-error" role="alert">Email must include @ and a domain.</span>
|
|
658
|
+
```
|
|
659
|
+
|
|
660
|
+
`aria-describedby` is the production default; `aria-errormessage` has
|
|
661
|
+
incomplete screen-reader support as of 2026-05 (full on NVDA, partial
|
|
662
|
+
on JAWS / VoiceOver / TalkBack) — treat as progressive enhancement.
|
|
663
|
+
|
|
664
|
+
WCAG 3.3.7 Redundant Entry is **Level A** (legal floor). Re-asking for
|
|
665
|
+
data the user already entered "in the same process" fails unless the
|
|
666
|
+
site auto-populates or offers a selectable shortcut. Browser autofill
|
|
667
|
+
does not satisfy it.
|
|
668
|
+
|
|
669
|
+
#### Keyboard operability and semantic structure
|
|
670
|
+
|
|
671
|
+
Visual contrast and labelled inputs don't matter if a keyboard or
|
|
672
|
+
screen-reader user can't reach the control or parse the page. The
|
|
673
|
+
bullets below are Level A / AA WCAG essentials plus a small set of
|
|
674
|
+
structural conventions OD treats as craft commitments. WCAG levels
|
|
675
|
+
are noted per item.
|
|
676
|
+
|
|
677
|
+
- **Tab reachability** (2.1.1 Keyboard, Level A): every interactive element must be reachable and operable via keyboard. `tabindex="-1"` removes from the tab order; `tabindex` values >0 break document order and should not be used. (2.1.3 No Exception extends 2.1.1 to AAA by removing the underlying-function exception.)
|
|
678
|
+
- **Activation keys** (2.1.1, Level A): `<button>` activates on Enter and Space; `<a href="…">` activates on Enter. A bare `<a>` without `href` is not a link, not focusable, and not keyboard-operable — use `<a href="…">` for navigation or `<button>` for actions, never a placeholder anchor. Custom controls must implement the matching key handlers and `role`.
|
|
679
|
+
- **No keyboard trap** (2.1.2, Level A): focus must be able to leave any component via the same standard keys it entered with. Modal dialogs are a focus-trap *by design*, not a violation — they trap until dismissed by Escape or the close button.
|
|
680
|
+
- **Focus order** (2.4.3, Level A): tab order must follow the meaningful reading order. Don't rely on positive `tabindex` to fix DOM that's out of order; fix the DOM.
|
|
681
|
+
- **Native control first** (craft convention, anchored on 4.1.2 Name/Role/Value Level A): a `<button>` is keyboard-operable, focusable, name-resolvable, and announced as a button by every AT for free. `<div role="button" tabindex="0">` requires you to re-implement all of that and most reimplementations miss `aria-pressed`, disabled state, or Space-on-keyup. Reach for ARIA only when no native element fits.
|
|
682
|
+
- **Document language** (3.1.1, Level A): `<html lang="...">` is required. Sub-tree language switches use `lang` on the inner element.
|
|
683
|
+
- **Heading hierarchy** (1.3.1 Info and Relationships Level A; 2.4.6 Headings and Labels Level AA): WCAG requires programmatically-determined structure and descriptive headings, not a specific outline shape. OD craft convention layers on: prefer one `<h1>` per page and don't skip levels (`<h1>` → `<h3>` without `<h2>`). Visual size and heading level are independent.
|
|
684
|
+
- **Landmarks** (1.3.1, 2.4.1 Bypass Blocks Level A): use `<header>` `<nav>` `<main>` `<aside>` `<footer>` rather than `<div role="banner">` etc. AT users navigate by landmark; a page with no landmarks is a wall of divs.
|
|
685
|
+
- **Text alternatives** (1.1.1 Non-text Content, Level A): `<img alt="...">` for content images, `alt=""` for decorative; `aria-label` on icon-only buttons; long-form description for charts and SVG data viz. A chart without a text alternative is unreadable to a screen reader.
|
|
686
|
+
|
|
687
|
+
#### ARIA discipline
|
|
688
|
+
|
|
689
|
+
WebAIM Million 2026 shows ARIA pages average **59.1 errors** vs
|
|
690
|
+
**42** on non-ARIA pages — about 17 extra errors on the ARIA side.
|
|
691
|
+
The gap was 30 in 2025 (57 vs 27) and 15 in 2024; YoY direction is
|
|
692
|
+
noisy, but ARIA usage is up (82.7% of home pages in 2026 vs 79.4% in
|
|
693
|
+
2025) while correctness lags. ARIA deployment outpaces ARIA
|
|
694
|
+
correctness.
|
|
695
|
+
|
|
696
|
+
Decision order, per ARIA APG:
|
|
697
|
+
|
|
698
|
+
1. Native HTML element with the right semantics.
|
|
699
|
+
2. Native element under custom visuals if restyling is required.
|
|
700
|
+
3. APG pattern verbatim if neither fits.
|
|
701
|
+
4. Closest APG pattern + documented deviation. Last resort.
|
|
702
|
+
|
|
703
|
+
Never invent ARIA.
|
|
704
|
+
|
|
705
|
+
#### Reduced motion and flashing
|
|
706
|
+
|
|
707
|
+
See `animation-discipline.md` for the full rule set. The non-negotiable
|
|
708
|
+
that anchors here: WCAG 2.3.1 (Level A) — flashing more than three
|
|
709
|
+
times per one-second period is non-conformant unless the flash area
|
|
710
|
+
stays below the general and red flash thresholds. Photosensitive
|
|
711
|
+
epilepsy is the protected concern.
|
|
712
|
+
|
|
713
|
+
#### Native mobile parity
|
|
714
|
+
|
|
715
|
+
Web ARIA does not auto-translate. Each platform has its own labelling API.
|
|
716
|
+
|
|
717
|
+
| Platform | Label | Role |
|
|
718
|
+
|---|---|---|
|
|
719
|
+
| iOS UIKit | `accessibilityLabel` | `accessibilityTraits` |
|
|
720
|
+
| iOS SwiftUI | `.accessibilityLabel(…)` | `.accessibilityAddTraits(.isButton)` |
|
|
721
|
+
| Android Compose | `Modifier.semantics { contentDescription = … }` | `Modifier.semantics { role = Role.Button }` |
|
|
722
|
+
| Flutter | `Semantics(label: …)` | `Semantics(button: true, …)` |
|
|
723
|
+
| React Native | `accessibilityLabel` | `accessibilityRole` |
|
|
724
|
+
|
|
725
|
+
Use the platform API for each target. AI-generated mobile UI that
|
|
726
|
+
mirrors web ARIA verbatim usually misses the platform-native screen
|
|
727
|
+
reader path.
|
|
728
|
+
|
|
729
|
+
#### Common mistakes (lint these)
|
|
730
|
+
|
|
731
|
+
- "Target Size 44×44" cited as the AA bar. 44×44 is **AAA** (2.5.5). AA is **24×24** (2.5.8).
|
|
732
|
+
- "18 px = large text" — wrong. Threshold is 18 *pt* regular (~24 px) or 14 pt bold (~18.5 px).
|
|
733
|
+
- "EAA = WCAG 2.2 AA" — wrong. EN 301 549 v3.2.1 is anchored to WCAG 2.1.
|
|
734
|
+
- "Section 508 = WCAG 2.1 AA" — wrong as of 2026-05. Revised 508 still references WCAG 2.0 AA; the Access Board update is in flight, not shipped.
|
|
735
|
+
- "Tabindex fixes focus order" — `tabindex` >0 reorders against DOM and almost always makes it worse. Fix the DOM.
|
|
736
|
+
- "Modal traps focus → keyboard trap" — confusing 2.1.2. A modal trapping focus until Escape / close is correct behaviour, not a violation.
|
|
737
|
+
- "Heading size = heading level" — visual hierarchy and `<h1>`/`<h2>`/`<h3>` are independent. Style the level you mean.
|
|
738
|
+
- "WebAIM Million uses axe-core" — uses WAVE.
|
|
739
|
+
- "WCAG 3 will use APCA" — APCA was dropped from WCAG 3 in July 2023.
|
|
740
|
+
- "Adding ARIA improves accessibility" — empirically the opposite. WebAIM Million 2026: ARIA pages average 59.1 errors, non-ARIA pages 42.
|
|
741
|
+
- "Bare `<a>` with click handler is a link" — wrong. `<a>` without `href` is not focusable, not keyboard-operable, and not a link. Use `<a href="…">` for navigation, `<button>` for actions.
|
|
742
|
+
- Removing the focus outline via `outline: none` without a replacement. Triple failure: 1.4.11, 2.4.7, 2.4.13.
|
|
743
|
+
- Placeholder text as the only label for a form input. Fails 1.3.1 and 3.3.2; placeholder disappears on input.
|
|
744
|
+
- Using `aria-description` as the sole state-carrier on `role="row"`. JAWS 2025/2026 silently drops it ([FreedomScientific standards-support #927](https://github.com/FreedomScientific/standards-support/issues/927)).
|
|
745
|
+
- Native HTML `<button>` reimplemented as `<div role="button">` without keyboard handling, focus, or `aria-pressed`.
|
|
746
|
+
- A11y treated as web-only. Flutter / iOS / Android have their own labelling APIs that web ARIA doesn't reach.
|
|
747
|
+
|
|
748
|
+
|
|
749
|
+
## animation-discipline
|
|
750
|
+
|
|
751
|
+
来源:https://github.com/nexu-io/open-design/blob/07170f8d2213936b7862db04139d27e0af5437ed/craft/animation-discipline.md
|
|
752
|
+
|
|
753
|
+
### Animation discipline craft rules
|
|
754
|
+
|
|
755
|
+
Universal rules for when motion earns its place in a UI and what numbers
|
|
756
|
+
constrain it. The active `DESIGN.md` decides brand-specific motion
|
|
757
|
+
personality; this file decides whether motion should run at all and at
|
|
758
|
+
what duration, easing, and accessibility floor.
|
|
759
|
+
|
|
760
|
+
> Grounded in primary sources: Tversky/Morrison/Bétrancourt 2002
|
|
761
|
+
> (IJHCS), Heer & Robertson TVCG 2007, Harrison/Yeo/Hudson CHI 2010,
|
|
762
|
+
> Doherty & Thadani IBM Systems Journal 1982, Chang & Ungar UIST 1993,
|
|
763
|
+
> Material 3 motion tokens, IBM `@carbon/motion`, Apple SwiftUI
|
|
764
|
+
> Animation API, W3C View Transitions, WCAG 2.2.2 + 2.3.3, WebKit's
|
|
765
|
+
> 2017 `prefers-reduced-motion` rationale.
|
|
766
|
+
|
|
767
|
+
#### When motion earns its place
|
|
768
|
+
|
|
769
|
+
Tversky/Morrison/Bétrancourt's 2002 meta-analysis (IJHCS 57, pp. 247-262)
|
|
770
|
+
found that every study claiming animation aids comprehension had a
|
|
771
|
+
broken control — the static version had less information, different
|
|
772
|
+
procedures, or hidden interactivity. When equalised, animation does
|
|
773
|
+
**not** beat static for teaching complex systems. The single use case
|
|
774
|
+
the paper endorses is real-time spatial or temporal reorientation:
|
|
775
|
+
page transitions, container morphs, viewpoint changes, progress
|
|
776
|
+
indicators (p. 257).
|
|
777
|
+
|
|
778
|
+
A follow-on hazard: Palmiter & Elkerton found animation-trained users
|
|
779
|
+
*declined* one week after training, while text-trained users *improved*
|
|
780
|
+
(Tversky 2002, p. 255). Animation's apparent short-term parity hides
|
|
781
|
+
worse retention.
|
|
782
|
+
|
|
783
|
+
So animate when the user is moving through space, time, or state —
|
|
784
|
+
navigation, container expansion, progress feedback, gesture
|
|
785
|
+
follow-through. Don't animate to teach, decorate, signal "premium",
|
|
786
|
+
or fill silence.
|
|
787
|
+
|
|
788
|
+
#### Duration thresholds
|
|
789
|
+
|
|
790
|
+
The cross-design-system convergence is **150 ms** — Material 3 `short3`,
|
|
791
|
+
IBM Carbon `moderate-01`, Shopify Polaris `150`, Tailwind default,
|
|
792
|
+
SLDS `duration-fast` all land here. Use it as the default duration for
|
|
793
|
+
state-confirmation feedback.
|
|
794
|
+
|
|
795
|
+
| Duration | Use |
|
|
796
|
+
|---|---|
|
|
797
|
+
| 50–100 ms | Instant feedback (button press, toggle commit, hover) |
|
|
798
|
+
| 150 ms | Default for state-confirmation |
|
|
799
|
+
| 200–300 ms | Entering UI (modals, sheets, dropdowns) |
|
|
800
|
+
| 300–500 ms | Cross-screen transitions, container morphs |
|
|
801
|
+
| > 500 ms | Reserved for cross-screen, staged, or platform-native transitions (e.g. M3 `long2`-`extraLong4`, Heer & Robertson 2007's per-stage recommendation). |
|
|
802
|
+
|
|
803
|
+
Non-navigation microinteractions — hover, press, toggle, validation,
|
|
804
|
+
chip selection, row expansion — should stay under 500 ms. Past that the
|
|
805
|
+
user notices the motion as motion and waits on the UI rather than
|
|
806
|
+
working through it. Two qualifications: frequent animations (a hover
|
|
807
|
+
effect seen 50 times per session) need to stay ≤200 ms; mobile
|
|
808
|
+
animations should run 20–30% shorter than desktop equivalents because
|
|
809
|
+
travel distances are shorter.
|
|
810
|
+
|
|
811
|
+
#### Curve vs spring
|
|
812
|
+
|
|
813
|
+
Use a curve for opacity, color, and any property that changes value
|
|
814
|
+
between two known points. Use a spring for position, scale, rotation,
|
|
815
|
+
and gesture-driven motion — anything that should feel physical.
|
|
816
|
+
|
|
817
|
+
Material 3 standard easing is `cubic-bezier(0.2, 0, 0, 1)` — front-loaded;
|
|
818
|
+
the trailing zero makes the curve hit its target instantly and settle.
|
|
819
|
+
M2 standard was the symmetric `cubic-bezier(0.4, 0, 0.2, 1)`, preserved
|
|
820
|
+
in M3 under the name `legacy`. Anyone shipping the M2 curve and calling
|
|
821
|
+
it "M3" is on legacy tokens. M3 `emphasized` is a **two-segment Bézier
|
|
822
|
+
path**, not a single cubic-bezier; single-cubic approximations silently
|
|
823
|
+
lose the front-loaded character. CSS `linear()` (Chrome 113+) is the
|
|
824
|
+
only way to replicate it on a single property.
|
|
825
|
+
|
|
826
|
+
Apple's published SwiftUI default spring is
|
|
827
|
+
`(response: 0.5, dampingFraction: 0.825, blendDuration: 0)`. The widely
|
|
828
|
+
cited `.snappy = 0.25 s, .smooth = 0.35 s` numbers are wrong — Apple's
|
|
829
|
+
docs assign all three presets a 0.5 s base, differing only in bounce
|
|
830
|
+
(0 / 0.15 / 0.3).
|
|
831
|
+
|
|
832
|
+
Spring framework defaults disagree. motion.dev's physics-mode default
|
|
833
|
+
is ζ ≈ 0.5 (bouncy). React Spring's `default` is ζ = 0.997 (critically
|
|
834
|
+
damped). Same word "default", opposite feel — React Spring's `wobbly`
|
|
835
|
+
is the actual feel-equivalent of motion.dev's `default`. Pick
|
|
836
|
+
consciously.
|
|
837
|
+
|
|
838
|
+
#### Reduced motion
|
|
839
|
+
|
|
840
|
+
Every animation that translates, scales, rotates, or parallaxes must
|
|
841
|
+
respect `@media (prefers-reduced-motion: reduce)`. WebKit shipped this
|
|
842
|
+
in 2017 to address vestibular triggers; the W3C MQ5 spec lets the UA
|
|
843
|
+
or author **strip motion entirely or substitute static imagery** —
|
|
844
|
+
the spec does not mandate which.
|
|
845
|
+
|
|
846
|
+
Working rule: strip motion-on-an-axis (translate, scale, rotate,
|
|
847
|
+
parallax). Keep opacity/color crossfades as substitutes when a state
|
|
848
|
+
change still needs to be conveyed. Be explicit — the View Transitions
|
|
849
|
+
API does **not** apply `prefers-reduced-motion` automatically; the
|
|
850
|
+
author must add a query override on the pseudo-elements or skip
|
|
851
|
+
`startViewTransition` entirely.
|
|
852
|
+
|
|
853
|
+
WCAG calibration: 2.2.2 (Pause/Stop/Hide) is Level A — the legal floor
|
|
854
|
+
under ADA Title II 2024 / EN 301 549 / EAA — but it names cognitive,
|
|
855
|
+
attentional, and reading populations, not vestibular. Vestibular
|
|
856
|
+
language lives in 2.3.3, which is **AAA**. Don't conflate the two.
|
|
857
|
+
Building for vestibular users is a craft commitment beyond the legal
|
|
858
|
+
floor, not a WCAG mandate.
|
|
859
|
+
|
|
860
|
+
**Flashing limits.** WCAG 2.3.1 (Level A) permits flashing only when
|
|
861
|
+
there are no more than three flashes within any one-second period, or
|
|
862
|
+
the flashing area stays below the general and red flash thresholds.
|
|
863
|
+
WCAG 2.3.2 (AAA) forbids flashing more than three times within any
|
|
864
|
+
one-second period, regardless of area or brightness. The protected
|
|
865
|
+
concern is photosensitive epilepsy; the legal floor isn't negotiable. For gamified UI, onboarding celebrations, sparkles,
|
|
866
|
+
confetti, level-up bursts, and shimmer: avoid rapid flashing unless
|
|
867
|
+
tested against the thresholds, and prefer one-shot animations over
|
|
868
|
+
loops.
|
|
869
|
+
|
|
870
|
+
#### Repeated and ambient motion
|
|
871
|
+
|
|
872
|
+
The rules above target one-shot transitions. Looping motion (skeleton
|
|
873
|
+
shimmer, idle backgrounds, autoplay, reward bursts) has different
|
|
874
|
+
constraints.
|
|
875
|
+
|
|
876
|
+
- Cap iteration count: carousels at 3-5 cycles then pause; skeleton shimmer until content lands, never indefinitely.
|
|
877
|
+
- WCAG 2.2.2 (Level A) requires a pause control for any motion running longer than 5 seconds — moving, blinking, or scrolling content, not only video.
|
|
878
|
+
- Cancel ambient motion on route change.
|
|
879
|
+
- Reward animations are one-shot. Confetti, sparkles, level-up bursts fire once and dismiss; no looping timer.
|
|
880
|
+
- Spinners must not run indefinitely. Escalate to progress/cancel states and stop animation at 60 s, matching `state-coverage.md`.
|
|
881
|
+
|
|
882
|
+
#### Cross-platform handoff
|
|
883
|
+
|
|
884
|
+
Native conventions diverge.
|
|
885
|
+
|
|
886
|
+
- **iOS** uses spring physics with perceptual `(response, dampingFraction)` parameters. Apple HIG documents principles, not numerical curves; the SwiftUI Animation API JSON is the source for actual numbers. UIView curve cubic-beziers commonly cited online are reverse-engineered, not Apple-published.
|
|
887
|
+
- **Android** uses cubic-bezier curves through M3 motion tokens (50–1000 ms range, 16 named durations). Predictive back is a *gesture-progress primitive*, not a transition primitive — `BackEvent.progress` is sampled per-frame from the touch stream and the destination is rendered behind the current surface while still on it. Cancellation is a first-class lifecycle state.
|
|
888
|
+
- **Web** has the View Transitions API (default 0.25 s, no easing specified by the spec — falls through to CSS `ease`). Same-document support 90.94%; cross-document 87.82%. Cross-document is same-origin and user-initiated only.
|
|
889
|
+
|
|
890
|
+
A "one curve fits all platforms" approach loses on each. If the brief
|
|
891
|
+
specifies platform fidelity, follow the platform; if it specifies brand
|
|
892
|
+
consistency, pick one motion vocabulary and apply it everywhere.
|
|
893
|
+
|
|
894
|
+
#### Common mistakes (lint these)
|
|
895
|
+
|
|
896
|
+
- "Skeleton screens feel 11% faster" — Harrison/Yeo/Hudson CHI 2010 measured *backwards-decelerating ribbed determinate progress bars* (n=16). The induced-motion mechanism doesn't transfer to skeletons.
|
|
897
|
+
- "Heer & Robertson recommend 300–1000 ms eased transitions" — they tested 1.25 s and 2 s only. Their recommendation is "~1 second per stage".
|
|
898
|
+
- "Doherty Threshold = 400 ms" — the 1982 paper does not contain "400". The lowest threshold actually measured is 300 ms.
|
|
899
|
+
- M2 standard easing `cubic-bezier(0.4, 0, 0.2, 1)` labelled as "Material 3". M3's standard is `cubic-bezier(0.2, 0, 0, 1)`.
|
|
900
|
+
- Animations that *perform* a state change rather than *confirming* one that has already happened. Optimistic UI first; motion second.
|
|
901
|
+
- More than 500 ms on any non-cross-screen transition.
|
|
902
|
+
- Animation as the only signal of state change. Reduced-motion users miss it; always pair with a static affordance (color, position, label).
|
|
903
|
+
- Ignoring `prefers-reduced-motion` on transform-based animations — the highest-cost vestibular triggers.
|
|
904
|
+
- Curve-based animation on a `transform: scale()` that should feel physical. Use a spring.
|
|
905
|
+
- Hero choreography in productivity tools. Motion budget belongs inside the product on functional micro-feedback, not on landing-page sequences.
|
|
906
|
+
- Decorative motion in the working canvas of a productivity tool.
|
|
907
|
+
|
|
908
|
+
|
|
909
|
+
## laws-of-ux
|
|
910
|
+
|
|
911
|
+
来源:https://github.com/nexu-io/open-design/blob/07170f8d2213936b7862db04139d27e0af5437ed/craft/laws-of-ux.md
|
|
912
|
+
|
|
913
|
+
### Laws of UX craft rules
|
|
914
|
+
|
|
915
|
+
Universal cognitive, perceptual, and behavioral heuristics that decide
|
|
916
|
+
what a UI composes — how many pricing tiers fit on a screen, where a
|
|
917
|
+
primary action anchors in scanning order, when a progress indicator
|
|
918
|
+
earns its place, why a settings list needs grouping. The active
|
|
919
|
+
`DESIGN.md` decides brand visual language; the existing craft files
|
|
920
|
+
decide rendering rules (color, typography, motion, states, ARIA, RTL,
|
|
921
|
+
forms); this file decides composition rules grounded in named research.
|
|
922
|
+
|
|
923
|
+
> Distilled from primary sources: Hick (1952) + Hyman (1953), Miller
|
|
924
|
+
> (1956) for chunking / `7±2` channel capacity, Cowan (2001) for the
|
|
925
|
+
> modern ~4 working-memory bound, Fitts (1954), Wertheimer (1923) for
|
|
926
|
+
> proximity / similarity / Prägnanz, Palmer (1992) for Common Region,
|
|
927
|
+
> Palmer & Rock (1994) for Uniform Connectedness, Kahneman /
|
|
928
|
+
> Fredrickson / Schreiber / Redelmeier (1993) for Peak-End, Zeigarnik
|
|
929
|
+
> (1927), Csíkszentmihályi (1975), Hull (1932), von Restorff (1933),
|
|
930
|
+
> Broadbent (1958), Sweller (1988), Postel (RFC 760, 1980), Carroll &
|
|
931
|
+
> Rosson (1987), Tversky & Kahneman (1974) for Anchoring, Kurosu &
|
|
932
|
+
> Kashimura (1995), Iyengar & Lepper (2000), Toffler (1970), Pareto
|
|
933
|
+
> (c.1906) / Juran (*Quality Control Handbook*, 1951), Ebbinghaus
|
|
934
|
+
> (1885), Ockham (14th c.), Tesler at Apple (1980s), Nielsen (2000),
|
|
935
|
+
> Norman *POET* (1988), Parkinson (1955).
|
|
936
|
+
|
|
937
|
+
#### Prior art and scope
|
|
938
|
+
|
|
939
|
+
Existing public catalogs of UX heuristics (Yablonski's lawsofux.com,
|
|
940
|
+
NN/g's 10 usability heuristics, Material 3 motion + interaction
|
|
941
|
+
guidance, Apple HIG, Baymard Institute checkout research) inventory the
|
|
942
|
+
laws but rarely tie each one to a concrete code-gen directive. This
|
|
943
|
+
file does the translation: every entry ends with one actionable move
|
|
944
|
+
for an HTML / Tailwind / React-emitting agent. Sibling craft files
|
|
945
|
+
(`accessibility-baseline.md`, `state-coverage.md`, `typography.md`,
|
|
946
|
+
`anti-ai-slop.md`, `color.md`, `animation-discipline.md`,
|
|
947
|
+
`form-validation.md`) own the auto-checked rules; this file names the
|
|
948
|
+
underlying law and surfaces the folklore. Out of scope: Weber-Fechner
|
|
949
|
+
psychophysics and Signal Detection Theory — both apply to UI but the
|
|
950
|
+
prompt-emission directives are too narrow to earn a slot here. Add
|
|
951
|
+
later if a skill needs them.
|
|
952
|
+
|
|
953
|
+
The rules below are guidance, not auto-checked. Reviewers and the agent
|
|
954
|
+
apply them; the linter does not. Where a law has a sibling rule already
|
|
955
|
+
auto-checked elsewhere — touch-target floor in
|
|
956
|
+
`accessibility-baseline.md`, the 300 ms / 2 s / 10 s / 30 s / 60 s
|
|
957
|
+
loading thresholds in `state-coverage.md`, ALL CAPS letter-spacing in
|
|
958
|
+
`typography.md`, the indigo / gradient / emoji-icon list in
|
|
959
|
+
`anti-ai-slop.md` — the entry below cross-references rather than
|
|
960
|
+
duplicates.
|
|
961
|
+
|
|
962
|
+
#### Perception and visual grouping
|
|
963
|
+
|
|
964
|
+
Five Gestalt laws plus three attention-and-recognition laws govern how
|
|
965
|
+
the eye groups elements before the brain reads them.
|
|
966
|
+
|
|
967
|
+
- **Law of Proximity** (Wertheimer, 1923). Objects near each other read
|
|
968
|
+
as a group. Cheapest grouping signal — cheaper than borders or shared
|
|
969
|
+
color. Apply variable vertical rhythm: 8–12 px within a group,
|
|
970
|
+
32–48 px between groups. Uniform spacing reads as nothing being
|
|
971
|
+
grouped.
|
|
972
|
+
- **Law of Similarity** (Wertheimer, 1923). Visually similar elements
|
|
973
|
+
read as a group. Equivalent affordances must share treatment — every
|
|
974
|
+
list row identical class set, every secondary button identical, every
|
|
975
|
+
destructive action identical. Visible deviation is reserved for the
|
|
976
|
+
one item meant to draw attention (the recommended pricing tier, the
|
|
977
|
+
selected nav item).
|
|
978
|
+
- **Law of Common Region** (Palmer, 1992). A shared bounded area binds
|
|
979
|
+
enclosed elements. Use enclosure when proximity is not enough — and
|
|
980
|
+
reserve it. Concrete numbers: padding ≥16 px inside the region,
|
|
981
|
+
distinct surface (border + tinted background, or card chrome at
|
|
982
|
+
≥1 px hairline). A page where every section is bordered destroys the
|
|
983
|
+
signal.
|
|
984
|
+
- **Law of Prägnanz / Good Figure** (Wertheimer, 1923). The eye
|
|
985
|
+
resolves complex layouts into the simplest underlying form. Designs
|
|
986
|
+
that align with a clear underlying grid (12-column, F-pattern,
|
|
987
|
+
4-quadrant) feel inevitable; ornate breaks that add nothing semantic
|
|
988
|
+
feel arbitrary.
|
|
989
|
+
- **Law of Uniform Connectedness** (Palmer & Rock, 1994). The
|
|
990
|
+
strongest grouping signal in the Gestalt hierarchy: connected lines,
|
|
991
|
+
shared toolbars, or bracketing containers tie items together more
|
|
992
|
+
strongly than proximity or similarity. Use for wizard steps,
|
|
993
|
+
comparison sets, and explicit navigation flows.
|
|
994
|
+
- **Selective Attention** (Broadbent, *Perception and Communication*,
|
|
995
|
+
1958). Cognitive bandwidth is finite. Users filter aggressively and
|
|
996
|
+
ignore anything that looks irrelevant to their goal — banner blindness
|
|
997
|
+
comes from this. Reserve the strongest visual contrast for the single
|
|
998
|
+
goal-relevant action; let supporting content recede in weight.
|
|
999
|
+
- **Von Restorff Effect** (von Restorff, 1933). The item that differs
|
|
1000
|
+
from a uniform field is the one most likely to be remembered. Make
|
|
1001
|
+
the recommended pricing tier, the active nav item, the warning state
|
|
1002
|
+
visually distinct. Pair contrast with a non-color signal (icon, text
|
|
1003
|
+
label, position) — `accessibility-baseline.md` rules out color-alone
|
|
1004
|
+
signaling.
|
|
1005
|
+
- **Aesthetic-Usability Effect** (Kurosu & Kashimura, Hitachi Design
|
|
1006
|
+
Center, 1995). Visual polish biases perceived usability. Refined
|
|
1007
|
+
typography, generous whitespace, and a calm palette earn the benefit
|
|
1008
|
+
of the doubt for minor friction. Never substitutes for measurable
|
|
1009
|
+
usability or for `state-coverage.md`'s required-states rule.
|
|
1010
|
+
|
|
1011
|
+
#### Decision-making
|
|
1012
|
+
|
|
1013
|
+
Six laws govern how fast and how well users decide when an interface
|
|
1014
|
+
offers a choice.
|
|
1015
|
+
|
|
1016
|
+
- **Hick's Law** (Hick, 1952; Hyman, 1953 replication). Decision time
|
|
1017
|
+
grows roughly log(n+1) with the number of equivalent options. Cap any
|
|
1018
|
+
single decision-screen to 3–5 visible primary options; collapse the
|
|
1019
|
+
rest behind a "More" / progressive disclosure pattern; visually
|
|
1020
|
+
distinguish the recommended choice. Aggressive truncation that hides
|
|
1021
|
+
the path forward is the opposite failure mode — surface the full
|
|
1022
|
+
option set, just don't render every option at the same visual weight.
|
|
1023
|
+
- **Choice Overload** (Iyengar & Lepper, *Journal of Personality and
|
|
1024
|
+
Social Psychology*, 2000; framing dates to Toffler, *Future Shock*,
|
|
1025
|
+
1970). Too many roughly-equivalent options stall or abandon the
|
|
1026
|
+
decision. Pricing pages: 3–4 tiers, exactly one marked recommended.
|
|
1027
|
+
Product grids: 6–9 hero cards above the fold. Settings panels: ≤5
|
|
1028
|
+
named groups. Never emit a flat wall of equivalents.
|
|
1029
|
+
- **Anchoring** (Tversky & Kahneman, *Science* 185:1124–1131, 1974).
|
|
1030
|
+
The first number a user sees re-weights every subsequent number.
|
|
1031
|
+
Place the recommended pricing tier where it anchors the comparison;
|
|
1032
|
+
render yearly-billing savings as concrete dollar deltas, not just
|
|
1033
|
+
percentage badges; pre-select the safer default in radio groups.
|
|
1034
|
+
Visual weight matches intended decision weight.
|
|
1035
|
+
- **Pareto Principle / 80-20** (Pareto, c.1906; Juran, *Quality Control
|
|
1036
|
+
Handbook*, 1951 — popularized the management-application framing). A
|
|
1037
|
+
small share of features drives most of the value. Identify the 2–3 actions
|
|
1038
|
+
that drive the dominant journey for the target persona; emphasize
|
|
1039
|
+
those visually; demote the long tail to overflow menus, footer
|
|
1040
|
+
surfaces, or settings.
|
|
1041
|
+
- **Tesler's Law / Conservation of Complexity** (Tesler, Apple, 1980s).
|
|
1042
|
+
Every product has an irreducible amount of complexity. The design
|
|
1043
|
+
choice is *where* it lives — engineering team, interface, user — not
|
|
1044
|
+
whether to eliminate it. When complexity reaches the user, surface
|
|
1045
|
+
contextual guidance (tooltips, smart defaults, inline empty-state
|
|
1046
|
+
coaching, progressive disclosure) at the exact step where it
|
|
1047
|
+
surfaces. Hiding it is not the same as removing it.
|
|
1048
|
+
- **Occam's Razor** (Ockham, 14th c.). Among options that explain the
|
|
1049
|
+
data equally well, prefer the one with the fewest assumptions. Specify
|
|
1050
|
+
a minimal element inventory; forbid decorative chrome that doesn't
|
|
1051
|
+
serve a stated user task. The law constrains assumptions, not feature
|
|
1052
|
+
count — a "minimum viable" framing misreads it.
|
|
1053
|
+
|
|
1054
|
+
#### Memory and learning
|
|
1055
|
+
|
|
1056
|
+
Five laws cover how working memory handles information density and
|
|
1057
|
+
what the user retains afterward.
|
|
1058
|
+
|
|
1059
|
+
- **Miller's Law and Chunking** (Miller, *The Magical Number Seven,
|
|
1060
|
+
Plus or Minus Two*, *Psychological Review*, 1956 — channel capacity /
|
|
1061
|
+
`7±2` and chunking; Cowan, *Behavioral and Brain Sciences* 24:1, 2001
|
|
1062
|
+
for the modern ~4-item working-memory bound). Working memory holds
|
|
1063
|
+
about four items reliably and up to seven for short-term recall. Each
|
|
1064
|
+
slot can hold a *larger familiar unit*, constrained by the user's
|
|
1065
|
+
domain knowledge — chunking does not let you pack arbitrary content
|
|
1066
|
+
into a single slot. Often misread as a rule about menu length;
|
|
1067
|
+
Miller's paper is about chunks. Group related fields with clear
|
|
1068
|
+
section headings, dividers, or card containers. A settings page with
|
|
1069
|
+
sections "Account / Notifications / Privacy / Billing / Danger zone"
|
|
1070
|
+
beats one flat list of 30 toggles.
|
|
1071
|
+
- **Working Memory** (Baddeley & Hitch, 1974; lineage to Atkinson &
|
|
1072
|
+
Shiffrin, 1968). Items decay in seconds without rehearsal. Recognition
|
|
1073
|
+
beats recall: persisting prior context across screens, marking visited
|
|
1074
|
+
elements, and surfacing comparison views beats forcing the user to
|
|
1075
|
+
memorize. On dashboards specifically: sticky filter chips, last-N
|
|
1076
|
+
selections persisted, breadcrumbs that include applied filters.
|
|
1077
|
+
- **Serial Position Effect** (Ebbinghaus, *Über das Gedächtnis*, 1885).
|
|
1078
|
+
Recall favors the extremes — primacy at the start, recency at the
|
|
1079
|
+
end — while middle items fade. Anchor the most important nav items at
|
|
1080
|
+
the leftmost and rightmost positions of a horizontal menu; cluster
|
|
1081
|
+
utilities in the middle.
|
|
1082
|
+
- **Peak-End Rule** (Kahneman, Fredrickson, Schreiber, Redelmeier,
|
|
1083
|
+
*Psychological Science*, 1993). Memory of an experience is dominated
|
|
1084
|
+
by the emotional peak and the ending, not the average. Stage a
|
|
1085
|
+
high-effort celebratory success state; let intermediate steps stay
|
|
1086
|
+
calm. Mediocre middles matter less than a strong close. The peak
|
|
1087
|
+
belongs at the *end* of a flow, not as arbitrary mid-flow motion —
|
|
1088
|
+
`animation-discipline.md` rejects motion that performs (rather than
|
|
1089
|
+
confirms) a state change.
|
|
1090
|
+
- **Zeigarnik Effect** (Zeigarnik, *Über das Behalten erledigter und
|
|
1091
|
+
unerledigter Handlungen*, 1927). Uncompleted tasks create cognitive
|
|
1092
|
+
tension that pulls the user back. Visible progress ("3 of 5 steps",
|
|
1093
|
+
greyed-out next sections) converts that tension into completion
|
|
1094
|
+
pressure. Reserve for genuinely beneficial flows like onboarding;
|
|
1095
|
+
applying the same lever to streaks, daily-quest counters, or notification-
|
|
1096
|
+
reduction nags is a dark pattern.
|
|
1097
|
+
|
|
1098
|
+
#### Interaction and motor
|
|
1099
|
+
|
|
1100
|
+
Five laws cover how fast and how accurately users can act on the UI.
|
|
1101
|
+
|
|
1102
|
+
- **Fitts's Law** (Fitts, *Journal of Experimental Psychology*, 1954).
|
|
1103
|
+
Time to acquire a target depends on its distance and size — bigger
|
|
1104
|
+
and closer is faster. Spacing between adjacent hit zones matters as
|
|
1105
|
+
much as size. Pair with `accessibility-baseline.md`'s 24 × 24 CSS px
|
|
1106
|
+
AA touch-target floor; on mobile, place high-frequency controls in
|
|
1107
|
+
the natural thumb arc.
|
|
1108
|
+
- **Doherty Threshold** (Doherty & Thadani, *IBM Systems Journal*,
|
|
1109
|
+
1982). Sub-second feedback keeps users in flow; latency above ~1 s
|
|
1110
|
+
breaks attention. The implementable directive lives in
|
|
1111
|
+
`state-coverage.md`'s loading-threshold table (no indicator under
|
|
1112
|
+
300 ms; skeleton 300 ms – 2 s; labelled spinner 2 – 10 s; determinate
|
|
1113
|
+
bar with cancel 10 – 60 s; stop and offer error/retry past 60 s).
|
|
1114
|
+
This entry exists to name the underlying law and flag its folklore
|
|
1115
|
+
(the 400 ms number doesn't appear in the 1982 paper — see
|
|
1116
|
+
`animation-discipline.md` for the 400 ms folklore trace).
|
|
1117
|
+
- **Flow** (Csíkszentmihályi, *Beyond Boredom and Anxiety*, 1975). Flow
|
|
1118
|
+
sits in the balance between challenge and skill — too hard breeds
|
|
1119
|
+
frustration, too easy breeds boredom. Continuous feedback and a clear
|
|
1120
|
+
sense of control keep the user inside the state. System friction and
|
|
1121
|
+
latency are the fastest ways to break it.
|
|
1122
|
+
- **Goal-Gradient Effect** (Hull, *Psychological Review*, 1932; Kivetz,
|
|
1123
|
+
Urminsky, Zheng, 2006 for the punch-card replication). Motivation to
|
|
1124
|
+
finish rises as the goal gets closer. Multi-step flows render with a
|
|
1125
|
+
prominent progress indicator that reflects *real* endowed progress —
|
|
1126
|
+
show completed prerequisites when they truly exist (saved profile,
|
|
1127
|
+
imported team, prior survey answer). When no real prerequisite
|
|
1128
|
+
exists, render the current step honestly as `1 of N` with the
|
|
1129
|
+
empty/current-step state clearly marked. Hull's hypothesis is
|
|
1130
|
+
descriptive; treating it as license for fabricated progress, streak
|
|
1131
|
+
dark patterns, or loyalty-program quota inflation is a misread.
|
|
1132
|
+
- **Postel's Law / Robustness Principle** (Postel, RFC 760, 1980). "Be
|
|
1133
|
+
liberal in what you accept, conservative in what you send." Take
|
|
1134
|
+
input in whatever shape users naturally give it (phone numbers with
|
|
1135
|
+
or without dashes, dates in mixed formats, percentages with or
|
|
1136
|
+
without `%`); normalize internally to a canonical form; emit one
|
|
1137
|
+
consistent format on output. The error-timing and ARIA-wiring half
|
|
1138
|
+
lives in `form-validation.md`; the input-tolerance half is the
|
|
1139
|
+
directive above. RFC 9413 (Thomson, IAB, 2023; built on the earlier
|
|
1140
|
+
`draft-iab-protocol-maintenance`) retracts the maxim for protocol
|
|
1141
|
+
design citing security surface; the UX-input application stands.
|
|
1142
|
+
|
|
1143
|
+
#### Behavior and expectation
|
|
1144
|
+
|
|
1145
|
+
Five laws cover what users predict and how that prediction interacts
|
|
1146
|
+
with the rendered surface.
|
|
1147
|
+
|
|
1148
|
+
- **Jakob's Law** (Nielsen, Nielsen Norman Group, 2000). Users spend
|
|
1149
|
+
most of their time on other sites and expect yours to work the same.
|
|
1150
|
+
Reuse category convention — nav placement, cart icon, settings gear,
|
|
1151
|
+
primary CTA in the upper right of a SaaS landing — so the user spends
|
|
1152
|
+
zero cycles relearning interaction grammar. Novelty must earn its
|
|
1153
|
+
keep against the convention's ROI; "innovate everywhere" is the
|
|
1154
|
+
opposite failure mode.
|
|
1155
|
+
- **Mental Model** (Craik, *The Nature of Explanation*, 1943; Norman,
|
|
1156
|
+
*POET / The Psychology of Everyday Things*, 1988). Every user
|
|
1157
|
+
arrives with a prior built from competitor products and the physical
|
|
1158
|
+
world. When the prediction holds, the product feels intuitive; when
|
|
1159
|
+
it breaks, friction shows up as confusion, not curiosity. When the
|
|
1160
|
+
brief names a reference product, anchor explicitly — capture the
|
|
1161
|
+
reference in the prompt and the agent inherits a transferable
|
|
1162
|
+
interaction grammar.
|
|
1163
|
+
- **Paradox of the Active User** (Carroll & Rosson, in *Interfacing
|
|
1164
|
+
Thought: Cognitive Aspects of Human-Computer Interaction*, MIT Press,
|
|
1165
|
+
1987, pp. 80–111). Users skip the manual and start using the
|
|
1166
|
+
software immediately, even when reading it would speed them up. Bake
|
|
1167
|
+
guidance into the surface itself — empty-state coaching, inline
|
|
1168
|
+
tooltips, contextual hints — at the action point.
|
|
1169
|
+
- **Parkinson's Law** (Parkinson, *The Economist*, 1955). Work expands
|
|
1170
|
+
to fill the time allotted to it. Loose interfaces let users dawdle;
|
|
1171
|
+
cut friction and pre-fill what you can — autofill, smart defaults,
|
|
1172
|
+
saved state — so a checkout finishes faster than the user expected.
|
|
1173
|
+
Beating anticipated duration becomes the felt win.
|
|
1174
|
+
- **Cognitive Load** (Sweller, *Cognitive Science*, 1988). Total
|
|
1175
|
+
mental effort splits into intrinsic (the task's inherent difficulty)
|
|
1176
|
+
and extraneous (poor layout, jargon, inconsistent patterns, visual
|
|
1177
|
+
noise). Designers can't reduce intrinsic load; they own extraneous
|
|
1178
|
+
fully. The visual-restraint directives (single accent in `color.md`,
|
|
1179
|
+
three-weight typography rhythm in `typography.md`, P0 anti-default
|
|
1180
|
+
list in `anti-ai-slop.md`) already constrain extraneous load; this
|
|
1181
|
+
entry exists to name the cognitive cost the sibling rules reduce.
|
|
1182
|
+
|
|
1183
|
+
#### Common mistakes (lint these)
|
|
1184
|
+
|
|
1185
|
+
Folklore corrections that don't survive a primary-source check, in the
|
|
1186
|
+
same vein as the busts already documented in `animation-discipline.md`
|
|
1187
|
+
and `accessibility-baseline.md`. The first three are attribution
|
|
1188
|
+
corrections (year / venue / institution) the body entries already
|
|
1189
|
+
applied — restated here so a reviewer reading just this section sees
|
|
1190
|
+
them. The remainder are folklore not addressed in the body.
|
|
1191
|
+
|
|
1192
|
+
- "Anchoring effect = Tversky & Kahneman 1972." Wrong year. The
|
|
1193
|
+
*Science* paper introducing the anchoring framing is 1974; the 1972
|
|
1194
|
+
paper is "Subjective probability: A judgment of representativeness"
|
|
1195
|
+
(different work).
|
|
1196
|
+
- "Tesler's Law was developed at Xerox PARC." Tesler left PARC for
|
|
1197
|
+
Apple in 1980; the Conservation-of-Complexity formulation traces to
|
|
1198
|
+
his Apple years.
|
|
1199
|
+
- "Paradox of the Active User was a CACM article." It's a chapter in
|
|
1200
|
+
Carroll's *Interfacing Thought* (MIT Press, 1987), not CACM.
|
|
1201
|
+
- "Selective Attention = solved by red dots and badges." Repeated
|
|
1202
|
+
attention-grabbers train banner blindness. Reserve the strongest
|
|
1203
|
+
contrast for one goal-relevant action per surface.
|
|
1204
|
+
- "Fitts's Law alone is enough for touch targets." Fitts gives the
|
|
1205
|
+
speed-accuracy tradeoff. WCAG 2.2 SC 2.5.8 sets the AA floor at
|
|
1206
|
+
24 × 24 CSS px (`accessibility-baseline.md`); iOS HIG suggests
|
|
1207
|
+
44 × 44 pt; Material 3 suggests 48 × 48 dp. Fitts plus the
|
|
1208
|
+
platform floor — never just Fitts.
|
|
1209
|
+
|
|
1210
|
+
|
|
1211
|
+
## form-validation
|
|
1212
|
+
|
|
1213
|
+
来源:https://github.com/nexu-io/open-design/blob/07170f8d2213936b7862db04139d27e0af5437ed/craft/form-validation.md
|
|
1214
|
+
|
|
1215
|
+
### Form validation craft rules
|
|
1216
|
+
|
|
1217
|
+
Universal rules for form validation lifecycle, error wiring beyond the
|
|
1218
|
+
accessibility baseline, and the schema-as-contract layer that makes
|
|
1219
|
+
the same validation work on the server and the client. The active
|
|
1220
|
+
`DESIGN.md` decides how the field looks; this file decides *when* the
|
|
1221
|
+
field tells the user it's wrong, *how* the error reaches assistive
|
|
1222
|
+
tech, and *where* the rule lives.
|
|
1223
|
+
|
|
1224
|
+
> Grounded in primary sources: WHATWG HTML Living Standard
|
|
1225
|
+
> (Constraint Validation section under "Form control infrastructure"),
|
|
1226
|
+
> CSS Selectors L4 (`:user-invalid`), WCAG 2.2 SC 3.3.x
|
|
1227
|
+
> Understanding pages, ARIA APG forms patterns, Standard Schema spec
|
|
1228
|
+
> (`@standard-schema/spec`), Baymard 2024 inline-validation research
|
|
1229
|
+
> checkout-UX benchmark, WebAIM Million 2026 forms findings.
|
|
1230
|
+
|
|
1231
|
+
#### Prior art and scope
|
|
1232
|
+
|
|
1233
|
+
Existing OSS forms guidance for AI agents pins to one layer at a time
|
|
1234
|
+
— `szilu/ux-designer-skill` is UX-opinion grade with no spec anchors,
|
|
1235
|
+
`Community-Access/accessibility-agents/forms-specialist` is
|
|
1236
|
+
WCAG-anchored but AT-only and doesn't reach the platform validity
|
|
1237
|
+
layer or the schema contract. This file connects the four layers a
|
|
1238
|
+
real form spans: **WHATWG Constraint Validation as the platform
|
|
1239
|
+
floor, validation timing as a state machine on the input, WCAG 3.3.x
|
|
1240
|
+
as the announcement and recovery contract, schema as the cross-stack
|
|
1241
|
+
truth.** A11y wiring lives next door in `accessibility-baseline.md`
|
|
1242
|
+
(label + describedby + invalid + `role="alert"` for inline errors);
|
|
1243
|
+
this file picks up where that ends.
|
|
1244
|
+
|
|
1245
|
+
#### The input state machine
|
|
1246
|
+
|
|
1247
|
+
Every input passes through these states. The names trace back to RHF /
|
|
1248
|
+
Formik vocabulary on web; the *shape* applies regardless of stack.
|
|
1249
|
+
Drive error chrome off the state, not off raw `:invalid` or
|
|
1250
|
+
focus/blur booleans.
|
|
1251
|
+
|
|
1252
|
+
| State | Meaning | UI |
|
|
1253
|
+
|---|---|---|
|
|
1254
|
+
| `pristine` | User has not interacted | No error chrome, no green check |
|
|
1255
|
+
| `dirty` | User has typed but not committed (still focused) | No error chrome yet |
|
|
1256
|
+
| `touched` | User has blurred at least once after editing | Field-level constraint runs |
|
|
1257
|
+
| `invalid-after-touched` | Constraint failed after blur | Show error, link via `aria-describedby` |
|
|
1258
|
+
| `invalid-after-submit` | Submit attempted, field still invalid | Same plus focus management to summary or first invalid field |
|
|
1259
|
+
| `recovering` | User editing an already-invalid field | Re-validate on `input`, not on next blur |
|
|
1260
|
+
| `submitting` | Action in flight | Disable submit, announce status via a polite live region |
|
|
1261
|
+
| `server-error` | Server returned an error for this field | Use server's message text; treat as `invalid-after-submit` |
|
|
1262
|
+
|
|
1263
|
+
Decision rule that collapses validation-timing debates: errors appear
|
|
1264
|
+
on transition into `invalid-after-touched`, clear on transition out
|
|
1265
|
+
of any invalid state, and never appear from `pristine` or plain
|
|
1266
|
+
`dirty`. CSS `:user-invalid` matches the `invalid-after-touched` /
|
|
1267
|
+
`invalid-after-submit` states for free.
|
|
1268
|
+
|
|
1269
|
+
#### Validation timing
|
|
1270
|
+
|
|
1271
|
+
Baymard's checkout-UX benchmark (2024-01-09 inline-validation article):
|
|
1272
|
+
**31% of sites have no inline validation, and most of the rest fire
|
|
1273
|
+
too early.** The participant quote that anchors the research: *"Why
|
|
1274
|
+
are you telling me my email address is wrong, I haven't had a chance
|
|
1275
|
+
to fill it all out yet?"* Premature firing is the loudest UX failure
|
|
1276
|
+
in this space.
|
|
1277
|
+
|
|
1278
|
+
The four rules:
|
|
1279
|
+
|
|
1280
|
+
1. **First blur after edit** runs the field-level constraint. Not on focus, not on first keystroke, not on every keystroke.
|
|
1281
|
+
2. **Once a field is invalid, switch to `input`-event re-validation** so the error clears the moment input becomes valid. Don't make the user blur again to dismiss it.
|
|
1282
|
+
3. **On submit**, run the schema parse. Move focus to the error summary at the top of the form (a heading-led container with `tabindex="-1"`, no `role="alert"` — see the wiring section), or to the first invalid field if no summary exists. Don't move focus on every keystroke.
|
|
1283
|
+
4. **Async checks** split into two paths. *Background preflight* (uniqueness while typing, address lookup) debounces 250-500 ms, announces via a polite live region, and never gates typing or keeps the submit button disabled indefinitely. *Authoritative server validation on submit* is different: the submit path must await the server's response and surface field errors from it, since the server is the truth. Don't conflate the two — the rule is "don't let a slow background check freeze the form," not "don't ever wait for the server."
|
|
1284
|
+
|
|
1285
|
+
CSS gets you most of timing rule 1 for free: style off `:user-invalid`
|
|
1286
|
+
not `:invalid`. The `:user-invalid` selector is Baseline Newly
|
|
1287
|
+
available 2023 (Chrome 119, Firefox 88, Safari 16.5; Firefox shipped
|
|
1288
|
+
the prefixed `:-moz-ui-invalid` years earlier and unprefixed in v88)
|
|
1289
|
+
and matches only after the user has either submitted the form or
|
|
1290
|
+
blurred the field with bad input.
|
|
1291
|
+
|
|
1292
|
+
#### Constraint Validation API as the platform floor
|
|
1293
|
+
|
|
1294
|
+
Native HTML constraints are not an alternative to JS validation; they
|
|
1295
|
+
are the substrate the rest of the layers run on. They survive JS
|
|
1296
|
+
failure, they integrate with autofill, and they are what
|
|
1297
|
+
`reportValidity()` and screen-reader native announcements key off.
|
|
1298
|
+
|
|
1299
|
+
```html
|
|
1300
|
+
<input type="email" name="email" required>
|
|
1301
|
+
```
|
|
1302
|
+
|
|
1303
|
+
Use these declaratively for every field that has them: `required`,
|
|
1304
|
+
`type` (email, url, number, tel), `pattern`, `min`/`max`,
|
|
1305
|
+
`minlength`/`maxlength`, `step`. Cross-field rules and dynamic
|
|
1306
|
+
constraints go through `setCustomValidity()` on both `input` and
|
|
1307
|
+
`change` events — autofill flows historically fired one without the
|
|
1308
|
+
other on some browsers, so listening on both is the cheap defense.
|
|
1309
|
+
|
|
1310
|
+
Rules of the API:
|
|
1311
|
+
|
|
1312
|
+
- **Empty string clears `setCustomValidity`.** Not `null`, not no-arg.
|
|
1313
|
+
- **`form.requestSubmit()` honors validation; `form.submit()` skips it.** Never call the second.
|
|
1314
|
+
- `disabled` controls are barred from validation and not submitted. The HTML spec says `readonly` is also barred, but `readonly` only has defined behavior on `<input>` and `<textarea>` — implementations diverge for `<select readonly>` and `<button readonly>` ([whatwg/html#11841](https://github.com/whatwg/html/issues/11841)). For non-input controls where the value must still submit, the safe pattern is `disabled` plus a same-named hidden `<input>` carrying the value, or rendering the non-editable text alongside a hidden `<input>`. `aria-readonly` alone is not enough — a `<select>` or custom widget tagged `aria-readonly="true"` is still interactable, so the visible control can drift while the hidden input ships a stale or different value. If you do use `aria-readonly`, you must also block the interaction or keep both values in sync.
|
|
1315
|
+
- `inputmode` is a virtual-keyboard hint, **not** validation. `<input type="text" inputmode="numeric" pattern="[0-9]*">` is the Baymard-recommended shape for ZIPs / OTPs / card numbers; `pattern="[0-9]*"` is the historical iOS-Safari trigger for the numeric keypad on top of `inputmode`. `type="number"` adds spinners, strips leading zeros, applies locale-decimal handling, and varies field width across browsers — wrong for any of these.
|
|
1316
|
+
|
|
1317
|
+
#### Error wiring beyond the baseline
|
|
1318
|
+
|
|
1319
|
+
The default error pattern in `accessibility-baseline.md` (`<label>` +
|
|
1320
|
+
`aria-describedby` + `aria-invalid` + `role="alert"`) covers WCAG
|
|
1321
|
+
3.3.1 / 3.3.2. Three additions matter for real forms:
|
|
1322
|
+
|
|
1323
|
+
**Adaptive error messages.** Baymard 2023: 98% of audited sites use
|
|
1324
|
+
generic catch-all errors ("Provide a valid phone number") rather than
|
|
1325
|
+
the specific subrule that fired ("Phone number is too short"). The
|
|
1326
|
+
back end already knows the subrule; surfacing it cuts re-submit
|
|
1327
|
+
attempts. Ship 4-7 distinct messages per high-traffic complex field
|
|
1328
|
+
(email, phone, card, postal code). The scale of the problem matches
|
|
1329
|
+
WebAIM Million 2026: missing form-input labels appear on **51% of
|
|
1330
|
+
the top 1M home pages** (input-level rate **33.1%** of all 6.9M
|
|
1331
|
+
inputs sampled) — labels and error messages are the categories
|
|
1332
|
+
trending sideways or worse year-over-year while overall a11y errors
|
|
1333
|
+
drop.
|
|
1334
|
+
|
|
1335
|
+
**Error summary at the top, on submit only.** Long forms benefit from
|
|
1336
|
+
a summary list of in-page anchor links to invalid fields, focused on
|
|
1337
|
+
submit:
|
|
1338
|
+
|
|
1339
|
+
```html
|
|
1340
|
+
<div id="form-errors" tabindex="-1">
|
|
1341
|
+
<h2>2 problems</h2>
|
|
1342
|
+
<ul>
|
|
1343
|
+
<li><a href="#email">Email is required</a></li>
|
|
1344
|
+
<li><a href="#dob">Date of birth must be in the past</a></li>
|
|
1345
|
+
</ul>
|
|
1346
|
+
</div>
|
|
1347
|
+
```
|
|
1348
|
+
|
|
1349
|
+
The container is heading-led with `tabindex="-1"` so JS can move
|
|
1350
|
+
focus to it on submit (render the summary into the DOM, *then*
|
|
1351
|
+
`.focus()` it; a `hidden` element can't take focus). It does **not**
|
|
1352
|
+
carry `role="alert"` because combining a moved-focus target with an
|
|
1353
|
+
alert role causes double-announcement: alert fires on insertion,
|
|
1354
|
+
focus fires the accessible name + role. Reserve `role="alert"` for
|
|
1355
|
+
inline per-field errors that appear without focus moving — that's
|
|
1356
|
+
the canonical baseline pattern in `accessibility-baseline.md`. WCAG
|
|
1357
|
+
technique G139 covers the summary; not required, high-value for long
|
|
1358
|
+
forms.
|
|
1359
|
+
|
|
1360
|
+
**Preserve user input on error.** Baymard 2024: 34% of audited
|
|
1361
|
+
checkouts wipe the credit-card field when an unrelated error reloads
|
|
1362
|
+
the page. Direct cause of abandonment. Either field-level-validate
|
|
1363
|
+
non-sensitive fields first, or split the payment step. PCI-wise,
|
|
1364
|
+
persisting card values across an error reload is fine via tokenized
|
|
1365
|
+
hosted iframes; never store raw PAN in your own session.
|
|
1366
|
+
|
|
1367
|
+
#### Schema as the cross-stack contract
|
|
1368
|
+
|
|
1369
|
+
Validation expressed once, consumed everywhere. The 2026 React shape
|
|
1370
|
+
— `useActionState` + Server Actions + Conform (which added Standard
|
|
1371
|
+
Schema support during the v1.x line) + a Zod 4 / Valibot / ArkType
|
|
1372
|
+
schema — is the most-cited concrete instance: one schema,
|
|
1373
|
+
server-authoritative, validator hot-swappable via the `~standard`
|
|
1374
|
+
interface. The same architecture works in TanStack Form, oRPC, Hono
|
|
1375
|
+
validator middleware, Nuxt UForm, and any other consumer that reads
|
|
1376
|
+
`~standard`.
|
|
1377
|
+
|
|
1378
|
+
```ts
|
|
1379
|
+
const Signup = z.object({
|
|
1380
|
+
email: z.email(), // Zod 4 top-level form
|
|
1381
|
+
password: z.string().min(12),
|
|
1382
|
+
});
|
|
1383
|
+
// Same schema parses on the Server Action and on the Conform client.
|
|
1384
|
+
```
|
|
1385
|
+
|
|
1386
|
+
Three rules that survive across stacks:
|
|
1387
|
+
|
|
1388
|
+
- **Server is the truth, client is the optimization.** Same schema runs in both. Returning `{ errors }` from the action (not throwing) is what feeds back into `useActionState`'s state slot — throwing routes to the Error Boundary and loses the form data.
|
|
1389
|
+
- **Standard Schema is the contract, not Zod.** A form library that ships per-validator resolver shims (`zodResolver`, `valibotResolver`, etc.) is yesterday's stack. Accept any `~standard`-compliant validator.
|
|
1390
|
+
- **`novalidate` on `<form>` does not mean "skip validation".** It means "let the form library repaint errors instead of the browser's bubble." But the trade-off is real: a literal server-rendered `<form novalidate>` disables the browser's submit-blocking and native validation UI **even when JS is unavailable**, which loses the no-JS constraint-validation floor. Pick one of two patterns. **A:** render `<form>` without `novalidate` server-side and have the form library set `form.noValidate = true` after hydration — the no-JS user keeps the browser's native validation, the JS user gets the library's chrome. **B:** ship `novalidate` from the start only when the submit path reaches server validation without JS (Server Action, classic POST handler) so the no-JS user is still protected by the server. Either way, keep `required` / `pattern` / `type` attributes — they survive JS failure and integrate with autofill. (HTML attribute is lowercase `novalidate`; the IDL property on the form element is `noValidate`.)
|
|
1391
|
+
|
|
1392
|
+
#### WCAG 3.3.x beyond Error Identification
|
|
1393
|
+
|
|
1394
|
+
`accessibility-baseline.md` covers 3.3.1 (Error ID), 3.3.2 (Labels),
|
|
1395
|
+
and 3.3.7 (Redundant Entry). The rest of 3.3 binds harder on
|
|
1396
|
+
transactional forms:
|
|
1397
|
+
|
|
1398
|
+
- **3.3.3 Error Suggestion (AA):** when the fix is determinable, suggest it in text. Adaptive errors satisfy this. "Date must be MM/DD/YYYY. You entered 5-3-26. Did you mean 05/03/2026?"
|
|
1399
|
+
- **3.3.4 Error Prevention — Legal, Financial, Data (AA):** for any submission with legal / financial / data-modifying consequence, provide one of: reversibility, server-side check + correction step, or a confirm-summary screen before commit.
|
|
1400
|
+
- **3.3.8 Accessible Authentication (AA, WCAG 2.2):** auth steps must not require a cognitive function test (remember a password, transcribe a code, recognize images) without an alternative. CAPTCHAs are the canonical thing this SC restricts; only object-recognition or personal-content variants escape via the narrow exceptions, and not all CAPTCHAs do. Practical floor: never block paste on password / verification-code fields, support password managers, accept verification-code paste from a clipboard.
|
|
1401
|
+
- **3.3.9 Accessible Authentication, No Exception (AAA):** removes even the object-recognition / personal-content exceptions. Aspirational; flag if a project commits to it.
|
|
1402
|
+
|
|
1403
|
+
#### Native mobile parity
|
|
1404
|
+
|
|
1405
|
+
Web validation primitives don't auto-translate. Each platform has its
|
|
1406
|
+
own validity machinery and its own AT path. Skills that emit web-only
|
|
1407
|
+
artifacts can skim this section; it's the entry point for skills
|
|
1408
|
+
that ship to mobile (mobile-onboarding, mobile-app, etc.).
|
|
1409
|
+
|
|
1410
|
+
| Platform | Validity primitive | Error announcement |
|
|
1411
|
+
|---|---|---|
|
|
1412
|
+
| iOS UIKit | Hand-rolled state on the view controller; `UITextField` doesn't carry a built-in invalid flag | `UIAccessibility.post(notification: .announcement, argument: "Email is required")` |
|
|
1413
|
+
| iOS SwiftUI | `TextField` + `@State`-driven validation; no built-in `Form`-level validity API as of iOS 18 | `AccessibilityNotification.Announcement("…").post()` (iOS 17+) |
|
|
1414
|
+
| Android Compose | `OutlinedTextField(isError = true, supportingText = { Text("…") })` — `isError` wires the AT error semantic for you | `Modifier.semantics { liveRegion = LiveRegionMode.Polite }` on the supporting-text node, or `LocalView.current.announceForAccessibility(message)` |
|
|
1415
|
+
| Flutter | `TextFormField(validator: (v) => …)` inside a `Form`, `formKey.currentState!.validate()` | `SemanticsService.announce(message, Directionality.of(context))` — never hardcode `TextDirection.ltr`; pull ambient direction so Arabic / Hebrew / Persian flows announce correctly |
|
|
1416
|
+
| React Native | Hand-rolled per field; no platform validity flag | `accessibilityLiveRegion="polite"` on the error node (Android) + `AccessibilityInfo.announceForAccessibility(...)` (iOS) |
|
|
1417
|
+
|
|
1418
|
+
Two parity rules that catch most AI-generated mobile forms:
|
|
1419
|
+
|
|
1420
|
+
- **Use the platform's native validation flag — and pair it with the platform's error-message semantic where one exists.** On Compose, `isError = true` is the right boolean state for the field visuals and AT error-state cue, but it does *not* carry the localized error message. Pair it with `Modifier.semantics { error(message) }` so accessibility services get the actual text — the same string you render in `supportingText`. The trap is duplication: a hand-rolled `Modifier.semantics { error("Email is required") }` next to a different supporting-text string desyncs. Source `error()` from the same state field as `supportingText` so they stay in sync.
|
|
1421
|
+
- **Don't mirror web ARIA into mobile semantics.** `aria-describedby` on a SwiftUI `TextField` is a no-op. Use the platform announcement primitive (`AccessibilityNotification.Announcement` on SwiftUI, `UIAccessibility.post` on UIKit, `announceForAccessibility` on Android, `SemanticsService.announce` on Flutter) for state-change events that need to reach the screen reader.
|
|
1422
|
+
|
|
1423
|
+
#### Common mistakes (lint these)
|
|
1424
|
+
|
|
1425
|
+
- Styling off `input:invalid` instead of `input:user-invalid`. Red borders on page load is the loudest "this validation was added without testing" signal.
|
|
1426
|
+
- Validating on every keystroke. Hostile; fires before the user has finished typing.
|
|
1427
|
+
- Generic catch-all error messages ("Invalid input") when the back end already knows which subrule fired. Baymard 2023 found 98% of audited sites do this — the most-cited preventable validation failure in their corpus.
|
|
1428
|
+
- Throwing from a Server Action on validation failure. Routes to the Error Boundary and loses the form data. Return `{ errors }` instead.
|
|
1429
|
+
- `role="alert"` on the error-summary container that focus moves to. Double-announces. Reserve `role="alert"` for inline per-field errors that appear without focus moving.
|
|
1430
|
+
- `aria-busy="true"` on the submit button while submitting. `aria-busy` is for stale containers; for buttons use `disabled` plus a polite live-region status message.
|
|
1431
|
+
- Email-confirm fields ("retype your email"). 3.3.7 redundant entry — exceptions are essential / security / no-longer-valid, not "we want to catch typos." Allow paste and validate the single field instead.
|
|
1432
|
+
- Per-validator resolver shims (`zodResolver`, `valibotResolver`) on a 2026 stack. Accept Standard Schema's `~standard` interface and the validator becomes swappable.
|
|
1433
|
+
- Wiping the credit-card field when an unrelated field errors. Baymard 2024: 34% of audited e-commerce sites; direct abandonment cause.
|
|
1434
|
+
- `setCustomValidity(null)` to clear an error. Pass empty string; `null` does not clear.
|
|
1435
|
+
- Mirroring web ARIA onto SwiftUI / Compose / Flutter. Each platform has its own validity API; `aria-*` attributes don't reach the mobile AT path.
|
|
1436
|
+
|
|
1437
|
+
|
|
1438
|
+
## anti-ai-slop
|
|
1439
|
+
|
|
1440
|
+
来源:https://github.com/nexu-io/open-design/blob/07170f8d2213936b7862db04139d27e0af5437ed/craft/anti-ai-slop.md
|
|
1441
|
+
|
|
1442
|
+
### Anti-AI-slop rules
|
|
1443
|
+
|
|
1444
|
+
Concrete, checkable rules that distinguish "designed by a human who has
|
|
1445
|
+
shipped product" from "default LLM output." Several rules below are
|
|
1446
|
+
auto-enforced by the daemon's `lint-artifact` linter — failing an
|
|
1447
|
+
enforced rule is not a style preference, it is a regression. The
|
|
1448
|
+
rest are guidance for agents and reviewers and are flagged inline as
|
|
1449
|
+
"(guidance, not auto-checked)" so the contract with the linter stays
|
|
1450
|
+
honest.
|
|
1451
|
+
|
|
1452
|
+
> Adapted from [refero_skill](https://github.com/referodesign/refero_skill)
|
|
1453
|
+
> (MIT), tightened to match OpenDesign's lint surface.
|
|
1454
|
+
|
|
1455
|
+
#### The seven cardinal sins
|
|
1456
|
+
|
|
1457
|
+
These are the patterns the linter blocks at P0 (must-fix):
|
|
1458
|
+
|
|
1459
|
+
1. **Default Tailwind indigo as accent** — exactly `#6366f1`, `#4f46e5`,
|
|
1460
|
+
`#4338ca`, `#3730a3`, `#8b5cf6`, `#7c3aed`, `#a855f7`. The active
|
|
1461
|
+
`DESIGN.md` provides `--accent`; use it. Indigo is the textbook AI
|
|
1462
|
+
tell. (The daemon's `lint-artifact` flags any of these as a solid
|
|
1463
|
+
accent; keep this list in sync with `AI_DEFAULT_INDIGO` in
|
|
1464
|
+
`apps/daemon/src/lint-artifact.ts`.)
|
|
1465
|
+
2. **Two-stop "trust" gradient on the hero** — purple→blue, blue→cyan,
|
|
1466
|
+
indigo→pink. A flat surface + intentional type beats this every
|
|
1467
|
+
time.
|
|
1468
|
+
3. **Emoji as feature icons** — `✨`, `🚀`, `🎯`, `⚡`, `🔥`, `💡`
|
|
1469
|
+
inside `<h*>`, `<button>`, `<li>`, or `class*="icon"`. Use
|
|
1470
|
+
1.6–1.8px-stroke monoline SVG with `currentColor`.
|
|
1471
|
+
4. **Sans-serif on display text when the seed binds a serif** — h1/h2
|
|
1472
|
+
must use `var(--font-display)`, not a hardcoded Inter / Roboto /
|
|
1473
|
+
`system-ui`.
|
|
1474
|
+
5. **Rounded card with a colored left-border accent** — the canonical
|
|
1475
|
+
"AI dashboard tile" shape. Drop either the radius or the left
|
|
1476
|
+
border.
|
|
1477
|
+
6. **Invented metrics** — "10× faster", "99.9% uptime", "3× more
|
|
1478
|
+
productive". Either pull from a real source or use a labelled
|
|
1479
|
+
placeholder.
|
|
1480
|
+
7. **Filler copy** — `lorem ipsum`, `feature one / two / three`,
|
|
1481
|
+
`placeholder text`, `sample content`. An empty section is a design
|
|
1482
|
+
problem to solve with composition, not by inventing words.
|
|
1483
|
+
|
|
1484
|
+
#### Soft tells (P1 — should fix)
|
|
1485
|
+
|
|
1486
|
+
- **Standard "Hero → Features → Pricing → FAQ → CTA" sequence with no
|
|
1487
|
+
variation** *(guidance, not auto-checked)*. This is the AI-template
|
|
1488
|
+
skeleton; introduce at least one unconventional section (testimonial
|
|
1489
|
+
wall as full-bleed quote, pricing as comparison-against-status-quo,
|
|
1490
|
+
an inline mini-product-demo).
|
|
1491
|
+
- **External placeholder image CDNs** (`unsplash.com`, `placehold.co`,
|
|
1492
|
+
`placekitten.com`, `picsum.photos`). Fragile and obvious. Use the
|
|
1493
|
+
shipped `.ph-img` placeholder class.
|
|
1494
|
+
- **More than ~12 raw hex values outside `:root`.** Tokens were not
|
|
1495
|
+
honoured.
|
|
1496
|
+
- **`var(--accent)` used 6+ times in the rendered body.** Cap at 2
|
|
1497
|
+
visible uses per screen.
|
|
1498
|
+
|
|
1499
|
+
#### Polish tells (P2 — nice to fix)
|
|
1500
|
+
|
|
1501
|
+
- **Sections without `data-od-id`** — comment mode can't target them.
|
|
1502
|
+
- **Decorative blob / wave SVG backgrounds** *(guidance, not
|
|
1503
|
+
auto-checked)* — meaningless geometry.
|
|
1504
|
+
- **Perfect symmetric layout with no visual tension** *(guidance, not
|
|
1505
|
+
auto-checked)* — alternating density (one tight section, one
|
|
1506
|
+
breathing section) reads as intentional.
|
|
1507
|
+
|
|
1508
|
+
#### How to add soul without breaking the rules
|
|
1509
|
+
|
|
1510
|
+
Aim for **~80% proven patterns + ~20% distinctive choice**. The 20%
|
|
1511
|
+
should live in:
|
|
1512
|
+
|
|
1513
|
+
- One bold visual move — a typography choice, a single color decision,
|
|
1514
|
+
an unexpected proportion.
|
|
1515
|
+
- Voice and microcopy — a button that says "Start tracking" beats one
|
|
1516
|
+
that says "Get started".
|
|
1517
|
+
- One micro-interaction the user will remember — a button press that
|
|
1518
|
+
moves 2px, a number that counts up.
|
|
1519
|
+
- One detail that could only have been put there by someone who used
|
|
1520
|
+
the product (a subtle kbd shortcut hint, a status badge with
|
|
1521
|
+
product-specific phrasing).
|
|
1522
|
+
|
|
1523
|
+
If a reviewer screenshots the artifact and someone outside the project
|
|
1524
|
+
can identify which product it's from — you have soul. If not, you
|
|
1525
|
+
shipped a template.
|
|
1526
|
+
|