actual-css 0.14.1 → 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.
- package/CHANGELOG.md +48 -0
- package/README.md +4 -4
- package/components.json +51 -6
- package/dist/actual.full.css +380 -32
- package/dist/actual.full.js +1 -1
- package/dist/actual.full.min.css +1 -1
- package/docs/design-notes/architecture.md +3 -0
- package/docs/design-notes/enhancement-contract.md +14 -0
- package/docs/design-notes/naming.md +6 -0
- package/docs/design-notes/steps.md +13 -2
- package/docs/design-notes/tokens.md +159 -0
- package/docs/navigation.json +4 -1
- package/docs/pages/components/accordion.md +15 -18
- package/docs/pages/components/avatar.md +1 -0
- package/docs/pages/components/badge.md +41 -5
- package/docs/pages/components/button.md +32 -7
- package/docs/pages/components/card.md +40 -7
- package/docs/pages/components/diagrams.md +96 -0
- package/docs/pages/components/steps.md +31 -17
- package/docs/pages/components/table.md +4 -0
- package/docs/pages/components/timeline.md +111 -0
- package/docs/pages/enhancements/overview.md +13 -20
- package/docs/pages/enhancements/status-bar.md +7 -9
- package/docs/pages/enhancements/tabs.md +59 -21
- package/docs/pages/enhancements/tooltip.md +10 -19
- package/docs/pages/examples/overview.md +3 -0
- package/docs/pages/forms/choice-cards.md +3 -0
- package/docs/pages/forms/combobox.md +34 -19
- package/docs/pages/forms/controls.md +2 -0
- package/docs/pages/forms/date-picker.md +34 -13
- package/docs/pages/forms/file-upload.md +120 -0
- package/docs/pages/forms/joined-controls.md +4 -2
- package/docs/pages/forms/overview.md +8 -0
- package/docs/pages/foundations/philosophy.md +32 -62
- package/docs/pages/foundations/theming.md +63 -26
- package/docs/pages/foundations/tokens.md +91 -159
- package/docs/pages/foundations/typography.md +3 -0
- package/docs/pages/guides/integrating-actual-css.md +1 -1
- package/docs/pages/guides/introduction.md +14 -14
- package/docs/pages/guides/modular-import.md +124 -0
- package/docs/pages/guides/upgrading.md +63 -0
- package/docs/pages/layout/choosing.md +10 -16
- package/docs/pages/layout/grid.md +8 -16
- package/docs/pages/patterns/intent-nesting.md +13 -1
- package/package.json +2 -2
- package/reserved-classes.json +3 -0
- package/src/css/components/accordion.css +7 -3
- package/src/css/components/alert.css +9 -1
- package/src/css/components/app-nav.css +2 -0
- package/src/css/components/badge.css +38 -11
- package/src/css/components/button.css +10 -2
- package/src/css/components/card.css +9 -0
- package/src/css/components/index.css +1 -0
- package/src/css/components/skeleton.css +11 -0
- package/src/css/components/tab.css +77 -0
- package/src/css/components/table.css +7 -1
- package/src/css/components/timeline.css +160 -0
- package/src/css/core/base.css +13 -2
- package/src/css/core/reset.css +5 -0
- package/src/css/core/theme.css +6 -1
- package/src/css/core/tokens.css +3 -3
- package/src/css/forms/choice-card.css +5 -2
- package/src/css/forms/control.css +12 -3
- package/src/css/forms/custom-select.css +1 -1
- package/src/css/typography/prose.css +4 -2
- package/src/tooling/design-tokens.js +2 -0
- package/src/tooling/theme-contrast.js +1 -1
|
@@ -58,28 +58,49 @@ date-calendar {
|
|
|
58
58
|
--dp-accent: var(--primary);
|
|
59
59
|
--dp-accent-fg: var(--primary-fg);
|
|
60
60
|
--dp-radius: var(--radius);
|
|
61
|
+
--dp-focus: var(--focus);
|
|
62
|
+
--dp-focus-width: var(--focus-ring-width);
|
|
61
63
|
/* Trigger glyph on the select chevron axis. */
|
|
62
64
|
--dp-picker-button-size: calc(var(--control-pad-x) * 2 + 1em + var(--border-width) * 2);
|
|
63
65
|
}
|
|
64
66
|
|
|
65
|
-
.dp-
|
|
66
|
-
|
|
67
|
-
outline: var(--focus-ring-width) solid var(--focus);
|
|
68
|
-
outline-offset: calc(var(--focus-ring-width) * -1);
|
|
69
|
-
box-shadow: none;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
.dp-picker-button:focus-visible,
|
|
73
|
-
.dp-day:focus-visible {
|
|
74
|
-
outline-color: var(--focus);
|
|
67
|
+
.dp-picker-panel[popover] {
|
|
68
|
+
box-shadow: var(--shadow-popout);
|
|
75
69
|
}
|
|
76
70
|
```
|
|
77
71
|
|
|
78
|
-
The
|
|
79
|
-
the
|
|
80
|
-
|
|
72
|
+
The picker draws focus as an inset line, like the core, so `--dp-focus` and
|
|
73
|
+
`--dp-focus-width` are the whole focus mapping; the field itself is a plain
|
|
74
|
+
`.input` and keeps the core outline. The panel has no shadow token, so it takes
|
|
75
|
+
`--shadow-popout` directly. It opens as a popover, in the top layer,
|
|
76
|
+
so inside a modal, even in a scrolling body, it is neither clipped nor stacked
|
|
77
|
+
under the dialog. The calendar popup is its own
|
|
81
78
|
element, so the `--dp-*` map is declared on `date-picker`/`date-calendar` rather
|
|
82
79
|
than inherited from a wrapper.
|
|
80
|
+
|
|
81
|
+
The header month, year and arrows take host classes through `controlClasses`,
|
|
82
|
+
so they render as real Actual controls:
|
|
83
|
+
|
|
84
|
+
```js
|
|
85
|
+
picker.controlClasses = { month: "select sm", year: "input sm", nav: "btn outline sm icon-only" };
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Set the defaults once for every picker and inline calendar. With the CDN script,
|
|
89
|
+
call the registered constructor after the deferred script has loaded:
|
|
90
|
+
|
|
91
|
+
```js
|
|
92
|
+
customElements.get("date-picker").setDefaultControlClasses({
|
|
93
|
+
month: "select sm",
|
|
94
|
+
year: "input sm",
|
|
95
|
+
nav: "btn outline sm icon-only",
|
|
96
|
+
});
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
With a bundler, import `setDefaultControlClasses` from `@lekoala/date-picker`.
|
|
100
|
+
An instance's `controlClasses` overrides only the supplied roles; omitted roles
|
|
101
|
+
follow the current defaults. Day cells and the field trigger stay on the
|
|
102
|
+
`--dp-*` tokens.
|
|
103
|
+
|
|
83
104
|
As with the combobox, the bridge stays in docs/demo — it is a recipe, not package
|
|
84
105
|
API, and pins no widget version.
|
|
85
106
|
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# File upload
|
|
2
|
+
|
|
3
|
+
> An upload widget is not shipped by the framework — the native `.file` input stays the baseline. Compose Dropzone's rows from Actual components, or theme FilePond with Actual tokens.
|
|
4
|
+
|
|
5
|
+
The native input is the default: it submits with the form and needs no
|
|
6
|
+
JavaScript. Reach for an uploader when the product needs drag and drop,
|
|
7
|
+
previews, progress, or asynchronous and chunked uploads.
|
|
8
|
+
|
|
9
|
+
**Related terms:** file upload, uploader, file input, drag and drop, drop zone, dropzone, attachments, upload progress, file preview, FilePond.
|
|
10
|
+
|
|
11
|
+
## Native baseline
|
|
12
|
+
|
|
13
|
+
```html demo
|
|
14
|
+
<label class="field">
|
|
15
|
+
<span class="field-label">Profile picture</span>
|
|
16
|
+
<input class="file" type="file" accept="image/*" />
|
|
17
|
+
</label>
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
See [Controls](controls.md#file) for what `.file` styles.
|
|
21
|
+
|
|
22
|
+
## Dropzone: rows from Actual components
|
|
23
|
+
|
|
24
|
+
The [file upload template](../../demo/templates/file-upload.html) puts the
|
|
25
|
+
native input, [Dropzone](https://docs.dropzone.dev/) and FilePond side by side.
|
|
26
|
+
Dropzone owns drop, queue and requests; its stylesheet is not loaded. Its
|
|
27
|
+
`previewTemplate` is plain markup, so each file renders as a `.list-item`, and
|
|
28
|
+
Dropzone fills the `data-dz-*` slots:
|
|
29
|
+
|
|
30
|
+
```html
|
|
31
|
+
<template id="upload-row">
|
|
32
|
+
<li class="list-item">
|
|
33
|
+
<span class="avatar"><span data-dz-ext aria-hidden="true"></span><img data-dz-thumbnail alt="" hidden></span>
|
|
34
|
+
<span class="list-item-content">
|
|
35
|
+
<strong class="list-item-title truncate" data-dz-name></strong>
|
|
36
|
+
<span class="list-item-text" data-dz-size></span>
|
|
37
|
+
<span class="list-item-text"><span class="danger intent-color" data-dz-errormessage></span></span>
|
|
38
|
+
<progress class="progress" value="0" max="100" data-dz-uploadprogress></progress>
|
|
39
|
+
</span>
|
|
40
|
+
<button class="close" type="button" aria-label="Remove file" data-dz-remove></button>
|
|
41
|
+
</li>
|
|
42
|
+
</template>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
```js
|
|
46
|
+
const dropzone = new Dropzone(zone, {
|
|
47
|
+
url: "/upload",
|
|
48
|
+
clickable: zone.querySelector("button"), // a real button, not the whole zone
|
|
49
|
+
previewsContainer: "#upload-list", // a <ul class="list">
|
|
50
|
+
previewTemplate: document.getElementById("upload-row").innerHTML,
|
|
51
|
+
});
|
|
52
|
+
dropzone.on("success", (file) => file.previewElement.querySelector("progress").classList.add("success"));
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Dropzone sets the value of a `<progress>` slot, so `.progress` works as is.
|
|
56
|
+
Outcomes take intent classes from event listeners rather than styling
|
|
57
|
+
Dropzone's `dz-success` and `dz-error` classes. The thumbnail starts
|
|
58
|
+
`hidden` and a `thumbnail` listener reveals it; until then the avatar shows
|
|
59
|
+
the file extension.
|
|
60
|
+
|
|
61
|
+
The drop target is the one piece left to draw: a dashed `--border-control`
|
|
62
|
+
outline on `--surface-subtle`, with a `.dz-drag-hover` rule (Dropzone writes
|
|
63
|
+
the class while files hover the zone). Put a native `.file` input in the zone
|
|
64
|
+
for the no-JavaScript case and remove it at init, as the template does:
|
|
65
|
+
Dropzone appends its own hidden input to `<body>`.
|
|
66
|
+
|
|
67
|
+
## FilePond: theme bridge
|
|
68
|
+
|
|
69
|
+
[FilePond v5](https://v5.filepond.com/) is a `<file-pond>` web component that
|
|
70
|
+
wraps a native input and renders its own UI in a shadow root. Its
|
|
71
|
+
`--default-*` properties inherit into that root, so the bridge is one rule:
|
|
72
|
+
|
|
73
|
+
```html
|
|
74
|
+
<div class="field">
|
|
75
|
+
<label class="field-label" for="attachments">Attachments</label>
|
|
76
|
+
<file-pond>
|
|
77
|
+
<input class="file" id="attachments" type="file" name="attachments" multiple>
|
|
78
|
+
</file-pond>
|
|
79
|
+
</div>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
```css
|
|
83
|
+
file-pond {
|
|
84
|
+
--default-color: var(--text);
|
|
85
|
+
--default-background-color: var(--surface-subtle);
|
|
86
|
+
--default-accent-color: var(--primary);
|
|
87
|
+
--default-accent-color-text: var(--primary-fg);
|
|
88
|
+
--default-border: var(--border-width) solid var(--border-control);
|
|
89
|
+
--default-border-radius: var(--radius);
|
|
90
|
+
--default-padding: var(--space-40);
|
|
91
|
+
--outline: var(--focus-ring-width) solid var(--focus);
|
|
92
|
+
display: block;
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
```js
|
|
97
|
+
import { defineFilePond } from "filepond";
|
|
98
|
+
import { locale } from "filepond/locales/en-gb.js";
|
|
99
|
+
|
|
100
|
+
defineFilePond({ locale });
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
FilePond reads `color-scheme` for everything the map leaves out, so light,
|
|
104
|
+
dark and `data-theme` islands need no second rule. Font and line height
|
|
105
|
+
inherit from the page. `--outline` is not documented by FilePond: it is the
|
|
106
|
+
property every focus-visible outline inside the component reads, and mapping
|
|
107
|
+
it gives the browse button and entry buttons the framework focus line. The
|
|
108
|
+
host is `inline-block` by default; `display: block` makes the drop area span
|
|
109
|
+
its field. For deeper changes, FilePond exposes `::part()` hooks and a
|
|
110
|
+
template API; the template does not need them.
|
|
111
|
+
|
|
112
|
+
FilePond v5 is in beta: pin an exact version (`npm install filepond@beta`).
|
|
113
|
+
|
|
114
|
+
Both bridges stay in docs/demo — they are recipes, not package API.
|
|
115
|
+
|
|
116
|
+
## Which one?
|
|
117
|
+
|
|
118
|
+
- A form that posts a few files: native `.file`.
|
|
119
|
+
- Drag and drop, previews and progress in your own markup: Dropzone with an Actual `previewTemplate`.
|
|
120
|
+
- A complete uploader UI (media previews, image editing, camera, chunked uploads): FilePond on the token bridge.
|
|
@@ -17,9 +17,11 @@ choice among a few on a shared track, use a
|
|
|
17
17
|
|
|
18
18
|
Add `.join` to the wrapper that groups the controls. Use `.join-addon` for static prefix/suffix content such as currency symbols, units, or protocol text. Action buttons inside the group should use `.btn`. The wrapper should still carry `role="group"` with a label for accessibility.
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
Each child keeps its own variant. Use the same variant across the group, and
|
|
21
|
+
change it only to mark state, such as a solid pressed toggle among outlines.
|
|
21
22
|
|
|
22
|
-
When composing source files manually, import `components/join.css` after the
|
|
23
|
+
When composing source files manually, import `components/join.css` after the
|
|
24
|
+
controls it groups so joined corners take precedence.
|
|
23
25
|
|
|
24
26
|
```html demo
|
|
25
27
|
<div class="field">
|
|
@@ -172,9 +172,17 @@ A full form using the control classes, field wrappers, and form actions:
|
|
|
172
172
|
|
|
173
173
|
## Hooks
|
|
174
174
|
|
|
175
|
+
Set `--control-default-bg` on a theme or region for an inherited resting field
|
|
176
|
+
background shared by `.input`, `.textarea`, `.select` and external widget bridges.
|
|
177
|
+
Use `--control-bg` for a local field override; state rules still own readonly,
|
|
178
|
+
disabled and validation fills.
|
|
179
|
+
|
|
175
180
|
Set `--control-hover-border` to tune the hover border of `.input` and `.textarea`.
|
|
176
181
|
Set `--control-hover-bg` to keep a `.select` background steady on hover, or give
|
|
177
182
|
it a stronger fill.
|
|
183
|
+
Set `--control-shadow` to give `.input`, `.textarea` and `.select` a resting
|
|
184
|
+
elevation (unset by default). It inherits, so a theme can set it once on its
|
|
185
|
+
root; keyboard focus and an open custom select keep it.
|
|
178
186
|
|
|
179
187
|
## Notes
|
|
180
188
|
|
|
@@ -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
|
|
37
|
-
|
|
38
|
-
|
|
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">`.
|
|
@@ -102,14 +89,19 @@ classes: `<article class="card pricing-plan pricing-plan--featured">`.
|
|
|
102
89
|
|
|
103
90
|
Components are semantic boxes: `.btn`, `.badge`, `.alert`, `.card`, `.avatar`, etc. Each component owns its intrinsic layout and visual defaults.
|
|
104
91
|
|
|
92
|
+
Components are replaceable implementations. If a built-in component does more
|
|
93
|
+
than your application needs, omit its module and write your own. Keep the
|
|
94
|
+
semantic markup, state conventions, and shared design tokens where they fit.
|
|
95
|
+
See [Replace a component, keep the conventions](../guides/modular-import.md#replace-a-component-keep-the-conventions)
|
|
96
|
+
for a minimal Steps implementation.
|
|
97
|
+
|
|
105
98
|
## Intents
|
|
106
99
|
|
|
107
|
-
`.primary`, `.secondary`, `.success`, `.warning`, `.danger`
|
|
100
|
+
`.primary`, `.secondary`, `.success`, `.warning`, and `.danger` choose a color
|
|
101
|
+
role. The component and variant decide how to display it.
|
|
108
102
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
should consume the current intent as its foreground color. It works with an
|
|
112
|
-
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.
|
|
113
105
|
|
|
114
106
|
```html demo
|
|
115
107
|
<button class="btn primary">Primary</button>
|
|
@@ -121,9 +113,7 @@ intent on the same element or inherited from an ancestor.
|
|
|
121
113
|
</span>
|
|
122
114
|
```
|
|
123
115
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
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.
|
|
127
117
|
|
|
128
118
|
Custom intents need no framework support — define `--intent` and `--intent-fg`
|
|
129
119
|
(and `--intent-soft-fg` when the custom role needs its own soft foreground) on a
|
|
@@ -144,7 +134,8 @@ class:
|
|
|
144
134
|
|
|
145
135
|
## Variants
|
|
146
136
|
|
|
147
|
-
`.solid`, `.soft`, `.outline`, `.surface`
|
|
137
|
+
`.solid`, `.soft`, `.outline`, and `.surface` choose the visual treatment:
|
|
138
|
+
filled, tinted, outlined, or on the page surface.
|
|
148
139
|
|
|
149
140
|
`.btn` defaults to `.solid`; `.badge` and `.alert` default to `.soft`.
|
|
150
141
|
|
|
@@ -162,37 +153,20 @@ class:
|
|
|
162
153
|
|
|
163
154
|
## Size and density
|
|
164
155
|
|
|
165
|
-
`.sm` and `.lg`
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
how tightly UI sits — spacing and component geometry — while font size and
|
|
180
|
-
icon size stay unchanged. `.tight` and `.loose` change the rhythm (`--gap`)
|
|
181
|
-
alone. Participation is opt-in, and a component only joins
|
|
182
|
-
where density has an effect independent from its optical size: if the result is
|
|
183
|
-
merely that the component looks smaller or larger, that is size, not density.
|
|
184
|
-
|
|
185
|
-
Density participation takes three levels:
|
|
186
|
-
|
|
187
|
-
- **Geometry + rhythm** — controls and their wrappers (`.field`, `.join`,
|
|
188
|
-
`.flyout`, …). Height, padding, and gap respond; typography is untouched.
|
|
189
|
-
- **Rhythm only** — content rows and shells such as `.list`. Spacing tightens
|
|
190
|
-
(`--list-item-gap: var(--gap)`), but the structural size stays stable.
|
|
191
|
-
- **No density effect** — components whose geometry is intrinsic to their
|
|
192
|
-
content (`.badge`, `.avatar`, `.spinner`, `.rating`, `.key`, prose, inline
|
|
193
|
-
`.choice`/`.switch`). Their optical size belongs to `sm`/`lg` or local hooks.
|
|
194
|
-
|
|
195
|
-
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:
|
|
196
170
|
|
|
197
171
|
```html demo
|
|
198
172
|
<div class="compact stack">
|
|
@@ -223,12 +197,8 @@ affect the same dimension:
|
|
|
223
197
|
</div>
|
|
224
198
|
```
|
|
225
199
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
Components consume the dimensions that make sense for them and opt out of the
|
|
229
|
-
rest. The absolute `--space-*` scale is not rebound by density scopes.
|
|
230
|
-
Components with bespoke geometry (`.badge`, `.avatar`,
|
|
231
|
-
`.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.
|
|
232
202
|
|
|
233
203
|
`.compact` also remains a meaningful local modifier for `.card` and `.table`.
|
|
234
204
|
On those components it tightens their own padding and establishes the compact
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
# Theming
|
|
2
2
|
|
|
3
|
-
Find
|
|
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
|
|
|
@@ -64,19 +63,45 @@ Change `--switch-width`, `--switch-block-size`, and `--switch-knob-margin`; knob
|
|
|
64
63
|
|
|
65
64
|
Set `--disabled-opacity`. All disabled-prone components — buttons, tabs, menu items, badges, avatars, choice cards, native inputs, and range sliders — read it for their dimmed state.
|
|
66
65
|
|
|
66
|
+
### Customize focus beyond the ring / focus background, text and border
|
|
67
|
+
|
|
68
|
+
Use an application class with `:focus-visible` to change a button's fill, text,
|
|
69
|
+
and border while keeping its framework outline. Load the rule after Actual CSS:
|
|
70
|
+
|
|
71
|
+
```css
|
|
72
|
+
.settings-action.btn:focus-visible:not(:where(:disabled, [aria-disabled="true"])) {
|
|
73
|
+
background: var(--surface-solid);
|
|
74
|
+
color: var(--surface-solid-fg);
|
|
75
|
+
border-color: var(--focus);
|
|
76
|
+
/* Hover paints an inset shadow over the background. */
|
|
77
|
+
--btn-hover-overlay: transparent;
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
```html
|
|
82
|
+
<button class="btn primary settings-action" type="button">Settings</button>
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Focus and hover can be active together. The selector takes precedence over the
|
|
86
|
+
generic hover fill; `--btn-hover-overlay` removes its extra tint while
|
|
87
|
+
preserving any `--btn-shadow` elevation. Check keyboard focus both with and
|
|
88
|
+
without the pointer over the button, in each color scheme and in forced colors.
|
|
89
|
+
Keep the outline visible against the surrounding surface when changing colors.
|
|
90
|
+
|
|
91
|
+
→ [Button hooks](../components/button.md#css-hooks) · [Focus tokens](./tokens.md#color)
|
|
92
|
+
|
|
67
93
|
### Keep bare native controls on-theme / accent-color
|
|
68
94
|
|
|
69
|
-
|
|
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.
|
|
70
98
|
|
|
71
99
|
→ Forms · Overview · Foundations · Tokens (theme contract)
|
|
72
100
|
|
|
73
101
|
### Store a theme name without applying it
|
|
74
102
|
|
|
75
|
-
`data-theme`
|
|
76
|
-
|
|
77
|
-
or a form control's `value`, when the element should only hold a theme name.
|
|
78
|
-
Apply `data-theme` deliberately when that element and its subtree should paint
|
|
79
|
-
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`.
|
|
80
105
|
|
|
81
106
|
### Loading / busy overlay on a container
|
|
82
107
|
|
|
@@ -147,13 +172,10 @@ well as color.
|
|
|
147
172
|
|
|
148
173
|
### Dark mode toggle / theme switcher / remember the user's choice
|
|
149
174
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
choice
|
|
154
|
-
follows the OS. Apply a stored choice from an inline script in `<head>` so the
|
|
155
|
-
first paint does not flash the OS scheme. The demo's theme picker is an
|
|
156
|
-
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.
|
|
157
179
|
|
|
158
180
|
### Force light or dark on a theme that has both / theme and color scheme
|
|
159
181
|
|
|
@@ -206,6 +228,25 @@ step per role rather than importing the scale.
|
|
|
206
228
|
|
|
207
229
|
→ Foundations · Tokens (theme contract) · Guides · Tailwind (Map the palette to theme roles)
|
|
208
230
|
|
|
231
|
+
### Use a custom font / webfont / typeface with a theme
|
|
232
|
+
|
|
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:
|
|
237
|
+
|
|
238
|
+
```css
|
|
239
|
+
:root {
|
|
240
|
+
--font-sans: "Space Grotesk Variable", system-ui, sans-serif;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
:is(h1, h2) {
|
|
244
|
+
font-family: "Archivo Black", var(--font-sans);
|
|
245
|
+
}
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
→ Examples · Neo-brutalist
|
|
249
|
+
|
|
209
250
|
### Use or adapt a preset palette
|
|
210
251
|
|
|
211
252
|
`src/css/themes/` holds example palettes (`ocean`, `spruce`, `neon`, `brutalist`, …) as
|
|
@@ -213,13 +254,9 @@ reference material to copy into your own `[data-theme]` island — they are demo
|
|
|
213
254
|
assets, not package entrypoints. Each sets the intent/surface/text tokens and
|
|
214
255
|
lets the core derive everything else.
|
|
215
256
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
and `.join` still needs no adaptation. The `glass` example paints translucent
|
|
223
|
-
surfaces over its own backdrop: it sets `--surface-opaque` and
|
|
224
|
-
`--surface-solid-fg` to opaque values, raises `--soft-bg-mix` so soft fills stay
|
|
225
|
-
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.
|