actual-css 0.19.4 → 0.20.0

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 (95) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/README.md +6 -6
  3. package/components.json +6 -3
  4. package/dist/actual.full.css +249 -50
  5. package/dist/actual.full.js +2 -2
  6. package/dist/actual.full.min.css +1 -1
  7. package/dist/types/menu.d.ts +2 -5
  8. package/docs/pages/components/accordion.md +11 -6
  9. package/docs/pages/components/alert.md +64 -62
  10. package/docs/pages/components/avatar.md +12 -12
  11. package/docs/pages/components/badge.md +15 -15
  12. package/docs/pages/components/breadcrumb.md +10 -8
  13. package/docs/pages/components/button.md +56 -7
  14. package/docs/pages/components/card.md +21 -21
  15. package/docs/pages/components/dialog.md +97 -69
  16. package/docs/pages/components/drawer.md +33 -33
  17. package/docs/pages/components/indicator.md +12 -12
  18. package/docs/pages/components/navbar.md +41 -9
  19. package/docs/pages/components/pagination.md +7 -7
  20. package/docs/pages/components/progress.md +18 -13
  21. package/docs/pages/components/rating.md +19 -19
  22. package/docs/pages/components/reveal.md +2 -0
  23. package/docs/pages/components/segmented.md +35 -31
  24. package/docs/pages/components/skeleton.md +10 -8
  25. package/docs/pages/components/spinner.md +21 -15
  26. package/docs/pages/components/table.md +26 -28
  27. package/docs/pages/enhancements/flyout.md +94 -43
  28. package/docs/pages/enhancements/in-view.md +3 -1
  29. package/docs/pages/enhancements/scrollspy.md +51 -18
  30. package/docs/pages/enhancements/tabs.md +43 -37
  31. package/docs/pages/enhancements/tooltip.md +4 -2
  32. package/docs/pages/forms/ajax.md +66 -0
  33. package/docs/pages/forms/choice-cards.md +8 -8
  34. package/docs/pages/forms/color-swatches.md +12 -12
  35. package/docs/pages/forms/form-actions.md +23 -0
  36. package/docs/pages/forms/joined-controls.md +8 -8
  37. package/docs/pages/forms/labels.md +11 -11
  38. package/docs/pages/forms/overview.md +35 -29
  39. package/docs/pages/forms/states-and-sizes.md +9 -9
  40. package/docs/pages/forms/switch.md +35 -2
  41. package/docs/pages/forms/validation.md +16 -16
  42. package/docs/pages/foundations/theming.md +32 -2
  43. package/docs/pages/foundations/tokens.md +18 -16
  44. package/docs/pages/guides/coding-agents.md +18 -0
  45. package/docs/pages/guides/introduction.md +1 -1
  46. package/llms.txt +3 -3
  47. package/package.json +5 -5
  48. package/reserved-classes.json +1 -0
  49. package/skills/actual-css/SKILL.md +7 -0
  50. package/src/cli/actual-css.js +3 -3
  51. package/src/css/components/badge.css +10 -6
  52. package/src/css/components/button.css +20 -7
  53. package/src/css/components/join.css +14 -4
  54. package/src/css/components/navbar.css +83 -1
  55. package/src/css/components/pagination.css +3 -1
  56. package/src/css/components/segmented.css +27 -7
  57. package/src/css/core/theme.css +11 -9
  58. package/src/css/core/tokens.css +7 -1
  59. package/src/css/core/variants.css +2 -0
  60. package/src/css/effects/reveal.css +15 -6
  61. package/src/css/forms/control.css +11 -1
  62. package/src/css/forms/form.css +14 -4
  63. package/src/css/forms/switch.css +32 -3
  64. package/src/js/ajax.js +18 -1
  65. package/src/js/context-menu.js +1 -3
  66. package/src/js/flyout.js +14 -5
  67. package/src/js/in-view.js +41 -30
  68. package/src/js/menu.js +9 -21
  69. package/src/js/surface.js +38 -0
  70. package/src/tooling/design-tokens.js +1 -0
  71. package/src/tooling/theme-contrast.js +24 -9
  72. package/tokens.json +1 -0
  73. package/docs/design-notes/accessibility-decisions.md +0 -63
  74. package/docs/design-notes/app-ui.md +0 -67
  75. package/docs/design-notes/architecture.md +0 -70
  76. package/docs/design-notes/browser-support.md +0 -239
  77. package/docs/design-notes/cascade-layer.md +0 -74
  78. package/docs/design-notes/column-layout.md +0 -260
  79. package/docs/design-notes/css-anchor.md +0 -87
  80. package/docs/design-notes/enhancement-contract.md +0 -193
  81. package/docs/design-notes/forced-colors.md +0 -123
  82. package/docs/design-notes/grid.md +0 -785
  83. package/docs/design-notes/motion-cost.md +0 -62
  84. package/docs/design-notes/naming.md +0 -71
  85. package/docs/design-notes/platform-alignment.md +0 -602
  86. package/docs/design-notes/popover-manual-poc.md +0 -328
  87. package/docs/design-notes/references.md +0 -336
  88. package/docs/design-notes/rich-text.md +0 -61
  89. package/docs/design-notes/spacing-units.md +0 -286
  90. package/docs/design-notes/steps.md +0 -776
  91. package/docs/design-notes/surface-reparenting.md +0 -130
  92. package/docs/design-notes/tokens.md +0 -166
  93. package/docs/design-notes/tooltip-coordinate-space.md +0 -130
  94. package/docs/design-notes/widget-primitives.md +0 -144
  95. package/docs/navigation.json +0 -176
@@ -1,239 +0,0 @@
1
- # Browser support strategy
2
-
3
- ## Actual tiers
4
-
5
- The compatibility contract is expressed in browser versions, not ECMAScript
6
- edition labels. Each tier is defined by what it guarantees.
7
-
8
- | Actual tier | Firefox | Safari | Chromium | Contract |
9
- | ----------- | -------: | ------: | -------: | ---------------------------------------------- |
10
- | Degraded | 78+ | 14+ | 88+ | Semantic HTML + core CSS; JS unsupported |
11
- | **Minimal** | **125+** | **17+** | **116+** | Full supported Actual experience, including JS |
12
- | Recommended | 129+ | 17.5+ | 123+ | Target experience |
13
-
14
- - **Degraded** keeps useful HTML and CSS on older browsers. JavaScript is
15
- explicitly outside the supported contract there.
16
- - **Minimal** is the JavaScript baseline: the complete Actual experience,
17
- including the runtime, is supported from this tier up. The runtime assumes
18
- modern platform primitives available across the whole tier and ships no
19
- legacy compatibility layer or polyfill.
20
-
21
- Only the JavaScript floor is expressed by Minimal. CSS degradation is owed to
22
- Degraded, so a capability being available across Minimal does not make it CSS
23
- baseline — `check:compat` audits stylesheets against the Degraded floor.
24
-
25
- Degraded browsers may still run some JavaScript successfully, but that
26
- behavior is not tested, documented as supported, or preserved when the
27
- runtime evolves.
28
-
29
- ### Native Popover and the tiers
30
-
31
- Minimal sits exactly where the manual Popover transport lands: Chromium 116,
32
- Firefox 125, Safari 17. That is what the floor buys, and the whole of what the
33
- runtime requires:
34
-
35
- ```text
36
- popover="manual"
37
- showPopover()
38
- hidePopover()
39
- top-layer promotion + closed-state display: none
40
- ```
41
-
42
- `popovertarget`, `popover="auto"` and `:popover-open` arrive on the same
43
- engines and are guaranteed too, but the runtime uses none of them — it keeps
44
- `aria-controls` and drives the lifecycle itself. Newer parts of the API
45
- (`popover="hint"`, interest invokers) are covered by no tier.
46
-
47
- | Actual tier | Manual Popover transport | Lifecycle owner |
48
- | ----------- | ------------------------ | -------------------------------------------- |
49
- | Degraded | no | HTML/CSS fallback only |
50
- | Minimal | yes | `surface.js`, `tooltip.js` |
51
- | Recommended | yes | native Popover, or `surface.js`/`tooltip.js` |
52
-
53
- Actual's presentation classes compose with either lifecycle. Both runtimes use
54
- the transport and never the native lifecycle: `popover="auto"` cannot express
55
- `data-flyout-auto-close`, and it would put the browser's light dismiss in
56
- competition with the tooltip's own hover and focus policy. See
57
- [platform-alignment](platform-alignment.md).
58
-
59
- ## JavaScript philosophy
60
-
61
- > The Degraded tier exists primarily to preserve useful HTML and CSS on older
62
- > browsers. It does not constrain the JavaScript runtime.
63
-
64
- > Minimal is the JavaScript baseline.
65
-
66
- Modern JavaScript supported by all Minimal browsers may be used directly.
67
- Actual does not transpile, polyfill, or wrap platform APIs solely to extend
68
- JavaScript support below Minimal.
69
-
70
- ### Abortable listeners
71
-
72
- Abortable event listeners predate the Minimal floor by a wide margin: Firefox
73
- 86, Chrome 88, and WebKit (early 2021). ([Bugzilla][1], [Chrome][2],
74
- [WebKit][3])
75
-
76
- > `addEventListener({ signal })` is a baseline runtime primitive.
77
-
78
- Do not introduce compatibility wrappers (`listen`, `on`,
79
- `addAbortableListener`, `supportsSignal`) solely to reproduce a capability
80
- that is already native throughout Minimal.
81
-
82
- ### Native `<dialog>`
83
-
84
- Native `<dialog>` predates the floor on every engine: Safari 15.4, Firefox 98,
85
- and Chromium earlier still. ([WebKit][4])
86
-
87
- > Native dialog is assumed by the runtime; no dialog polyfill is shipped.
88
-
89
- ### The manual Popover transport
90
-
91
- The floor is set by this capability. `surface.js` and `tooltip.js` both promote
92
- their element with `popover="manual"` instead of moving it in the DOM, which is
93
- what keeps a surface — and an explicit tooltip — inside every scope that reaches
94
- it by inheritance. See [surface-reparenting](surface-reparenting.md).
95
-
96
- > The manual Popover transport is assumed by the runtime; there is no
97
- > reparenting fallback.
98
-
99
- A capability branch was rejected rather than overlooked: the fallback path is
100
- the defect, so keeping it would leave the bug in place for exactly the browsers
101
- the branch would have served.
102
-
103
- ### Future-direction invariants
104
-
105
- 1. **Minimal drives JavaScript compatibility; Degraded does not.**
106
- 2. **Prefer native platform APIs over compatibility abstractions when they are
107
- available throughout Minimal.**
108
- 3. **Browser versions are the compatibility contract, not ECMAScript edition
109
- labels.**
110
- 4. **Raise Minimal only when doing so buys a concrete simplification, removal
111
- of a fallback, or materially better implementation.**
112
-
113
- > Do not preserve an older JavaScript idiom solely because it happens to run
114
- > in the Degraded tier. If the clearer native alternative is supported
115
- > throughout Minimal, prefer it.
116
-
117
- ---
118
-
119
- ## Philosophy
120
-
121
- Works everywhere, works best on modern browsers. Wide browser support (even older browsers, not IE 11).
122
-
123
- - No consumer build step is required (just CSS).
124
- - No post-processing — use only necessary browser-specific prefixes and engine hooks.
125
- - CSS nesting is not used — code must be findable in the inspector. Rules are organized as if nesting were used, grouped together without nesting syntax. Exception: see [CSS nesting inside @supports](#css-nesting-inside-supports).
126
-
127
- ## Platform feature baseline
128
-
129
- The tiers above are Actual's own contract. The table below tracks the Web
130
- Platform Baseline of the individual CSS features the framework uses; it is a
131
- different notion from an Actual tier.
132
-
133
- | Feature area | Baseline | Progressive enhancement |
134
- | ------------------------------------- | ------------- | ------------------------------------ |
135
- | Layout (flex, grid, position) | Baseline 2023 | — |
136
- | CSS custom properties | Baseline 2023 | — |
137
- | `:has()` | Baseline 2023 | — |
138
- | `<dialog>` element | Baseline 2023 | — |
139
- | `color-mix()` | Baseline 2023 | Fallback flat color |
140
- | `light-dark()` | 2024+ | Manual theme override |
141
- | `:user-invalid` | 2024+ | `[aria-invalid]` attribute |
142
- | `transition-behavior: allow-discrete` | 2024+ | Native dialog open/close |
143
- | `appearance: base-select` | 2024+ | Native `<select>` |
144
- | `@starting-style` | 2024+ | Instant appearance |
145
- | View Transition API | 2024+ | Dialog open/close transition |
146
- | Popover transport (`manual`) | Baseline 2025 | none — runtime requirement |
147
- | CSS Anchor Positioning | Future | JS positioning (`@lekoala/floating`) |
148
-
149
- Core layout and visual tokens work on all Baseline 2023 browsers. Features marked
150
- 2024+ are gated with `@supports` or degrade gracefully through fallback values.
151
-
152
- ## Dark mode
153
-
154
- Dark mode is for modern browsers only (light mode is the fallback otherwise).
155
- Use `color-scheme: light dark` plus `light-dark()` for theme tokens so the
156
- default theme follows the OS without `data-theme`. Explicit themes pin
157
- `color-scheme` to light or dark.
158
-
159
- ## Progressive enhancement
160
-
161
- Modern features are gated with `@supports`; unsupported browsers keep the core layout and controls.
162
-
163
- - `color-mix(in oklch, ...)` — enhanced variant surfaces and hover states
164
- - `appearance: base-select` — enhanced select picker on fine-pointer devices
165
- - `backdrop-filter` — enhanced sticky form actions
166
- - `transition-behavior: allow-discrete` — smooth dialog open/close
167
- - `:has()` — button groups, alert icons, disabled choice labels
168
-
169
- ### @supports usage
170
-
171
- Use positive `@supports` by default. Use `@supports not` only for a genuine fallback branch that cannot safely coexist with the enhanced rules. Do not gate a single progressive declaration whose unsupported value is simply ignored by the browser, such as `text-wrap: balance`.
172
-
173
- When a baseline declaration is already a valid fallback, prefer the normal cascade to an `@supports` wrapper. For example, older browsers keep the opaque surface here, while newer ones replace it with the translucent value:
174
-
175
- ```css
176
- background: var(--surface);
177
- background: color-mix(in oklch, var(--surface) 88%, transparent);
178
- backdrop-filter: blur(1rem);
179
- ```
180
-
181
- `@supports` is the simplest machine-readable boundary for a structural
182
- enhancement, not a preferred shape in itself. Where an unsupported selector
183
- already drops the enhancement cleanly and the baseline stays functional, a
184
- documented why-comment (the one the guard audit recognises) or a `PROGRESSIVE`
185
- ledger entry is just as valid. A wrapper that is behaviorally redundant is a
186
- simplification candidate: improve `check:compat` — for example, let one
187
- justification cover a contiguous group of rules — rather than let the wrapper
188
- become a framework convention.
189
-
190
- ### CSS nesting inside @supports
191
-
192
- The no-nesting rule protects browsers that predate CSS nesting (Chrome 112, Firefox 117, Safari 16.5). A block already gated behind a later feature can't be reached by any browser that lacks nesting, so the inspector-friendliness argument no longer applies — nest freely inside it. `appearance: base-select` (Chrome 133+) is the current example: everything inside that `@supports` block in `custom-select.css` uses `&`-nesting instead of repeating the `.select:not(...)` selector.
193
-
194
- Check the gating feature's baseline against nesting's before relying on this: if a future gate ships on a browser older than nesting's baseline, flatten that block back out.
195
-
196
- ### Vendor prefixes and engine hooks
197
-
198
- Keep a browser-specific prefix only when it reaches a still-relevant engine behavior that the standard property does not cover, or when it targets a browser-only native part. Examples include `-webkit-mask-*` where needed and pseudo-elements such as `::-webkit-scrollbar` or `::-webkit-progress-value`.
199
-
200
- Do not retain a prefixed duplicate merely to preserve an optional visual enhancement on older browsers. If the unprefixed declaration or an earlier fallback keeps the component functional and legible, prefer the smaller rule set.
201
-
202
- ### color-mix fallbacks
203
-
204
- Every `color-mix()` declaration needs a flat fallback outside `@supports` (older browsers drop the whole property, not just the function).
205
-
206
- ### Hover rules
207
-
208
- Use `:hover` directly for standard interactive feedback (links, buttons, table rows,
209
- form controls, menu items, tabs, badges). The browser already knows when `:hover` can
210
- apply; guarding it behind `@media (hover: hover)` needlessly suppresses hover on hybrid
211
- devices whose primary pointer is touch but that also have a mouse or trackpad.
212
-
213
- Reserve `@media (hover: hover)` only when hover:
214
-
215
- - reveals controls or content,
216
- - triggers heavy animation,
217
- - changes layout,
218
- - or is part of an interaction specifically designed for a mouse.
219
-
220
- `:active` feedback stays unguarded.
221
-
222
- ### forced-colors
223
-
224
- The default theme maps public color, focus, and shadow tokens to system colors
225
- inside `forced-colors: active`. Components should rely on those tokens first.
226
- Use local forced-color rules only for shapes or states the token layer cannot
227
- infer, such as custom checkbox/switch geometry, native progress/meter parts,
228
- disabled affordances, tooltip arrows, or selected states otherwise expressed
229
- only through background color.
230
-
231
- ### :has()
232
-
233
- - Grouping works with `role="group"` and `:has()`: it is a progressive enhancement; UI should still be functional without it.
234
- - Keep `:has()` out of selector lists that also contain legacy-safe selectors. Put the `:has()` branch in `@supports selector(...)` if necessary.
235
-
236
- [1]: https://bugzilla.mozilla.org/show_bug.cgi?id=1679204 "1679204 - Consider to add signal to addEventListener"
237
- [2]: https://developer.chrome.com/blog/new-in-chrome-88 "New in Chrome 88 | Blog"
238
- [3]: https://trac.webkit.org/timeline "WebKit timeline, January 2021"
239
- [4]: https://webkit.org/blog/12209/introducing-the-dialog-element/ "Introducing the Dialog Element"
@@ -1,74 +0,0 @@
1
- # Cascade layer strategy
2
-
3
- ## Purpose
4
-
5
- Actual CSS is designed for new projects where its bare class names don't
6
- conflict. For existing projects that need coexistence, `actual.layer.css`
7
- wraps the core entrypoint in a single `@layer actual` so its specificity
8
- is lower than unlayered author styles. `actual.layer.css` is layered core —
9
- it does not include the functional families. Use it as the base and import
10
- the families you need from `actual-css/css/*` outside the layer.
11
-
12
- ## Usage
13
-
14
- `actual.layer.css` wraps only the core entrypoint in the layer. The family
15
- manifests (components, forms, layout, …) are imported separately, outside the
16
- layer by default:
17
-
18
- ```css
19
- /* Before — classes may override existing project styles */
20
- @import "actual-css";
21
-
22
- /* After — core rules are scoped to the `actual` layer */
23
- @import "actual-css/css/layer";
24
- @import "actual-css/css/layout";
25
- @import "actual-css/css/forms";
26
- @import "actual-css/css/components";
27
- ```
28
-
29
- Author styles outside any layer will win over layer styles with equal
30
- specificity.
31
-
32
- For an existing project, the collisions that matter are component classes
33
- (`.card`, `.btn`, `.grid`, `.input`, `.navbar`), not the core tokens. If the
34
- whole framework must sit below the project's own styles, layer the full bundle
35
- in the project entrypoint:
36
-
37
- ```css
38
- @layer actual;
39
- @import "actual-css/full" layer(actual);
40
- ```
41
-
42
- There is no separate `full`-layer bundle; the two declarations above are the
43
- official recipe.
44
-
45
- ## Layer structure
46
-
47
- A single `actual` layer. The internal import order is a contract: later imports
48
- can override earlier ones within the layer. Sublayers (`actual.reset`,
49
- `actual.components`, etc.) are reserved for future use if the single layer
50
- causes real-world override issues.
51
-
52
- ## Import order contract
53
-
54
- Within `actual.css` (the minimal core) the order is:
55
-
56
- 1. Reset
57
- 2. Tokens
58
- 3. Theme
59
- 4. Base (document defaults)
60
- 5. Intents
61
- 6. Variants
62
- 7. Focus
63
- 8. Print
64
-
65
- This order is stable. If a future version introduces sublayers, the relative
66
- order will be preserved.
67
-
68
- ## Limitations
69
-
70
- - `actual.layer.css` cannot protect against conflicts with other layered
71
- frameworks that also use `@layer actual`. If both projects use the same
72
- layer name, the later `@layer` declaration wins.
73
- - The layer applies only when importing from `actual.layer.css`. Direct
74
- imports of individual files bypass the layer.
@@ -1,260 +0,0 @@
1
- # Explicit Column Layout
2
-
3
- ## Problem
4
-
5
- Actual CSS already provides several layout primitives with distinct responsive contracts:
6
-
7
- * `.grid` for intrinsic collections whose item width drives reflow;
8
- * `.grid-N` for equal-width structural collections with a known peer density;
9
- * `.switcher` for peer regions that must switch together between horizontal and stacked layouts;
10
- * `.sidebar-layout` for main content paired with a secondary region;
11
- * `.media` for media paired with flexible content.
12
-
13
- These primitives intentionally encode common layout relationships rather than exposing a general coordinate system.
14
-
15
- There is still one legitimate case they do not cover well: **explicit composition where the placement of individual regions is itself part of the design**.
16
-
17
- Examples include:
18
-
19
- * an 8-column main region beside a 4-column supporting region;
20
- * a centered 10-column article starting on column 2;
21
- * a 3 / 6 / 3 application shell;
22
- * editorial or dashboard compositions where regions must align to a shared column canvas.
23
-
24
- These layouts can be expressed with `--grid-columns` and application-specific `grid-column` rules, but that gives no shared canvas and makes every application redefine the same conventions — including the auto-placement trap described below.
25
-
26
- ## Decision
27
-
28
- An opt-in 12-column horizontal composition primitive, placed through two hooks on each direct child:
29
-
30
- ```css
31
- .column-layout {
32
- display: grid;
33
- gap: var(--gap);
34
- grid-template-columns: repeat(12, minmax(0, 1fr));
35
- }
36
-
37
- :where(.column-layout) > * {
38
- --column-start: initial;
39
- --column-span: initial;
40
-
41
- grid-column-start: var(--column-start, auto);
42
- grid-column-end: span var(--column-span, calc(13 - var(--column-start, 1)));
43
- min-inline-size: 0;
44
- }
45
- ```
46
-
47
- ```css
48
- .main {
49
- --column-span: 8;
50
- }
51
-
52
- .aside {
53
- --column-span: 4;
54
- }
55
- ```
56
-
57
- The public API is one class and two hooks. No responsive behavior is implied. No row placement, ordering, named areas, breakpoint variants, offsets, or configurable column counts are part of the primitive.
58
-
59
- ## Why hooks rather than placement classes
60
-
61
- A span and a start are two numbers. As classes they need twenty-four adapters (`.column-span-1` … `.column-start-12`) to encode CSS coordinates, and those adapters interact: a start class must also set the end line so it can stand alone, a span class must refine that end, and the only thing separating them at zero specificity is source order. The primitive then depended on a file order no browser reports when it breaks, guarded by a test whose only job was that order.
62
-
63
- As custom properties the two inputs are independent. One rule reads both, and there is nothing to order.
64
-
65
- Recomposition also stays inside the primitive's API. With classes, an application's container query had to leave the vocabulary and write `grid-column` itself. With hooks, it sets the same two properties the region was placed with.
66
-
67
- The API does not require inline styles. The documented form puts the hooks on an application class; `style="--column-span: 8"` is a shortcut for a composition that never changes. An inline value outranks every rule, so coordinates that a container query recomposes belong on a class.
68
-
69
- ## One rule, four placements
70
-
71
- ```text
72
- neither set start auto, span 12 auto-placed, full canvas
73
- span only start auto, span N auto-placed over N units
74
- start only start S, span 13 - S from line S to the canvas end
75
- start and span start S, span N explicit
76
- ```
77
-
78
- ### The start defaults to `auto`
79
-
80
- The obvious way to write "full canvas" is `grid-column: 1 / -1`. It gives every child a **definite** column start of line 1, which removes it from column auto-placement. Two placed peers then both resolve to column 1 and the second is pushed to the next row:
81
-
82
- ```text
83
- <section style="--column-span: 8"> row 1, columns 1-8
84
- <aside style="--column-span: 4"> row 2, columns 1-4 ← not 9-12
85
- ```
86
-
87
- Measured, not reasoned: the pair renders on two rows with a definite default start and on one row with an `auto` start, which `tests/browser/column-layout.test.js` asserts. Keeping the start `auto` until an author sets it lets auto-placement flow peers across the canvas.
88
-
89
- ### A start alone runs to the edge
90
-
91
- With a fixed `span 12` default, `--column-start: 9` would place a region across lines 9 to 21 and add nine implicit columns. The span fallback is therefore derived from the start, `calc(13 - start)`, so a start alone always ends on the canvas edge. With no start, the same expression resolves to `span 12`.
92
-
93
- `calc()` in an integer position resolves to a whole number once `var()` is substituted. Support for `calc()` in number contexts predates the CSS floor by years (Chrome 31, Firefox 48, Safari 6); the browser tests prove the four placements in Chromium.
94
-
95
- ### Coordinates are local to the grid item
96
-
97
- Custom properties inherit. A nested `.column-layout` placed with `--column-start: 3; --column-span: 8` would hand those values to each of its own children, which would all land on line 3.
98
-
99
- The reset is declared on each child, not on the canvas: the nested canvas needs its coordinates for its own position in the parent, and its children must start from nothing. `--column-start: initial` makes the property guaranteed-invalid, so `var()` takes its fallback. The rule has zero specificity, so any author rule on the child wins.
100
-
101
- `@property { inherits: false }` would express the same thing, but it is above the CSS floor and two declarations already do the job.
102
-
103
- ## Why this is separate from `.grid`
104
-
105
- `.grid` and `.grid-N` are collection primitives. They answer:
106
-
107
- > How many peer items should fit here?
108
-
109
- `.column-layout` answers a different question:
110
-
111
- > Where should these distinct regions sit on a shared composition canvas?
112
-
113
- A layout that happens to contain three regions is not automatically a column layout. If those regions are peers that should switch together, `.switcher` is the correct primitive. If one region is secondary to another, `.sidebar-layout` is usually the better choice.
114
-
115
- Use `.column-layout` because **placement is part of the design**, not merely because the design contains columns.
116
-
117
- | Need | Primitive |
118
- | ------------------------------------------------------ | ----------------- |
119
- | Independent repeated items with intrinsic reflow | `.grid` |
120
- | Equal-width peers with a known structural density | `.grid-N` |
121
- | Peer regions that must switch together | `.switcher` |
122
- | Main content with a secondary region | `.sidebar-layout` |
123
- | Media paired with flexible content | `.media` |
124
- | Explicit region placement on a shared 12-column canvas | `.column-layout` |
125
-
126
- > If local CSS mainly makes one layout primitive behave like another, reconsider the primitive before adding more CSS.
127
-
128
- ## Why twelve columns
129
-
130
- Twelve provides useful subdivisions without requiring a configurable grid system: `6 + 6`, `4 + 4 + 4`, `3 + 3 + 3 + 3`, `8 + 4`, `9 + 3`, `2 + 8 + 2`.
131
-
132
- A configurable `--column-count` would weaken the shared canvas: a span of 8 would mean different widths in different layouts, and the start-only fallback would need the count too. Applications that genuinely require a different track system should use `--grid-columns`.
133
-
134
- ## Base recipe
135
-
136
- `minmax(0, 1fr)` is an invariant, not responsive behavior. It prevents the track definition itself from creating a min-content floor that forces the layout wider than its container. It does **not** guarantee that arbitrary content remains usable inside a very narrow span; that is an application composition problem.
137
-
138
- The track template never reads `--gap`, so `gap` and the track count are independent at every width. This is worth stating because an author who has read the grid page will reasonably assume the opposite.
139
-
140
- ## Exceeding the canvas
141
-
142
- When combining a start and a span, the author keeps `start + span - 1 <= 12`. Actual CSS does not guard against invalid combinations, and the failure is worth stating precisely because it is not local.
143
-
144
- When a placement exceeds the explicit canvas, CSS Grid adds implicit columns at the end. `grid-auto-columns` defaults to `auto`, so an implicit column is sized by its content while the twelve `1fr` tracks divide whatever inline size is left. Every region shifts, not just the one carrying the invalid placement.
145
-
146
- A pair that does not fit *without* explicit starts wraps instead: two eight-unit regions occupy sixteen units, so the second moves to the next row. That is correct grid behavior, not a canvas violation.
147
-
148
- ## Responsive contract
149
-
150
- `.column-layout` has **no automatic responsive collapse**. Different compositions have different useful breakpoints:
151
-
152
- * `8 + 4` may remain useful longer than `3 + 9`;
153
- * a centered article may only need reduced side gutters;
154
- * a dashboard may recombine from three regions into two before eventually stacking;
155
- * an editorial layout may switch to a completely different representation on narrow screens.
156
-
157
- A single framework threshold would be arbitrary, and a hidden one would force authors to undo it before writing their own. The author owns narrow-container behavior, and writes it with the same hooks:
158
-
159
- ```css
160
- @container (width < 48rem) {
161
- .profile-main {
162
- --column-start: 1;
163
- --column-span: 6;
164
- }
165
-
166
- .profile-aside {
167
- --column-start: 7;
168
- --column-span: 6;
169
- }
170
- }
171
-
172
- @container (width < 32rem) {
173
- .profile-main,
174
- .profile-aside {
175
- --column-start: 1;
176
- --column-span: 12;
177
- }
178
- }
179
- ```
180
-
181
- The ability to recompose through intermediate states is part of the value of a coordinate system; the framework should not reduce every narrow layout to a single automatic stack.
182
-
183
- `.container-query` is not required by `.column-layout`. An author uses it because their own rules use `@container` — the author uses a query container because the author wrote a container query.
184
-
185
- ## Narrow containers
186
-
187
- With the default `--gap: 0.75rem` and a container measuring 279px at a 360px viewport, the eleven gaps take 132px. The twelve tracks divide the remaining 147px, roughly **12px per unit**: a four-unit region is 84px wide.
188
-
189
- That number is the argument. There is no useful composition to guess at that width, which is precisely why the primitive does not try. For intrinsic responsive behavior, prefer `.grid`, `.switcher`, or `.sidebar-layout`.
190
-
191
- ## One-dimensional scope
192
-
193
- Despite being implemented with CSS Grid, `.column-layout` exposes only horizontal column placement. There are no row, area, end-line, or order hooks. Applications remain free to use native CSS Grid where a genuinely two-dimensional composition requires it:
194
-
195
- ```css
196
- .dashboard-summary {
197
- grid-row: 1 / span 2;
198
- }
199
- ```
200
-
201
- Keeping the API one-dimensional prevents the primitive from growing into a general-purpose grid DSL.
202
-
203
- Visual reordering has consequences for reading order, keyboard navigation, and accessibility, and is not specific to this primitive. Authors should prefer DOM order that stays sensible when the composition changes.
204
-
205
- ## Direct-child box requirement
206
-
207
- Placement applies to grid items. A direct child carrying coordinates must generate a box: with `display: contents`, its own box is removed, its descendants become grid items, and the coordinates no longer control them.
208
-
209
- ## Why this is opt-in
210
-
211
- A general coordinate system is easy to misuse. Given `main + aside`, it is tempting to write an 8 + 4 composition even when `.sidebar-layout` already expresses the relationship with intrinsic responsive behavior. Likewise, three peer panels should not become three four-unit regions merely because the canvas makes that possible.
212
-
213
- The primitive belongs to the Layout family but is not part of the core baseline, and its documentation makes the selection boundary explicit.
214
-
215
- ## Rejected alternatives
216
-
217
- ### Placement classes (`.column-span-N`, `.column-start-N`)
218
-
219
- Rejected. Twenty-four classes encode two numbers, the start and span classes must be ordered in the source for a start alone to end on the canvas edge, and application recomposition has to leave the vocabulary to write `grid-column`. See [Why hooks rather than placement classes](#why-hooks-rather-than-placement-classes).
220
-
221
- ### Reset the hooks on the canvas
222
-
223
- Rejected. A nested canvas is also a grid item of its parent; resetting on `.column-layout` would erase the coordinates it needs for its own placement.
224
-
225
- ### `@property` with `inherits: false`
226
-
227
- Rejected for the base contract: above the CSS floor, and the per-child reset already keeps coordinates local.
228
-
229
- ### Make `.grid-N` support arbitrary spans
230
-
231
- Rejected. `.grid-N` represents structural peer density. Arbitrary child placement would blur the distinction between a collection and a composition canvas.
232
-
233
- ### Use `.layout-grid` or `.columns`
234
-
235
- Rejected. `.layout-grid` is confusing beside `.grid` and `.grid-N`; `.columns` is too generic and reads as CSS multi-column layout.
236
-
237
- ### Add `--column-count`
238
-
239
- Rejected. Twelve columns are part of the primitive's contract.
240
-
241
- ### Add automatic container-query collapse, breakpoint variants, or offsets
242
-
243
- Rejected. There is no universally correct threshold; breakpoint variants would move responsive strategy back into markup; `--column-start` already expresses native grid placement without a second, margin-based model.
244
-
245
- ### Add row placement, named areas, or ordering
246
-
247
- Rejected for this scope. Row placement and areas belong to native Grid on an application class; ordering carries separate accessibility concerns.
248
-
249
- ## Decision summary
250
-
251
- The primitive:
252
-
253
- * uses twelve equal `minmax(0, 1fr)` tracks;
254
- * places each direct child from `--column-start` and `--column-span`, in one rule;
255
- * keeps the start `auto` until set, so auto-placement composes spans;
256
- * derives the default span from the start, so a start alone ends on the canvas edge;
257
- * resets both hooks on each child, so coordinates never leak into a nested canvas;
258
- * provides no automatic responsive behavior and leaves recomposition to the application, through the same hooks;
259
- * remains horizontal-only;
260
- * complements rather than replaces `.grid`, `.grid-N`, `.switcher`, `.sidebar-layout`, and `.media`.
@@ -1,87 +0,0 @@
1
- # CSS anchor positioning
2
-
3
- Placement stays in JavaScript. This note records why, so the question is not
4
- reopened on browser-support figures alone.
5
-
6
- ## What owns placement today
7
-
8
- `@lekoala/floating` positions every anchored surface. `surface.js` calls
9
- `reposition()` for an element anchor and `repositionAt()` for a pointer
10
- coordinate, both inside an `autoUpdate()` loop.
11
-
12
- The positioner is not only a placement engine. It writes outputs the components
13
- read as ordinary CSS:
14
-
15
- ```text
16
- left / top the placement itself
17
- data-placement resolved side, after flip
18
- --arrow-x / --arrow-y arrow offset along the panel edge
19
- --available-height space left for the panel
20
- ```
21
-
22
- `tooltip.css` draws its arrow from `data-placement` and `--arrow-x/-y`;
23
- `flyout.css` caps its panel with `--available-height`. Replacing the engine
24
- means replacing those, not only the coordinates.
25
-
26
- ## The blocker is not support
27
-
28
- Support is the obvious gate and the wrong one. The blocking output is the one
29
- that is not CSS at all — the positioner's return value:
30
-
31
- ```js
32
- if (!positionSurface(menu)) closeSurface(menu); // surface.js
33
- ```
34
-
35
- `reposition()` returns `false` when positioning cannot be performed: a hidden
36
- floating element, a missing reference rect, an anchor outside the boundary, or
37
- a document with no browsing context. `surface.js` runs that check on every
38
- `autoUpdate` tick, so an anchor that leaves its boundary **closes** the surface.
39
-
40
- CSS anchor positioning offers no equivalent signal. `position-try-fallbacks`
41
- re-places the box and `position-visibility` can hide it, but hiding is not
42
- closing: no event fires, `.is-open` stays set, focus is never restored, and the
43
- Escape stack keeps an entry for a panel the user can no longer see.
44
-
45
- This is the boundary the manual Popover transport was adopted on, in the other
46
- direction — a capability takes one responsibility without being handed the
47
- neighbouring one. See [platform-alignment](platform-alignment.md).
48
-
49
- ## The pointer-coordinate case
50
-
51
- Context menus open at `clientX`/`clientY`, not at a DOM element
52
- (`context-menu.js` stores the point, `surface.js` passes it to
53
- `repositionAt()`). Anchor positioning anchors to elements, so this path needs a
54
- script layer whatever happens to the element-anchored one. Adoption would split
55
- the positioner in two rather than delete it.
56
-
57
- ## The one output with a declarative equivalent
58
-
59
- `--surface-anchor-width` is measured from the trigger's rect on every
60
- reposition, solely so a flyout can match its trigger's width. `anchor-size()`
61
- expresses that relationship directly and would remove both the measurement and
62
- the property.
63
-
64
- It is not free either: the panel would need an `anchor-name` on its trigger and
65
- a `position-anchor` written at runtime, which is the same plumbing the
66
- positioner already does. Worth doing only alongside a wider move, not as a
67
- standalone saving.
68
-
69
- ## What would unblock the move
70
-
71
- One of:
72
-
73
- - a script-observable anchor-visibility signal, so the lifecycle keeps its
74
- close decision while CSS takes the geometry; or
75
- - a deliberate contract change — an out-of-view surface hides instead of
76
- closing. That is a component decision, not a transport swap, and it has the
77
- same shape as the `popover="auto"` rejection in
78
- [popover-manual-poc](popover-manual-poc.md). It has been taken for tooltips,
79
- which have no focus restoration, event or Escape entry to lose — see
80
- [tooltip-coordinate-space](tooltip-coordinate-space.md).
81
-
82
- Browser support is a precondition for either, never the trigger on its own.
83
-
84
- ## Review trigger
85
-
86
- Revisit when a script-observable anchor-visibility signal appears, or when a
87
- project need makes hide-instead-of-close the wanted behavior.