actual-css 0.15.0 → 0.15.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.
@@ -33,9 +33,9 @@ the next card, belongs to the layout around it:
33
33
  A rule such as `.card + .card { margin-block-start: 2rem }` moves page layout
34
34
  into the component; put a composition around the cards instead.
35
35
 
36
- **A composition on a component takes over its default layout.** A component's
37
- own layout sits at zero specificity, so `<article class="card media">` lays out
38
- as a `.media` without an override, whatever the import order.
36
+ **A layout primitive replaces the component's default layout.** For example,
37
+ `<article class="card media">` keeps the card's appearance and uses `.media`
38
+ for its layout.
39
39
 
40
40
  **State uses the most semantic attribute; classes choose presentation.**
41
41
 
@@ -81,19 +81,6 @@ A component takes optional intent, variant and size classes:
81
81
  A modifier is a separate class that combines with others (`.btn.primary.soft`,
82
82
  not `.btn--primary`), and a part gets a prefixed class (`.alert-icon`,
83
83
  `.list-item-title`) only when its element does not already say what it is.
84
- There is no `__` or `--` in Actual's names, because:
85
-
86
- - **Modifiers are shared axes.** `.primary`, `.soft` and `.sm` mean the same
87
- thing on every component that supports them, so one class serves `.btn`,
88
- `.badge` and `.alert`. BEM names a modifier per block, which multiplies the
89
- vocabulary and keeps a custom intent such as `.tertiary` from working
90
- everywhere at once.
91
- - **State is not a modifier.** `disabled`, `aria-current` and `open` already
92
- name the state; a `--disabled` or `--active` class would duplicate them and
93
- drift out of sync.
94
- - **Elements come from HTML.** A card's `header` and `footer`, an avatar's
95
- `<img>` need no `__element` class; a prefixed class is kept for the parts
96
- HTML cannot name.
97
84
 
98
85
  Application CSS can use any convention, BEM included, alongside Actual's
99
86
  classes: `<article class="card pricing-plan pricing-plan--featured">`.
@@ -110,12 +97,11 @@ for a minimal Steps implementation.
110
97
 
111
98
  ## Intents
112
99
 
113
- `.primary`, `.secondary`, `.success`, `.warning`, `.danger` do not style elements directly. They only expose `--intent` and `--intent-fg`. Components and variants decide how to consume them.
100
+ `.primary`, `.secondary`, `.success`, `.warning`, and `.danger` choose a color
101
+ role. The component and variant decide how to display it.
114
102
 
115
- Intent classes define the current `--intent` value; they do not form a
116
- general-purpose color utility system. Use `.intent-color` when a simple element
117
- should consume the current intent as its foreground color. It works with an
118
- intent on the same element or inherited from an ancestor.
103
+ For plain text or an icon, add `.intent-color` to use the intent as its text
104
+ color. The intent can be on that element or an ancestor.
119
105
 
120
106
  ```html demo
121
107
  <button class="btn primary">Primary</button>
@@ -127,9 +113,7 @@ intent on the same element or inherited from an ancestor.
127
113
  </span>
128
114
  ```
129
115
 
130
- There is no `.btn-primary` or `.badge-success`. Intents are generic and reusable across any component that supports them.
131
-
132
- Components fall back to their own default intent when no intent class is set. Buttons, badges, and alerts use the neutral palette (`--neutral` / `--neutral-fg`) by default.
116
+ Without an intent class, components use their own default palette.
133
117
 
134
118
  Custom intents need no framework support — define `--intent` and `--intent-fg`
135
119
  (and `--intent-soft-fg` when the custom role needs its own soft foreground) on a
@@ -150,7 +134,8 @@ class:
150
134
 
151
135
  ## Variants
152
136
 
153
- `.solid`, `.soft`, `.outline`, `.surface` define the visual treatment by setting `--ui-bg`, `--ui-fg`, `--ui-border`. Components consume these tokens with sensible fallbacks. Interactive components also set a `--ui-hover-bg` recipe that their hover rule reads.
137
+ `.solid`, `.soft`, `.outline`, and `.surface` choose the visual treatment:
138
+ filled, tinted, outlined, or on the page surface.
154
139
 
155
140
  `.btn` defaults to `.solid`; `.badge` and `.alert` default to `.soft`.
156
141
 
@@ -168,37 +153,20 @@ class:
168
153
 
169
154
  ## Size and density
170
155
 
171
- `.sm` and `.lg` mean one size role below or above a component's natural size.
172
- Size names are shared roles, not shared measurements. Each participating
173
- component family maps them to its own optical scale: badges use `xs / sm / md`,
174
- while controls use `sm / md / lg`. Components without an explicit mapping do
175
- not change.
176
-
177
- A size role is applied to the component that participates in the scale and
178
- never styles arbitrary descendants. It propagates through token inheritance,
179
- though: components in the shared control scale set local `--control-size` and
180
- `--control-font-size`, and descendants consume them by their own rules. That is
181
- how `.field sm`, `.input-icon sm`, `.join sm`, and `.flyout sm` size the
182
- controls inside them, while a bare `.sm` on a plain element does nothing.
183
-
184
- `.compact` and `.spacious` establish inherited density tokens. Density arranges
185
- how tightly UI sits — spacing and component geometry — while font size and
186
- icon size stay unchanged. `.tight` and `.loose` change the rhythm (`--gap`)
187
- alone. Participation is opt-in, and a component only joins
188
- where density has an effect independent from its optical size: if the result is
189
- merely that the component looks smaller or larger, that is size, not density.
190
-
191
- Density participation takes three levels:
192
-
193
- - **Geometry + rhythm** — controls and their wrappers (`.field`, `.join`,
194
- `.flyout`, …). Height, padding, and gap respond; typography is untouched.
195
- - **Rhythm only** — content rows and shells such as `.list`. Spacing tightens
196
- (`--list-item-gap: var(--gap)`), but the structural size stays stable.
197
- - **No density effect** — components whose geometry is intrinsic to their
198
- content (`.badge`, `.avatar`, `.spinner`, `.rating`, `.key`, prose, inline
199
- `.choice`/`.switch`). Their optical size belongs to `sm`/`lg` or local hooks.
200
-
201
- As inherited contexts, one class tightens or loosens the whole subtree:
156
+ - **Size:** `.sm` and `.lg` change a component's text and geometry. Each
157
+ component has its own scale; the same size name does not mean the same
158
+ dimensions everywhere.
159
+ - **Density:** `.compact` and `.spacious` change spacing and control geometry
160
+ throughout a region, keeping text and icons at the same size.
161
+ - **Rhythm:** `.tight` and `.loose` change only the inherited gap.
162
+
163
+ Apply size to a supported component or control wrapper. For example,
164
+ `.field sm`, `.input-icon sm`, `.join sm`, and `.flyout sm` size the controls
165
+ inside them. `.sm` on a plain element has no effect.
166
+
167
+ Density affects controls and layout spacing. Badges, avatars, spinners,
168
+ ratings, keys, prose, and inline choices keep their own size. One density
169
+ class applies to the whole subtree:
202
170
 
203
171
  ```html demo
204
172
  <div class="compact stack">
@@ -229,12 +197,8 @@ affect the same dimension:
229
197
  </div>
230
198
  ```
231
199
 
232
- The density tokens are `--gap`, `--density-space`, `--control-size`, and
233
- `--control-pad-x`.
234
- Components consume the dimensions that make sense for them and opt out of the
235
- rest. The absolute `--space-*` scale is not rebound by density scopes.
236
- Components with bespoke geometry (`.badge`, `.avatar`,
237
- `.spinner`, `.rating`) own their local `.sm`/`.lg` mappings.
200
+ Density leaves the absolute `--space-*` scale unchanged. See
201
+ [Control tokens](tokens.md#controls) to customize the shared scale.
238
202
 
239
203
  `.compact` also remains a meaningful local modifier for `.card` and `.table`.
240
204
  On those components it tightens their own padding and establishes the compact
@@ -1,8 +1,7 @@
1
1
  # Theming
2
2
 
3
- Find the right lever when you want to change how a component or layout looks, without knowing in advance which custom property to use.
4
-
5
- This is a problem-oriented index. It maps common intents to the public hooks and primitives that express them, then points to the canonical section. It is not a catalogue of every variable — the CSS source remains canonical for exact defaults and fallback chains. See the tokens page, Public surface section, for the public/internal rule.
3
+ Find a common customization below, then follow the reference for examples and
4
+ hook details. See [Tokens](tokens.md) for global settings and the theme contract.
6
5
 
7
6
  ## I want to…
8
7
 
@@ -93,17 +92,16 @@ Keep the outline visible against the surrounding surface when changing colors.
93
92
 
94
93
  ### Keep bare native controls on-theme / accent-color
95
94
 
96
- Native controls that no component class restyles — a bare checkbox, radio, range, or `<progress>` — follow the theme through `accent-color: var(--primary)`, declared on `:root` and every `[data-theme]` island so each island recomputes it from its own palette. Component classes (`.check`, `.radio`, `.range`) paint their own rendering and do not read it.
95
+ Bare checkboxes, radios, ranges, and `<progress>` follow the theme through
96
+ `accent-color: var(--primary)`. Styled controls such as `.check`, `.radio`,
97
+ and `.range` use their own appearance.
97
98
 
98
99
  → Forms · Overview · Foundations · Tokens (theme contract)
99
100
 
100
101
  ### Store a theme name without applying it
101
102
 
102
- `data-theme` is an active theme boundary on every element that carries it, not
103
- a generic storage attribute. Use a different name such as `data-theme-value`,
104
- or a form control's `value`, when the element should only hold a theme name.
105
- Apply `data-theme` deliberately when that element and its subtree should paint
106
- with the selected palette — a theme swatch is a useful example.
103
+ `data-theme` applies a theme to the element and its subtree. To store a theme
104
+ name without applying it, use `data-theme-value` or a form control's `value`.
107
105
 
108
106
  ### Loading / busy overlay on a container
109
107
 
@@ -174,13 +172,10 @@ well as color.
174
172
 
175
173
  ### Dark mode toggle / theme switcher / remember the user's choice
176
174
 
177
- Actual CSS ships the mechanism, not the control. Without `data-theme` the page
178
- follows the OS; `data-theme="light"` or `"dark"` on `<html>` forces a scheme,
179
- and removing the attribute returns to the OS. The switcher UI and where the
180
- choice is stored belong to the application; a page with no setting already
181
- follows the OS. Apply a stored choice from an inline script in `<head>` so the
182
- first paint does not flash the OS scheme. The demo's theme picker is an
183
- inspection tool, not a component to copy.
175
+ The default theme follows the OS. Set `data-theme="light"` or `"dark"` on
176
+ `<html>` to force a scheme; remove the attribute to follow the OS again.
177
+ Build the switcher and store the preference in application code. Apply a saved
178
+ choice from an inline script in `<head>` to avoid a flash of the wrong scheme.
184
179
 
185
180
  ### Force light or dark on a theme that has both / theme and color scheme
186
181
 
@@ -235,12 +230,10 @@ step per role rather than importing the scale.
235
230
 
236
231
  ### Use a custom font / webfont / typeface with a theme
237
232
 
238
- A font belongs to the page, not to the theme. Load the face in the application
239
- stylesheet (`@font-face` or a font service) and set `--font-sans` (and
240
- `--font-mono`) on `:root`, never in a `[data-theme]` block: a theme switches at
241
- runtime and scopes to islands, so a font tied to it would change the text
242
- metrics of every island it touches. A display face for headings has no token:
243
- name it on the headings in application CSS.
233
+ Load fonts in the application stylesheet with `@font-face` or a font service.
234
+ Set `--font-sans` and `--font-mono` on `:root` so the type stays consistent
235
+ across theme changes and islands. Set a separate heading face directly in
236
+ application CSS:
244
237
 
245
238
  ```css
246
239
  :root {
@@ -261,17 +254,9 @@ reference material to copy into your own `[data-theme]` island — they are demo
261
254
  assets, not package entrypoints. Each sets the intent/surface/text tokens and
262
255
  lets the core derive everything else.
263
256
 
264
- The `gradient` example keeps a Bootstrap 4 style outer halo on focused fields
265
- instead of the core inset line. The `neo-brutalist` example puts a hard offset
266
- shadow on every standalone framed object (`--btn-shadow` for buttons, which
267
- lift on hover and press flat), keeps pastel intents in fills with contrasting
268
- ink, and turns the accordion marker into a plus. It is an invasive page skin:
269
- its descendant rules and inherited component hooks cross nested `data-theme`
270
- boundaries, so use a separate page to show another theme. Its `.join` groups
271
- fit their contents so the shadow follows the controls.
272
- The `material` example restyles
273
- fields as filled underlines with pill buttons — tokens plus three small rules,
274
- and `.join` still needs no adaptation. The `glass` example paints translucent
275
- surfaces over its own backdrop: it sets `--surface-opaque` and
276
- `--surface-solid-fg` to opaque values, raises `--soft-bg-mix` so soft fills stay
277
- light over glass, and adds the blur and an opaque busy veil as small rules.
257
+ - `gradient`: outer focus halos on fields.
258
+ - `neo-brutalist`: hard shadows, pastel fills, and plus-shaped accordion
259
+ markers. Use it as a page skin: its rules cross nested theme boundaries.
260
+ - `material`: filled underline fields and pill buttons.
261
+ - `glass`: translucent surfaces over a backdrop. Keep `--surface-opaque` and
262
+ `--surface-solid-fg` opaque, and check soft fills against the actual backdrop.
@@ -1,25 +1,23 @@
1
1
  # Tokens
2
2
 
3
- The public theming surface — small, semantic global tokens that make the library easy to restyle without understanding every component's internals.
4
-
5
- The surface stays small by keeping most tokens semantic, not component-specific.
6
-
7
- - Global tokens are public API.
8
- - Component-local tokens are implementation details unless documented by that component.
9
- - Components should map global tokens to local variables internally.
10
- - Themes override tokens, not selectors.
11
- - Defaults must work without modern color features or build tooling.
12
- - Modern enhancements can derive better values with `color-mix()`, `light-dark()`, or container queries.
3
+ Tokens are CSS custom properties for colors, spacing, shape, type, and motion.
4
+ Override global tokens to restyle the whole system; use documented component
5
+ hooks for local changes.
13
6
 
14
7
  ## Public surface
15
8
 
16
- Component custom properties fall into three header categories in the source: **Public hooks** (author-facing customization points), **Framework plumbing** (shared relays consumed across components — `--ui-*`, `--intent*`, `--density-*`), and **Internal** (derived, state/variant-owned, or runtime-written). Documentation focuses on discovering the right hook and on non-obvious usage; the CSS source remains canonical for exact defaults and fallback chains.
9
+ Global tokens and documented component hooks are public API. Shared relays,
10
+ derived values, and properties written by JavaScript are internal.
17
11
 
18
- As a convention, component-prefixed properties owned by the component's base rule are usually author hooks. Properties owned by states/variants, derived from other hooks, or written by JavaScript are not. This convention is indicative, not algorithmic: runtime-written, derived, and state-relay properties stay internal even when their form resembles a hook.
12
+ Component pages list the useful hooks and their relationships. CSS source
13
+ headers classify properties as **Public hooks**, **Framework plumbing**, or
14
+ **Internal** and provide exact defaults and fallback chains.
19
15
 
20
16
  ### Where a token is declared
21
17
 
22
- A hook is only defined inside the scope that declares it. Reading one outside that scope is not an error a browser reports: `var()` resolves to nothing, the whole declaration becomes invalid at computed-value time, and the property falls back to its initial value — `padding: var(--card-pad)` outside a card computes to `0`, silently.
18
+ Use global tokens in application CSS. Component hooks are available only in
19
+ their component's scope: outside a card, `padding: var(--card-pad)` can silently
20
+ compute to `0`. Supply a fallback when reading a hook outside its component.
23
21
 
24
22
  | Scope | Declared on | Examples |
25
23
  | --------- | --------------------------- | -------------------------------------- |
@@ -27,7 +25,8 @@ A hook is only defined inside the scope that declares it. Reading one outside th
27
25
  | Component | the component's base rule | `--card-pad`, `--drawer-size` |
28
26
  | Relay | a variant, state, or script | `--ui-bg`, `--intent`, `--surface-pad` |
29
27
 
30
- Global tokens are the ones to reach for in application CSS. Write a relay only to override what a variant sets on one element (Button · Variants); read one only where its owner documents it (`--bleed-pad`). When you do want a component token outside its component — matching a bare block to the card rhythm, say — give `var()` the default explicitly, so the declaration survives where the hook is absent:
28
+ Use relays only where documented, such as Button variants or `--bleed-pad`.
29
+ To match a bare panel to a card's padding:
31
30
 
32
31
  ```css
33
32
  .panel {
@@ -48,14 +47,12 @@ hands down. Instance geometry stops at every new instance; policy inherits.
48
47
  | Role policy | `--form-actions-justify`, `--frame-ratio` | yes |
49
48
  | Instance geometry | `--cluster-justify`, `--grid-columns` | no |
50
49
 
51
- Set instance geometry on the element itself (a class or inline style), and
52
- select nested instances to change them (`.toolbar > .cluster`). Set a policy
53
- once on the region or on `:root` that owns it. A new hook follows the same
54
- test: "how this element lays out" stops at the element, "what this context
55
- hands down" inherits. The stop needs the instance to read its own hook:
56
- `.switcher` and `.sidebar-layout` hooks are read by their children, and a
57
- nested instance that is itself such a child still needs its parent's value,
58
- so those keep inheriting.
50
+ Set instance geometry on the element itself, with a class or inline style.
51
+ Select nested instances explicitly to change them (`.toolbar > .cluster`).
52
+ Set inherited policies on a region or `:root`.
53
+
54
+ The layout hooks of `.switcher` and `.sidebar-layout` inherit because their
55
+ children consume them; check their component pages when nesting layouts.
59
56
 
60
57
  ### Color
61
58
 
@@ -117,7 +114,15 @@ their own colors.
117
114
 
118
115
  Use `*-fg` pairs only for solid backgrounds where the component controls both foreground and background. Do not require a foreground token for every surface token.
119
116
 
120
- Focus styling is outline-first. A global focus baseline draws a `--focus-ring-width` line in `--focus-outline-color`, offset by `--focus-outline-offset`: older browsers show it on `:focus`, while modern browsers limit it to `:focus-visible`. The baseline is a `currentColor` line, so text-like elements (links, `summary`, nav and menu items) follow whatever surface the application painted. Boxed components draw a solid `--focus-ring-width` line in `--focus`: inside the border box on text fields (`.input`, `.textarea`, `.select`), outside at `--focus-outline-offset` on actions (`.btn`, `.close`, choices, switches). The color never follows an intent or a local surface, so `--focus` must hold 3:1 against both `--surface` and `--surface-solid` — the page, fields and a solid band all rely on it. Both lines are `--focus-ring-width` wide. Under `forced-colors: active`, outlines map to the system focus color.
117
+ Focus uses an outline:
118
+
119
+ - Links, summaries, nav items, and menu items use `--focus-outline-color`.
120
+ - Text fields use `--focus` inside their border.
121
+ - Buttons, close controls, choices, and switches use `--focus` outside their border.
122
+
123
+ `--focus-ring-width` controls all these lines; `--focus-outline-offset` sets
124
+ the outside gap. Choose `--focus` with at least 3:1 contrast against both
125
+ `--surface` and `--surface-solid`. Forced colors use the system focus color.
121
126
 
122
127
  ```css
123
128
  :root {
@@ -137,15 +142,13 @@ writes `var(--focus-ring-width) solid var(--focus-outline-color)`.
137
142
 
138
143
  ### Palette coherence
139
144
 
140
- A coherent palette treats surfaces, text, borders, intents, and shadows as related roles rather than isolated colors.
141
-
142
- Coherence does not mean that every token must be chromatic. Pure or near-pure whites and blacks remain legitimate where their role calls for them; what matters is that the surrounding neutral ramp and derived treatments belong to the same visual family.
145
+ Choose surfaces, text, borders, intents, and shadows as one palette. Neutrals
146
+ may share an ambient hue; success, warning, and danger should remain
147
+ recognizable. These relationships are set in the theme values, not derived
148
+ from `--primary` at runtime.
143
149
 
144
- Neutral roles may lean toward the palette's ambient hue — by default the primary's — while lightness and chroma stay curated per role. Chroma runs strongest through the ramp's mid-lightness rungs, often around `--border` and `--text-muted` depending on the color scheme, and tapers toward both ends. A palette whose accent is deliberately warmer or cooler than its paper picks an ambient hue of its own.
145
-
146
- Semantic intents are curated colors, not mechanical derivatives of `--primary`. Danger, warning, and success stay recognizable for their function, but they are chosen as members of the theme palette rather than copied independently from a generic scale. Neither intents nor neutrals are derived from `--primary` at runtime: the relationship is a design decision recorded in the theme's own values.
147
-
148
- Color should reinforce structure and meaning, not carry them alone. Information hierarchy and semantic states should remain understandable when hue is removed or unavailable. Desaturating a composition is a useful review heuristic, not a conformance test.
150
+ Keep structure and state understandable without color. A grayscale review can
151
+ help reveal where labels, shapes, or other cues are missing.
149
152
 
150
153
  ### Default theme philosophy
151
154
 
@@ -188,7 +191,9 @@ A rule that re-derives a soft color reads it with the recipe's own fallback:
188
191
  mix. Both recipes are rendering-only — the baseline path below `color-mix()`
189
192
  keeps `var(--surface-subtle)` and `var(--border)`.
190
193
 
191
- `--soft-fg-mix` is the share of raw intent in soft *text*. At its `100%` default soft ink is the intent color itself, which is what a palette of dark, muted intents wants. A vivid or light palette cannot afford that: a soft badge then paints intent-tinted ink on an intent-tinted surface, and the two converge. Lowering the mix rebates the ink toward `--text`, which is the right direction in both schemes because `--text` is dark on a light theme and light on a dark one. Around `45%` a fully saturated palette recovers AA while the ink still reads as its intent.
194
+ `--soft-fg-mix` controls the share of intent color in soft text. Lower it to
195
+ move the text toward `--text` when a vivid or light intent lacks contrast.
196
+ Measure the result with `actual-css contrast`.
192
197
 
193
198
  Soft ink can also be corrected per role. The intent classes relay a per-role
194
199
  hook, and the soft recipe reads it before falling back to the global mix:
@@ -200,25 +205,18 @@ hook, and the soft recipe reads it before falling back to the global mix:
200
205
  intent class to its own `--*-soft-fg`.
201
206
  - `--soft-fg-mix` — the **global fallback derivation**, unchanged.
202
207
 
203
- **Soft foregrounds are calibrated against the darkest or closest interactive
204
- surface they are expected to appear on.** The tint is translucent, so the same
205
- pair reads differently on each surface — usually closest on `--surface-subtle`.
206
- For interactive soft treatments the fill moves toward the intent on hover
207
- (`--soft-hover-alpha`), so the binding pair is the *hovered* tint over
208
- `--surface-subtle` and the resting fill simply carries more margin; the default
209
- palette ships its own `--primary`/`--secondary`/… `-soft-fg` hooks to keep
210
- every pair ≥ 4.5:1 on `--surface`, `--surface-raised` and `--surface-subtle` in
211
- both color schemes, enforced by `tests/browser/soft-recipe.test.js`. The hard line stops at the default theme:
212
- presets and custom `[data-theme]` islands keep the `--soft-fg-mix` derivation
213
- unless they declare the hooks themselves (the framework resets them outside
214
- the default boundary). A theme that overrides the soft palette is responsible
215
- for preserving sufficient text contrast; `bunx --bun actual-css contrast --theme FILE`
216
- measures its resting and hovered pairs, composited on each of those surfaces.
217
-
218
- A theme whose primary should read more muted than its statuses sets only
219
- `--primary-soft-fg`, and every soft `.primary` foreground follows it. Without a
220
- `--*-soft-fg` the recipe resolves byte-identically to the old `--soft-fg-mix`
221
- derivation. A custom intent class provides the relay directly:
208
+ The default theme's soft text meets 4.5:1 contrast on `--surface`,
209
+ `--surface-raised`, and `--surface-subtle`, at rest and on hover in both schemes.
210
+ Custom themes must check their own pairs:
211
+
212
+ ```sh
213
+ bunx --bun actual-css contrast --theme src/theme.css
214
+ ```
215
+
216
+ Named themes fall back to `--soft-fg-mix` unless they declare per-role hooks.
217
+
218
+ Set `--primary-soft-fg` to change soft primary text without changing other
219
+ intents. A custom intent class provides its soft foreground directly:
222
220
 
223
221
  ```css
224
222
  .tertiary {
@@ -228,14 +226,6 @@ derivation. A custom intent class provides the relay directly:
228
226
  }
229
227
  ```
230
228
 
231
- **When an intent is tinted against a theme-controlled surface or border, the mix interpolates in `oklab`.** That covers the soft recipe, the checked `.choice-card` tint, and the `.overline.pill` border.
232
-
233
- Not because rectangular interpolation is more faithful to the intent hue — across the shipped presets it is a few degrees *less* faithful. A browser treats hue as powerless below a small chroma epsilon, so for the low-chroma surfaces and borders the presets actually use, a polar mix snaps cleanly onto the intent and wins.
234
-
235
- The reason is continuity. A theme owns `--surface` and `--border`, and may put them anywhere from achromatic to vivid. Under polar interpolation that range contains a cliff: below the epsilon the mix tracks the intent, above it the surface hue starts winning, and crossing it moves the result into a different color family — 116 degrees, a soft `.secondary` landing in the greens. Cartesian interpolation responds smoothly across the whole range a public token allows. A recipe that is only correct while an adopter's surface stays under an unstated, implementation-defined threshold is not a contract, so the framework trades a small continuous error for a predictable one. The present cost is imperceptible: the largest difference the rule introduces in any preset is 3/255 on one channel.
236
-
237
- Mixing against `black`, `white`, `transparent`, or `currentColor` is exempt and stays in `oklch`: those have no hue to interpolate, so both spaces give byte-identical results. Polar interpolation also stays legitimate where hue rotation is the point, such as sweeping a gradient through hues. `bun run check:color-space` enforces the rule for contextual tints and takes an `intentional-oklch` comment as an escape hatch.
238
-
239
229
  ### Shape
240
230
 
241
231
  Shape is intentionally small. Components can derive local radii from these.
@@ -268,7 +258,8 @@ Spacing should be useful without becoming a design-token encyclopedia.
268
258
  }
269
259
  ```
270
260
 
271
- Official steps are named in tens so the scale stays extensible. **Actual CSS will never define a `--space-*` token that is not a multiple of 10.** The intermediate names (`--space-15`, `--space-45`, …) are reserved for application-level interpolation: defining them is not writing into the framework namespace, it is using the half of the scale the framework has permanently given up.
261
+ Framework spacing names use multiples of 10. Intermediate names such as
262
+ `--space-15` and `--space-45` are reserved for application-defined steps.
272
263
 
273
264
  Use `em` for spacing that should scale with the component text size, such as button gaps and inline padding. Use `rem` for global rhythm, layouts, and fixed density.
274
265
 
@@ -421,7 +412,9 @@ Motion durations keep transitions consistent and easy to disable.
421
412
  }
422
413
  ```
423
414
 
424
- Ordinary interaction/state transitions have **no easing token**: they use the CSS default `ease` directly, and the dialog shake feedback plus the `actual-dialog` View Transition keep that default deliberately. The presence pair exists only for one-shot open/close where open and closed states own separate easing values (`.status-bar`/`.is-open`, `dialog.modal[open]`, `dialog.drawer[open]`): `--ease-enter` decelerates the appearance, `--ease-exit` accelerates the departure. The pair follows Material's standard rhythm; the emphasized-decelerate entrance is deliberately not offered because it only pays off at 250–400ms durations, beyond this vocabulary. Backdrops keep `ease` — a scrim only fades, it does not travel — but track their surface's duration. Toggles that share one transition list at `--duration-fast` (flyout, tooltip) also stay on `ease`: at 100ms the curve barely resolves and entry/exit cannot split on a single rule. These absences are deliberate, not gaps; a theme with a different motion character overrides `--ease-enter` / `--ease-exit`.
415
+ Use `--ease-enter` and `--ease-exit` to change how dialogs, drawers, and the
416
+ status bar appear and leave. Ordinary state transitions, flyouts, tooltips,
417
+ and backdrops use CSS `ease`.
425
418
 
426
419
  `reset.css` clamps raw animation and transition durations to `0.01ms`, resets their delays, and restores `html` scroll behavior under `prefers-reduced-motion: reduce`. Decorative loops effectively complete immediately without blanket-disabling animation support.
427
420
 
@@ -463,9 +456,13 @@ Under `forced-colors: active`, `--backdrop-fill` maps to `Canvas`.
463
456
 
464
457
  Two systems order overlays, and only one of them uses numbers.
465
458
 
466
- **The platform top layer** holds native `<dialog>` (modal, drawer) and every element currently showing as a popover — which, since the runtime drives flyouts, context menus and tooltips with `popover="manual"`, is all of Actual's anchored overlays. Top-layer ordering does not use `z-index`. Such an element always paints above the document, and its order among the others is its top-layer promotion order — the most recently promoted on top. A `z-index` declaration on it still computes; it just does not decide where it lands.
459
+ **The platform top layer** holds modal dialogs, drawers, and open popovers,
460
+ including runtime-managed flyouts, context menus, and tooltips. They appear
461
+ above the document, ordered by when they entered the top layer. `z-index`
462
+ does not change that order.
467
463
 
468
- **The document layer** is everything else, and the scale below is what orders it. Nothing in it can reach the other system: `z-index: 999999` on a document-layer element still paints under any open dialog or popover.
464
+ **The document layer** uses the scale below. Even a very high `z-index` stays
465
+ below the top layer.
469
466
 
470
467
  | Token | Value | Used by |
471
468
  | ------------ | ----- | ------------------------------- |
@@ -476,81 +473,38 @@ Two systems order overlays, and only one of them uses numbers.
476
473
  `.flyout` keeps the `--z-menu` declaration for a panel the runtime does not
477
474
  manage — one the platform has not promoted still stacks by number.
478
475
 
479
- `status-bar` is at the top of the document layer: above sticky bars and the FAB,
480
- and below any open dialog, menu or tooltip. That is the boundary between the
481
- two systems rather than a gap in the scale. Status messages are transient,
482
- non-critical feedback and their real contract is the live-region announcement
483
- — which is why `status.js` moves the singleton into an open modal dialog's
484
- subtree, since a modal inerts the rest of the document and promotion would not
485
- undo that.
476
+ The status bar sits above sticky bars and the FAB, and below the top layer.
477
+ For messages from a modal dialog, the runtime temporarily moves it inside the
478
+ dialog so the message remains visible and announced.
486
479
 
487
- Stacking-context traps: these apply to overlays painted in the page, not to promoted ones. An element that is a DOM descendant of a container with `transform`, `filter`, `contain`, `isolation`, or `will-change` is confined to that ancestor's stacking context, and its z-index token only orders it against siblings within that context. Promotion escapes all of it — but do not move the markup to chase the effect: a panel or tooltip used from inside a modal dialog must be authored *inside* that dialog, because the top layer does not lift an element out of a modal's inertness.
480
+ Document overlays can be confined by ancestor stacking contexts, such as those
481
+ created by `transform` or `isolation`. Top-layer overlays escape these contexts.
482
+ A panel or tooltip used in a modal dialog still needs to be authored inside
483
+ that dialog; promotion does not remove modal inertness.
488
484
 
489
485
  Scrollbar gutter: modal open/close can shift page layout when the classic scrollbar disappears. When a measured scrollbar is present, `modal.css` applies `scrollbar-gutter: stable` to the viewport so the page doesn't jump.
490
486
 
491
487
  ## Internal tokens
492
488
 
493
- Internal tokens are allowed when they reduce duplication or make component code clearer.
494
-
495
- ### Variant plumbing
496
-
497
- The shared visual variants are:
498
-
499
- - `.solid`: full background, paired foreground. This is the default for buttons.
500
- - `.soft`: lightly tinted background, colored text. Good for alerts, badges, and secondary actions.
501
- - `.outline`: transparent background, colored border and text.
502
- - `.surface`: the page surface with the theme border, and the intent only in the text. The neutral chrome neither `.soft` (the intent-tinted treatment) nor `.outline` (no fill) can give.
503
-
504
- Buttons also support two button-only variants:
505
-
506
- - `.ghost`: transparent button with hover affordance.
507
- - `.link`: button semantics with link presentation.
508
-
509
- Do not force `.ghost` or `.link` onto components where the interaction model does not fit. Shared API should follow shared use.
510
-
511
- Components map global tokens to local aliases once at the top of the component and consume local tokens afterwards:
512
-
513
- ```css
514
- .btn {
515
- --btn-bg: var(--ui-bg, var(--btn-default-bg, var(--intent, var(--neutral))));
516
- --btn-fg: var(--ui-fg, var(--btn-default-fg, var(--intent-fg, var(--neutral-fg))));
517
- --btn-border: var(--ui-border, var(--btn-default-border, transparent));
518
-
519
- border: var(--border-width) solid var(--btn-border-color, var(--btn-border));
520
- border-block-end-color: var(
521
- --btn-border-block-end-color,
522
- var(--btn-border-color, var(--btn-border))
523
- );
524
- border-block-end-width: var(--btn-border-block-end-width, var(--border-width));
525
- }
526
- ```
527
-
528
- The `--btn-*` fallbacks are intentionally inherited extension points for themes that change button grammar — such as turning the default solid button into a surface button with an intent-colored lower edge (the `edge` theme does exactly this). Keep them local until the same need appears across multiple components.
529
-
530
- Text controls (`.input`/`.textarea`/`.select`) expose the same lower-edge extension point: `--control-border-block-end-color` and `--control-border-block-end-width` are unset by default and fall back to the regular border, so a theme can give inputs an underline-style lower edge the same way, without fighting the hover/focus/disabled state rules that still own `--control-border` itself.
531
-
532
- Alerts expose the same idea on the leading edge instead of the lower one: `--alert-border-inline-start-color` and `--alert-border-inline-start-width` are unset by default and fall back to the regular `--ui-border`, so a theme can turn an alert into a callout with a colored flag on the inline-start side, matching the classic notice pattern, without a per-variant override.
533
-
534
- A theme is not limited to the tokens above; it can restate any component-local token or rule under a state selector to change the interaction recipe itself, not just the palette. The `gradient` theme does this for field focus: it restores a `--focus` border plus an outer translucent halo in place of the core inset outline.
535
-
536
- Rules:
537
-
538
- - Prefix internal component tokens with the component name (`--btn-*`, `--alert-*`, `--card-*`).
539
- - Prefix shared variant plumbing with `--ui-*`.
540
- - The shared relays `--ui-*`, `--intent*`, and `--density-*` are framework plumbing: they are classified once at framework level, not restated in every component file.
541
- - Keep component-specific variants in component code when they do not generalize.
542
- - `flush` is a shared modifier: it removes the component's outer chrome so the component sits directly inside an existing surface (`.accordion.flush`). Reuse the term one component at a time when the same integration need appears elsewhere; `separated` stays component-local until a second real consumer exists.
543
- - Do not require users to override internal tokens for ordinary theming.
544
- - Promote an internal token to public only when there is a repeated, reasonable customization need.
545
- - A custom property used only in a fallback position (`var(--x, default)`) and never declared is an unset extension point and must carry a classification — public, framework plumbing, or internal. `check:css-api` fails on any unclassified fallback-only property; it does not force an artificial declaration to satisfy the audit.
489
+ The framework uses `--ui-*` and `--intent*` to connect variants and components.
490
+ Use the documented component hooks for ordinary customization.
546
491
 
547
492
  ## Theme contract
548
493
 
549
494
  Themes override tokens, not selectors. The themes in `src/css/themes/` are repository-only demo examples, not included in the default stylesheet or the npm package; they exist to show valid ways to use this contract, such as `ocean`, `square`, `cyberpunk`, and `brutalist`.
550
495
 
551
- A minimal recolor theme overrides the intent pairs, surfaces, text colors, border, focus, hover overlay, and shadow color. Pick `--focus` as a mid-tone that holds 3:1 against both `--surface` and `--surface-solid` in every scheme the theme declares; a pastel dark-scheme primary usually fails on the light solid surface. `bunx --bun actual-css contrast --theme FILE` measures both pairs, and exits 1 when a pair misses. The file may declare a `[data-theme]` island or set the tokens on `:root`; the tool reads each scheme through `color-scheme`, so write dark values with `light-dark()` — a `prefers-color-scheme` media block is not measured.
496
+ A recolor theme sets intent pairs, surfaces, text, border, focus, hover overlay,
497
+ and shadow color. Check it with `bunx --bun actual-css contrast --theme FILE`;
498
+ the command exits 1 when a measured pair fails. In particular, `--focus` needs
499
+ 3:1 contrast against both `--surface` and `--surface-solid` in every scheme.
500
+
501
+ The file can use `[data-theme]` or `:root`. The checker reads schemes through
502
+ `color-scheme`: express dark values with `light-dark()`. It does not measure
503
+ `prefers-color-scheme` media blocks.
552
504
 
553
- When overriding an intent color, review its paired `--*-fg` and `--*-soft-fg`. A theme that declares no hook falls back to the `--soft-fg-mix` derivation: one global percentage applied to every role, so it carries no contrast guarantee for a palette it was not tuned against. `actual-css contrast` prints the resting and hovered soft pair for every intent in every scheme the theme declares, which is how a theme finds the roles that need a hook or a lower `--soft-fg-mix`.
505
+ When changing an intent, check its `--*-fg` and `--*-soft-fg` too. The contrast
506
+ report includes resting and hovered soft pairs for each intent and scheme.
507
+ Adjust failing roles with a per-role hook or a lower `--soft-fg-mix`.
554
508
 
555
509
  The default palette's hooks apply to `:root` and to the `light`/`dark` boundaries only. Any other `data-theme` value resets them to the derivation, whether the attribute sits on `<html>` or on a nested island.
556
510
 
@@ -607,7 +561,9 @@ A minimal recolor theme (illustrative, not a shipped theme):
607
561
  }
608
562
  ```
609
563
 
610
- Several tokens are theme-derived aliases that reference other tokens — `--state-selected`/`--state-selected-fg`/`--state-disabled`, `--indicator-ring`, `--shadow`/`--shadow-popout`, `--heading`, `--selection-bg`/`--selection-fg`, and `--surface-opaque`/`--surface-solid-fg`. They are declared on `:root, [data-theme]` so they recompute on every theme boundary: a custom property resolves its `var()` references at computed-value time on the element that declares it, so an alias declared only on `:root` would be inherited as an already-resolved value and would not follow a `[data-theme]` island's overridden tokens. A theme that wants a distinct alias (e.g. a `--selection-bg` of its own) overrides it explicitly afterwards, which wins by cascade order.
564
+ Derived tokens, including shadows, headings, selection colors, and state
565
+ colors, recompute at each theme boundary. To customize one, declare it in your
566
+ theme after Actual CSS.
611
567
 
612
568
  Selected state has three roles:
613
569
 
@@ -615,7 +571,9 @@ Selected state has three roles:
615
571
  - `--state-selected-fg` — ink on that fill.
616
572
  - `--state-selected-text` — selected ink on a regular surface: the current nav link, the selected tab, the current step's number and ring.
617
573
 
618
- `--state-selected-text` has no default: the core resets it to the guaranteed-invalid value on every theme boundary, and each consumer reads `var(--state-selected-text, var(--state-selected))`. The reset is what lets a nested theme island reach its own `--state-selected`: a theme that resolves the hook to another token bakes the reference where it is declared, so an island that sets nothing would otherwise inherit the resolved value and never fall back. Set it when one color cannot be both a fill under its `-fg` and text on the page — typically a dark scheme, where a fill dark enough for white ink is too dark to read as text. Pulling the accent toward `--text` keeps its hue in both schemes:
574
+ `--state-selected-text` falls back to `--state-selected` within each theme.
575
+ Set it separately when the selected fill lacks contrast as text, especially
576
+ in a dark scheme. Mixing the accent toward `--text` can help:
619
577
 
620
578
  ```css
621
579
  [data-theme="my-theme"] {
@@ -630,39 +588,13 @@ Selected state has three roles:
630
588
 
631
589
  Without `data-theme`, the default theme advertises `color-scheme: light dark` and follows the user's OS preference in browsers that support `light-dark()`. Dark themes should set `color-scheme: dark`. Light themes should set `color-scheme: light`. Browsers without `light-dark()` receive the light fallback.
632
590
 
633
- Because the native select chevron is an SVG background image and cannot inherit `currentColor`, the select hands the arrow back to the browser under `prefers-contrast: more` (same treatment as `forced-colors: active`) instead of shipping a recolored chevron per theme — one native fallback covers every theme without a high-contrast icon variant to maintain.
591
+ Selects use the browser's native arrow under `prefers-contrast: more` and
592
+ `forced-colors: active`.
634
593
 
635
- Under `prefers-contrast: more`, the user's contrast preference wins over a theme's palette by contract: the core collapses `--text-muted`/`--text-subtle` to `--text` and thickens borders and focus so no theme can defeat a legibility requirement. This is a deliberate decision, not a specificity quirk — the repeated `[data-theme][data-theme]` attribute only outranks a preset theme stylesheet loaded after the core.
594
+ Under `prefers-contrast: more`, muted and subtle text use `--text`, and borders
595
+ and focus lines thicken. Keep these accessibility adjustments when customizing
596
+ a theme.
636
597
 
637
598
  Under `prefers-reduced-transparency: reduce`, `.topbar` and `.form-actions.sticky` paint `--surface` without a backdrop blur. A theme with translucent `--surface-*` redeclares them opaque inside the same media query; the glass demo theme shows the recipe.
638
599
 
639
600
  Under `forced-colors: active`, the browser automatically remaps `color`, `background`, and `border` properties to system colors. The core only adjusts what the remapping cannot express on its own — `--state-disabled` becomes `GrayText` and `--disabled-opacity` becomes `1` — declared on `:root` and `[data-theme]` so every theme boundary follows. Keep local forced-color rules only for custom control geometry, native bar parts, or selected/checked states that would otherwise be communicated only by background color.
640
-
641
- ## Component mapping
642
-
643
- Components map global tokens to local aliases at the top of the component, then use the local tokens afterwards. This makes the contract obvious:
644
-
645
- ```css
646
- .alert {
647
- --alert-bg: var(--ui-bg, var(--surface-subtle));
648
- --alert-fg: var(--ui-fg, var(--intent, var(--text)));
649
- --alert-border: var(--ui-border, var(--border));
650
-
651
- border: var(--border-width) solid var(--alert-border);
652
- border-radius: var(--alert-radius, var(--radius-lg));
653
- background: var(--alert-bg);
654
- color: var(--alert-fg);
655
- }
656
- ```
657
-
658
- - theme authors adjust global tokens
659
- - variant code adjusts `--ui-*`
660
- - component code consumes local aliases
661
-
662
- ## Non-goals
663
-
664
- - Do not expose a separate token for every selector.
665
- - Do not mirror Pico-style component-specific variables unless there is a clear need.
666
- - Do not add Tailwind-like color scales as public API.
667
- - Do not rely on Sass, PostCSS, or generated token files.
668
- - Do not make dark mode required for old browsers. Light mode is the fallback.