actual-css 0.19.4 → 0.19.5

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.
Files changed (35) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +2 -2
  3. package/dist/actual.full.css +6 -2
  4. package/dist/actual.full.min.css +1 -1
  5. package/docs/pages/forms/joined-controls.md +1 -1
  6. package/docs/pages/forms/switch.md +4 -2
  7. package/docs/pages/foundations/tokens.md +13 -13
  8. package/llms.txt +3 -3
  9. package/package.json +4 -5
  10. package/src/cli/actual-css.js +3 -3
  11. package/src/css/forms/switch.css +6 -2
  12. package/src/tooling/theme-contrast.js +6 -2
  13. package/docs/design-notes/accessibility-decisions.md +0 -63
  14. package/docs/design-notes/app-ui.md +0 -67
  15. package/docs/design-notes/architecture.md +0 -70
  16. package/docs/design-notes/browser-support.md +0 -239
  17. package/docs/design-notes/cascade-layer.md +0 -74
  18. package/docs/design-notes/column-layout.md +0 -260
  19. package/docs/design-notes/css-anchor.md +0 -87
  20. package/docs/design-notes/enhancement-contract.md +0 -193
  21. package/docs/design-notes/forced-colors.md +0 -123
  22. package/docs/design-notes/grid.md +0 -785
  23. package/docs/design-notes/motion-cost.md +0 -62
  24. package/docs/design-notes/naming.md +0 -71
  25. package/docs/design-notes/platform-alignment.md +0 -602
  26. package/docs/design-notes/popover-manual-poc.md +0 -328
  27. package/docs/design-notes/references.md +0 -336
  28. package/docs/design-notes/rich-text.md +0 -61
  29. package/docs/design-notes/spacing-units.md +0 -286
  30. package/docs/design-notes/steps.md +0 -776
  31. package/docs/design-notes/surface-reparenting.md +0 -130
  32. package/docs/design-notes/tokens.md +0 -166
  33. package/docs/design-notes/tooltip-coordinate-space.md +0 -130
  34. package/docs/design-notes/widget-primitives.md +0 -144
  35. package/docs/navigation.json +0 -176
@@ -1,785 +0,0 @@
1
- # Grid Responsiveness and Balanced Subdivision
2
-
3
- ## Status
4
-
5
- Design note for Actual CSS 0.4.
6
-
7
- This document explains the intended behavior of `.grid` and `.grid-N`, the alternatives considered, and the CSS constraints that prevent a single mechanism from satisfying every use case.
8
-
9
- The goal is to preserve these decisions so future changes do not accidentally reintroduce previously rejected approaches.
10
-
11
- ## Problem
12
-
13
- Actual CSS exposes two related but distinct grid use cases:
14
-
15
- * a free collection that should adapt naturally to available space;
16
- * a structured collection where a known column density should collapse through visually balanced subdivisions.
17
-
18
- These goals are not equivalent.
19
-
20
- A generic intrinsic grid can efficiently fill available space, but it does not know whether the resulting number of columns produces a balanced distribution for the number of items.
21
-
22
- Conversely, a structurally balanced grid can preserve predictable subdivisions, but CSS cannot make it fully autonomous without introducing other layout constraints.
23
-
24
- The distinction matters most when resizing a collection.
25
-
26
- For six items, a purely space-driven grid may naturally move through:
27
-
28
- ```text
29
- 6 → 5 → 4 → 3 → 2 → 1
30
- ```
31
-
32
- This maximizes use of available space, but produces layouts such as:
33
-
34
- ```text
35
- 5 + 1
36
- 4 + 2
37
- ```
38
-
39
- Actual's structural grid use case instead prefers:
40
-
41
- ```text
42
- 6 → 3 → 2 → 1
43
- ```
44
-
45
- Every state is a natural subdivision of six and every item has the same width.
46
-
47
- ## Core principle
48
-
49
- Actual distinguishes **space-driven grids** from **count-driven grids**.
50
-
51
- ### `.grid`: space-driven collection
52
-
53
- `.grid` is an intrinsic responsive collection.
54
-
55
- Its behavior is driven by:
56
-
57
- * the width of its containing block;
58
- * `--grid-min`;
59
- * the number of tracks that can fit.
60
-
61
- A typical implementation uses `auto-fit`.
62
-
63
- The browser is free to choose any number of columns that satisfies the minimum item width.
64
-
65
- No guarantee is made about balanced final rows.
66
-
67
- Conceptually:
68
-
69
- ```text
70
- available space
71
- ↓
72
- how many items fit?
73
- ↓
74
- auto-fit
75
- ```
76
-
77
- This is appropriate for collections where filling available space is more important than preserving a particular structural rhythm.
78
-
79
- ### `.grid-N`: count-driven structural grid
80
-
81
- `.grid-2`, `.grid-3`, `.grid-4`, and `.grid-6` express a preferred structural density.
82
-
83
- Their responsive progression should favor natural divisors of that density.
84
-
85
- The intended chains are:
86
-
87
- ```text
88
- .grid-2 2 → 1
89
- .grid-3 3 → 1
90
- .grid-4 4 → 2 → 1
91
- .grid-6 6 → 3 → 2 → 1
92
- ```
93
-
94
- This deliberately skips intermediate column counts that would create visibly uneven subdivisions.
95
-
96
- For example, `.grid-6` should not pass through five or four columns simply because five or four tracks happen to fit.
97
-
98
- The defining property of `.grid-N` is therefore not merely:
99
-
100
- > at most N columns
101
-
102
- It is:
103
-
104
- > a structural density of N columns that collapses through balanced subdivisions of N.
105
-
106
- ## Equal-width items are an invariant
107
-
108
- Actual does not attempt to repair an incomplete row by stretching individual items, changing their span independently, or making the last card wider than its peers.
109
-
110
- At every responsive state, all direct items in a structural grid should have the same width.
111
-
112
- Layouts such as this are intentionally avoided:
113
-
114
- ```text
115
- [A][B][C]
116
- [ D ][E]
117
- ```
118
-
119
- The grid may contain an incomplete final row when its item count is incompatible with the selected density, but the items themselves remain regular.
120
-
121
- Visual consistency of the grid is more important than artificially filling every pixel.
122
-
123
- ## Item count and structural density are different inputs
124
-
125
- A structural density does not imply that CSS knows the actual number of items.
126
-
127
- For example, `.grid-6` describes the sequence:
128
-
129
- ```text
130
- 6 → 3 → 2 → 1
131
- ```
132
-
133
- but it does not guarantee a balanced final row for an arbitrary number of children.
134
-
135
- With eight items, six columns still produce:
136
-
137
- ```text
138
- 6 + 2
139
- ```
140
-
141
- and three columns produce:
142
-
143
- ```text
144
- 3 + 3 + 2
145
- ```
146
-
147
- CSS is not inferring the child count and selecting an optimal divisor of that count.
148
-
149
- The contract is narrower:
150
-
151
- > `.grid-N` provides balanced subdivisions of the declared structural density N.
152
-
153
- This works particularly well when collection sizes are naturally compatible with that density.
154
-
155
- For paginated collections, the server knows the page size and should choose a page size that works well with the expected presentation densities.
156
-
157
- A partial final page is normal. CSS should not contain pagination heuristics intended to disguise a poor full-page item count.
158
-
159
- ## Why `auto-fit` alone is insufficient
160
-
161
- `auto-fit` answers a spatial question:
162
-
163
- > How many tracks of this minimum size fit in the available width?
164
-
165
- It does not answer:
166
-
167
- > Which number of tracks produces the most balanced subdivision?
168
-
169
- For six items, if five columns fit, `auto-fit` may use five columns.
170
-
171
- That behavior is correct for an intrinsic collection and incorrect for the structural-grid contract.
172
-
173
- Therefore `.grid-N` cannot simply be implemented as `.grid` with a maximum column count if balanced subdivision remains a goal.
174
-
175
- ## Why `auto-fill` does not solve subdivision
176
-
177
- `auto-fill` differs from `auto-fit` mainly in its treatment of empty tracks.
178
-
179
- This matters when fewer items exist than the available grid capacity.
180
-
181
- For example, with a four-column capacity and three items:
182
-
183
- ```text
184
- auto-fit
185
- [A ][B ][C ]
186
-
187
- auto-fill
188
- [A][B][C][ ]
189
- ```
190
-
191
- `auto-fill` can therefore preserve card width on a partial final page instead of expanding the remaining items.
192
-
193
- That is useful behavior for catalogue-like layouts.
194
-
195
- However, it does not solve the subdivision problem.
196
-
197
- With six items and enough room for four columns, both mechanisms can still produce:
198
-
199
- ```text
200
- [A][B][C][D]
201
- [E][F]
202
- ```
203
-
204
- Neither `auto-fit` nor `auto-fill` understands that three columns would form the more balanced `3 + 3` subdivision.
205
-
206
- `auto-fill` is therefore not a replacement for the `.grid-N` responsive model.
207
-
208
- ## Historical implementation in 0.3.1
209
-
210
- Actual CSS 0.3.1 already distinguished intrinsic grids from structural grids.
211
-
212
- The structural presets changed their column count using container queries.
213
-
214
- This allowed responsive behavior to depend on the size of the grid's local layout context rather than on the viewport.
215
-
216
- The important architectural property was:
217
-
218
- ```text
219
- query container
220
- ↓
221
- .grid-N
222
- ```
223
-
224
- The grid itself remained an ordinary grid item and therefore retained its normal intrinsic sizing behavior.
225
-
226
- The main drawback was ergonomic: responsive structural grids depended on an explicit ancestor establishing the query container.
227
-
228
- The requirement looked like an implementation detail in markup, which motivated attempts to make `.grid-N` autonomous in 0.4.
229
-
230
- The behavior was worth preserving; the mechanism was the part under investigation.
231
-
232
- ## Demoted, not rejected: bounded intrinsic grids
233
-
234
- One proposed 0.4 design implemented `.grid-N` as an intrinsic `auto-fit` or
235
- `auto-fill` grid capped at N columns.
236
-
237
- This removed breakpoints and container-query requirements.
238
-
239
- It cannot be the whole answer, because it optimizes for available space:
240
-
241
- ```text
242
- 6 -> 5 -> 4 -> 3 -> 2 -> 1
243
- ```
244
-
245
- where a structural grid is expected to optimize for subdivision:
246
-
247
- ```text
248
- 6 -> 3 -> 2 -> 1
249
- ```
250
-
251
- The mechanism therefore answers a different question than the one `.grid-N`
252
- asks.
253
-
254
- It is nevertheless the right **baseline**. Bounded at N, using `auto-fill`, it
255
- is responsive, overflow-safe, and equal-width at every state, and it needs
256
- nothing above Actual's Minimal floor. Adopting it as the unenhanced behavior of
257
- `.grid-N` is what makes the actual-container container a precision enhancement rather than
258
- a prerequisite for responsiveness. This is the single most important difference
259
- from 0.3.1, where a preset used without a wrapper stayed frozen at N columns
260
- and was a genuine trap.
261
-
262
- ## Rejected approach: `smart-grid` item-count heuristics
263
-
264
- Another direction attempted to choose intermediate column counts that avoided orphan rows.
265
-
266
- For a collection containing `itemCount` items and `c` columns, a one-item final row appears when:
267
-
268
- ```text
269
- itemCount mod c = 1
270
- ```
271
-
272
- This observation is useful, but it is not a suitable basis for a generic grid class.
273
-
274
- The undesirable column counts depend on the actual number of items, not only on the declared grid density.
275
-
276
- A fixed `.grid-4` class cannot know whether three columns are desirable:
277
-
278
- * for ten items, three columns produces `3 + 3 + 3 + 1`;
279
- * for twelve items, three columns produces a perfect `3 + 3 + 3 + 3`.
280
-
281
- Hard-coding `.grid-4` to skip three columns would encode the answer for one item count and penalize another.
282
-
283
- More importantly, avoiding a singleton is weaker than balanced subdivision.
284
-
285
- For six items, four columns gives `4 + 2`. There is no singleton, but `3 + 3` is still structurally preferable.
286
-
287
- Actual therefore does not attempt to infer an optimal layout from item count in CSS.
288
-
289
- ## Rejected approach: make `.grid-N` its own query container
290
-
291
- A promising prototype used:
292
-
293
- ```css
294
- .grid-N {
295
- container-type: inline-size;
296
- }
297
- ```
298
-
299
- and kept a fixed internal track count.
300
-
301
- Instead of changing `grid-template-columns` on the container, container queries changed `grid-column: span ...` on its children.
302
-
303
- For a six-track grid:
304
-
305
- ```text
306
- span 1 → 6 columns
307
- span 2 → 3 columns
308
- span 3 → 2 columns
309
- span 6 → 1 column
310
- ```
311
-
312
- This successfully produced:
313
-
314
- ```text
315
- 6 → 3 → 2 → 1
316
- ```
317
-
318
- without requiring an external query-container wrapper.
319
-
320
- It also guaranteed equal-width items.
321
-
322
- Technically, the mechanism is valid: descendants can query the dimensions of their ancestor query container.
323
-
324
- However, the solution has a serious side effect.
325
-
326
- ### Inline-size containment changes intrinsic sizing
327
-
328
- `container-type: inline-size` introduces inline-size containment.
329
-
330
- The contents of the grid no longer contribute normally to the grid's intrinsic inline size.
331
-
332
- Probes showed the following behavior:
333
-
334
- | Context | Observed grid width |
335
- | ------------------------------- | ------------------: |
336
- | normal block | 1192px |
337
- | parent grid `auto` track | 992px |
338
- | parent grid `min-content` track | 48px |
339
- | flex item with `flex: 0 1 auto` | 48px |
340
- | `width: fit-content` | 48px |
341
- | float | 48px |
342
- | inline-block | 0px |
343
-
344
- The self-container therefore works when the grid already receives a definite or stretched width, but can collapse almost completely in shrink-to-fit or intrinsic-sizing contexts.
345
-
346
- This is not merely an artificial CSS edge case.
347
-
348
- Actual's own composition primitives can create such contexts.
349
-
350
- For example:
351
-
352
- ```html
353
- <div class="cluster">
354
- <div class="grid-4">...</div>
355
- </div>
356
- ```
357
-
358
- `.cluster` is a wrapping flex row whose children retain normal `flex: 0 1 auto` sizing.
359
-
360
- A self-contained `.grid-4` can therefore exhibit exactly the collapse observed in the probe.
361
-
362
- Similar intrinsic-sizing concerns exist when a structural grid participates in auto-sized tracks or other shrink-to-fit compositions.
363
-
364
- ### Why this approach is rejected
365
-
366
- Making `.grid-N` its own query container removes an explicit wrapper at the cost of changing the fundamental sizing behavior of the primitive.
367
-
368
- That trade-off is not acceptable for a composable layout library.
369
-
370
- Attempts to compensate with `contain-intrinsic-size`, special rules for `.cluster`, or other context-specific fixes would add complexity and create coupling between otherwise independent primitives.
371
-
372
- The self-container approach is therefore rejected.
373
-
374
- ## Why an external query container is not merely a workaround
375
-
376
- A size container query cannot make an element react to its own size without applying containment to that element.
377
-
378
- Placing the query container on an ancestor preserves the intrinsic sizing behavior of `.grid-N` while still allowing the grid to react to local available space.
379
-
380
- The relationship is:
381
-
382
- ```text
383
- query container (any ancestor, e.g. .container-query)
384
- ↓ observes local available width
385
- .grid-N
386
- ↓ changes structural subdivision
387
- items
388
- ```
389
-
390
- The extra ancestor is therefore not accidental ceremony.
391
-
392
- It represents a real boundary imposed by the CSS containment model.
393
-
394
- Actual should not hide that boundary if hiding it requires changing the sizing semantics of the grid. Balanced subdivision keys off a container **named** `actual-container` rather than any anonymous query container, so an incidental `container-type: inline-size` region never changes the grid by accident; `.container-query` is the convenience helper that establishes that named context. The name is generic rather than grid-specific: it means "here is the width you were allocated", and other size-aware components (`.steps` and its label collapse) read the same context. The grid does not own it — it is one consumer.
395
-
396
- ## Out of scope: explicit per-region placement
397
-
398
- Editorial or application layouts that need arbitrary per-region spans and starts
399
- are outside the `.grid` / `.grid-N` collection contract. Both primitives lay out
400
- uniform peers; neither expresses "this region occupies seven units starting at
401
- the third".
402
-
403
- That case is answered by `.column-layout`, an opt-in twelve-column coordinate
404
- system with no automatic responsive behavior. See `column-layout.md`. It also
405
- narrows `--grid-columns` to its intended role: track templates whose sizes carry
406
- meaning, rather than a stand-in for a coordinate system.
407
-
408
- ## Progressive enhancement
409
-
410
- Container queries are guaranteed across Minimal, but not across Degraded — and
411
- Degraded browsers still receive every stylesheet.
412
-
413
- Structural grids must therefore have a usable fallback without them.
414
-
415
- The fallback should remain structurally valid and readable. It does not need to reproduce the full responsive subdivision behavior.
416
-
417
- Modern browsers may enhance the grid when it is placed inside a query container.
418
-
419
- This follows Actual's general compatibility rule:
420
-
421
- > Modern CSS should not raise the Minimal baseline when a progressive fallback is possible at low cost.
422
-
423
- ## Relationship with `--grid-min`
424
-
425
- `--grid-min` belongs naturally to `.grid`.
426
-
427
- It expresses the minimum desirable width of an item in a space-driven collection.
428
-
429
- Structural `.grid-N` presets are different: their behavior is driven by a known count and a predefined subdivision sequence.
430
-
431
- Trying to derive their container-query thresholds from `--grid-min` is not currently practical because size container-query conditions cannot use arbitrary custom-property values as their thresholds.
432
-
433
- The APIs should therefore remain conceptually separate:
434
-
435
- ```text
436
- .grid
437
- input: --grid-min
438
- strategy: available-space driven
439
-
440
- .grid-N
441
- input: structural density N
442
- strategy: divisor-driven subdivision
443
- ```
444
-
445
- The fact that both produce CSS Grid layouts does not mean they require the same responsive algorithm.
446
-
447
- ## Supported structural densities
448
-
449
- The current useful presets are:
450
-
451
- ```text
452
- 2 → 1
453
- 3 → 1
454
- 4 → 2 → 1
455
- 6 → 3 → 2 → 1
456
- ```
457
-
458
- Not every integer necessarily deserves a preset.
459
-
460
- For example, five has only trivial divisors:
461
-
462
- ```text
463
- 5 → 1
464
- ```
465
-
466
- Adding `.grid-5` would either produce an abrupt transition or require introducing non-divisor heuristics such as `5 → 2 → 1`.
467
-
468
- Actual should not add structural presets merely to complete a numerical sequence.
469
-
470
- New presets should have a clear layout use case and a defensible subdivision chain.
471
-
472
- ## Thresholds are visual design decisions
473
-
474
- The subdivision chain can be derived from the structural density.
475
-
476
- The width thresholds at which transitions occur cannot.
477
-
478
- Values such as:
479
-
480
- ```text
481
- 28rem
482
- 48rem
483
- 64rem
484
- ```
485
-
486
- must be validated against realistic Actual content rather than inherited mechanically from historical breakpoints.
487
-
488
- Before changing structural-grid thresholds, probes should verify:
489
-
490
- * realistic cards rather than empty boxes;
491
- * narrow parent inside a wide viewport;
492
- * every expected subdivision state;
493
- * equal item widths;
494
- * full and partial rows;
495
- * interaction with common Actual composition primitives;
496
- * fallback behavior without container-query support.
497
-
498
- The viewport itself should not determine the result; the relevant local container should.
499
-
500
- ## Why there is no breakpoint scale
501
-
502
- Actual exposes no `sm` / `md` / `lg` / `xl` scale, and the structural grid is the
503
- clearest illustration of why. The whole framework declares two width media
504
- queries:
505
-
506
- ```text
507
- @media (max-width: 30rem) x2 modal padding on small screens
508
- @media (min-width: 48rem) x1 .app-layout, bottom nav -> side nav
509
- ```
510
-
511
- Everything else responsive is intrinsic or container-driven. The responsibility
512
- splits cleanly:
513
-
514
- ```text
515
- viewport
516
- |
517
- +-- the few genuinely viewport-level decisions
518
- | .app-layout
519
- |
520
- +-- composition and chrome
521
- |
522
- named query container
523
- |
524
- actual-container
525
- |
526
- 2 / 3 / 4 / 6 stages
527
- ```
528
-
529
- **Thresholds are local and content-driven.** `28rem`, `48rem` and `64rem`
530
- describe how much room *this collection* needs for a given density, probed
531
- against the content each preset targets. They are not device classes, and the
532
- fact that two of them coincide with widely used framework breakpoints is a
533
- coincidence, not the justification. A grid does not know what device it is on
534
- and does not need to.
535
-
536
- **The unit is `rem` so the thresholds follow typographic scale.** Container
537
- query lengths in `rem` resolve against the root font size, so a reader who
538
- scales their type up moves every threshold with it:
539
-
540
- ```text
541
- root 16px 48rem = 768px 768px container -> .grid-3 = 3 columns
542
- root 20px 48rem = 960px 768px container -> .grid-3 = 1 column
543
- root 24px 48rem = 1152px 768px container -> .grid-3 = 1 column
544
- ```
545
-
546
- That is the correct response, not a rounding artifact: larger type genuinely
547
- needs more room per item, so the same container honestly supports fewer columns.
548
- A `px` breakpoint cannot express this.
549
-
550
- ### Container width is not a monotonic function of viewport width
551
-
552
- This is the empirical case against a global scale, and it is measurable inside
553
- this repository. `demo/templates/dashboard.html` reveals its workspace sidebar
554
- at `72rem`. Measuring the main region's content box across that boundary:
555
-
556
- | Viewport | Container content box | `.grid-4` | `.grid-6` |
557
- | -------- | --------------------- | --------- | --------- |
558
- | 1100px | 65.8rem | 4 | 6 |
559
- | 1160px | 52.6rem | 2 | 3 |
560
-
561
- The viewport grew by 60px and the grid lost half its columns, because the
562
- composition spent that growth on chrome rather than on content. A viewport-keyed
563
- system reasons about this backwards by construction: it sees a wider screen and
564
- infers more room, at the exact moment there is less. No amount of breakpoint
565
- tuning fixes that, because there is no stable function from viewport width to
566
- container width — the composition sits in between and is free to change.
567
-
568
- A named query container asks the only question with a reliable answer: *how much
569
- inline space does this collection actually have?* Everything the ladder does
570
- follows from that measurement, which is why the thresholds can stay content-
571
- derived instead of device-derived.
572
-
573
- ## API guidance
574
-
575
- Use `.grid` when the number of columns should emerge naturally from available space.
576
-
577
- Use `.grid-N` when the declared density and its balanced subdivisions are part of the intended composition.
578
-
579
- Use structural grids for uniform peer items. They are not intended as editorial grids with arbitrary per-item spans.
580
-
581
- Do not use CSS layout heuristics to compensate for a pagination size that produces undesirable full-page distributions when the server already knows the item count.
582
-
583
- ## Decision
584
-
585
- Actual keeps two different grid contracts.
586
-
587
- ```text
588
- .grid
589
- intrinsic
590
- space-driven
591
- auto-fit
592
- configurable through --grid-min
593
- no guarantee of balanced rows
594
-
595
- .grid-N
596
- structural
597
- count-driven
598
- equal-width items
599
- responsive through natural subdivisions of N
600
- local-container driven when enhanced
601
- ```
602
-
603
- A structural grid must not become its own inline-size query container, because doing so breaks intrinsic and shrink-to-fit composition.
604
-
605
- If local responsive subdivision requires a size container query, that query container must remain outside the structural grid.
606
-
607
- The explicit container boundary is preferable to hidden containment side effects.
608
-
609
- The guiding principle is:
610
-
611
- > `.grid` optimizes for available space. `.grid-N` optimizes for balanced subdivision.
612
-
613
- Future grid changes should preserve that distinction unless the public contract itself is intentionally reconsidered.
614
-
615
- ## Resolution
616
-
617
- `.grid-N` is a bounded `auto-fill` grid by default, and a divisor-chain grid
618
- inside a query container.
619
-
620
- ```text
621
- .grid space-driven, auto-fit, --grid-min
622
- .grid-N count-driven baseline, auto-fill bounded at N,
623
- may pass through non-divisor column counts
624
- actual-container .grid-N balanced subdivision, N -> divisors of N -> 1
625
- ```
626
-
627
- The whole enhancement lives inside `@supports (container-type: inline-size)`.
628
- Browsers below the floor get the baseline whether or not a wrapper is present,
629
- which removes the parallel `@media` block 0.3.1 had to maintain in lockstep
630
- with its container thresholds.
631
-
632
- ### `--grid-min` is not a `.grid-N` hook
633
-
634
- `@container` thresholds cannot resolve a custom property. A hook honored in the
635
- baseline would therefore fall silent the moment an author added a query
636
- container — exactly the kind of hidden, position-dependent contract this
637
- redesign set out to remove. The baseline hard-codes `16rem` instead.
638
-
639
- The resulting API split is the clearer one anyway: item width is `.grid`'s
640
- contract, column density is `.grid-N`'s.
641
-
642
- ### Thresholds
643
-
644
- Three shared steps, not one calibrated per preset:
645
-
646
- ```text
647
- 28rem first horizontal density .grid-2, .grid-4, .grid-6 -> 2 columns
648
- 48rem three columns .grid-3, .grid-6 -> 3 columns
649
- 64rem dense densities .grid-4 -> 4, .grid-6 -> 6
650
- ```
651
-
652
- An earlier draft tuned each final step so that every preset landed an item
653
- around 240px, which put `.grid-6` at 80rem or 96rem. That was the wrong
654
- optimization, and worth recording so it is not re-derived.
655
-
656
- Calibrating every preset to the same item width erases the information N
657
- carries. An author does not reach for `.grid-N` to say *I have N things*; they
658
- say *my content suits this density*. `.grid-6` should reach six columns early
659
- precisely because choosing it is a statement that the items are compact. At
660
- 96rem an item is back to `.grid`'s 16rem default, and the preset has no reason
661
- to exist.
662
-
663
- The right probe is therefore each preset against the content it targets, not
664
- one specimen across all of them:
665
-
666
- | Preset | Probed with | Item at its final step | Result |
667
- | --------- | ---------------------------------- | ---------------------- | ------ |
668
- | `.grid-2` | large card, summary, action | 218px @ 28rem | clean |
669
- | `.grid-3` | standard card | 248px @ 48rem | clean |
670
- | `.grid-4` | compact card, stat | 247px @ 64rem | clean |
671
- | `.grid-6` | stat, avatar, thumbnail, icon tile | 161px @ 64rem | clean |
672
-
673
- 161px is small for a card with a heading and a paragraph — and that is the
674
- point. A preset that needs 250px per item is `.grid-4`, not `.grid-6`.
675
-
676
- The framework does not guess appropriate item size. The author states it by
677
- choosing a density; the framework then guarantees a clean structural collapse
678
- of that density.
679
-
680
- ### Reference container sizes
681
-
682
- The thresholds describe the **query container's content box**, not the viewport
683
- and not the grid's own border box. Padding and borders on the container come off
684
- the top before the query resolves. Verified states:
685
-
686
- | Container content box | `.grid-2` | `.grid-3` | `.grid-4` | `.grid-6` |
687
- | --------------------- | --------- | --------- | --------- | --------- |
688
- | `< 28rem` | 1 | 1 | 1 | 1 |
689
- | `28rem` – `< 48rem` | 2 | 1 | 2 | 2 |
690
- | `48rem` – `< 64rem` | 2 | 3 | 2 | 3 |
691
- | `>= 64rem` | 2 | 3 | 4 | 6 |
692
-
693
- Two consequences for anyone sizing a region that hosts a structural grid.
694
-
695
- **Size the region to land on a threshold, not just under one.** A region whose
696
- content box settles at 47rem gives `.grid-3` one column — the same result as
697
- 20rem. The step is a cliff, not a ramp, and `.grid-3` has no intermediate state
698
- to soften it; that is the invariant, not a defect. If a region is meant to show
699
- three columns, give it 48rem of content box with room to spare.
700
-
701
- **Budget backwards from the content box.** A region that must reach a threshold
702
- `T` needs `T + its own padding-inline + its own border-inline` of outer width.
703
- The convenient reference sizes are therefore the thresholds plus the padding the
704
- region actually carries:
705
-
706
- ```text
707
- target 28rem content box + 2 x 1rem padding + 2 x 1px border ~= 30.2rem outer
708
- target 48rem content box + 2 x 1rem padding + 2 x 1px border ~= 50.2rem outer
709
- target 64rem content box + 2 x 1rem padding + 2 x 1px border ~= 66.2rem outer
710
- ```
711
-
712
- Rounding **up** past that figure is deliberate. Landing on the threshold to the
713
- pixel means a later padding change, measured in fractions of a rem, silently
714
- drops the region a state.
715
-
716
- ### Why there is no `.grid-5`
717
-
718
- The divisors of five are five and one, so the chain would be `5 -> 1` with no
719
- intermediate state. The system exposes densities that subdivide well, not every
720
- integer. Proposals to give `.grid-5` a hand-picked `5 -> 2 -> 1` chain are
721
- covered by the rejected `smart-grid` section above: those steps encode an
722
- assumption about item count that the class cannot verify.
723
-
724
- ## Demonstrability is part of the contract
725
-
726
- A threshold nobody can reach is indistinguishable from a threshold that does not
727
- work. This was not hypothetical: the documentation site shipped for some time
728
- with an article column capped at 48rem, and the live demo previews inside it are
729
- the query containers. Their content box therefore topped out at **45.9rem at
730
- every viewport width** — 1280px, 1920px, identical. Every `.grid-3` demo on the
731
- site rendered one column, `.grid-4` and `.grid-6` rendered two, and the page
732
- teaching `6 -> 3 -> 2 -> 1` showed the reader its 2-column state as though that
733
- were the top of the chain.
734
-
735
- The bug was reported as a `.grid-3` calibration complaint. It was not one. No
736
- text-based check could see it, because every class name, every threshold, and
737
- every rule in the framework was correct.
738
-
739
- Two durable rules came out of it.
740
-
741
- **The query container must be the element whose content box is the grid's actual
742
- available space.** Putting `container` on a padded box is correct; putting it on
743
- an outer wrapper and letting an inner box add the padding makes the query
744
- resolve against a width the grid does not have, firing every threshold early.
745
- The demo would then claim a state it cannot honor — a lie in the geometry rather
746
- than in the CSS.
747
-
748
- **A surface that documents the thresholds has to be wide enough to reach them.**
749
- The docs shell is sized backwards from 64rem plus the preview's own padding, and
750
- that arithmetic is asserted in `tests/docs-geometry.test.js` against the
751
- thresholds parsed out of `grid.css`, so raising a threshold without giving the
752
- documentation room to reach it fails a test instead of quietly degrading every
753
- demo. The prose keeps its own reading measure inside the wider track: demo
754
- measure and prose measure are different contracts and should not be forced to
755
- share a number.
756
-
757
- ### A probe that correctly changed nothing
758
-
759
- The same investigation measured `.choice-card` in a forced 3-up, to ask whether
760
- `.grid-3`'s 48rem step was simply too conservative:
761
-
762
- | Container | px / card | Result |
763
- | --------- | --------- | ------------------ |
764
- | 44rem | 224 | one line, at ease |
765
- | 40rem | 203 | one line, at limit |
766
- | 38rem | 192 | **wraps** |
767
- | 32rem | 160 | wraps badly |
768
-
769
- So those particular cards do fit three-up at roughly 40rem, well below the
770
- preset's step. That was not a reason to move the step or to add a density
771
- modifier, and the temptation is worth recording.
772
-
773
- `.grid-3` is a generic preset built around ~15.5rem per item, in agreement with
774
- `.grid-4`'s ~15.4rem. Choice cards are simply smaller than the preset's target
775
- content. Lowering the step to fit them would have put `.grid-3` at ~14.2rem and
776
- broken the only clean agreement in the ladder — to fix a symptom whose actual
777
- cause was 2rem of documentation padding.
778
-
779
- A modifier introducing a second density ladder becomes defensible only when
780
- *several unrelated* content families independently show the standard steps to be
781
- too conservative while wanting identical balanced-collapse behavior. One
782
- component in one miscalibrated container is not that evidence. A per-component
783
- threshold would also collide with the established meaning of `.compact` in
784
- Actual: UI density, including tighter local padding on `.card.compact` and
785
- `.table.compact`, never a layout threshold.