@eldrajs/ui 0.2.9 → 0.3.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.
Files changed (121) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +171 -151
  3. package/dist/{VariantPicker-Da41_oGA.js → VariantPicker-DDFlMvgJ.js} +1222 -833
  4. package/dist/components/accordion/Accordion.vue.d.ts +1 -2
  5. package/dist/components/accordion/AccordionItem.vue.d.ts +1 -1
  6. package/dist/components/accordion/types.d.ts +6 -7
  7. package/dist/components/avatar/Avatar.vue.d.ts +1 -1
  8. package/dist/components/avatar/types.d.ts +6 -4
  9. package/dist/components/badge/types.d.ts +6 -4
  10. package/dist/components/breadcrumb/types.d.ts +5 -2
  11. package/dist/components/button/Button.vue.d.ts +3 -3
  12. package/dist/components/button/ButtonGroup.vue.d.ts +0 -1
  13. package/dist/components/button/types.d.ts +7 -6
  14. package/dist/components/card/ContentCard.vue.d.ts +1 -1
  15. package/dist/components/card/FeatureCard.vue.d.ts +1 -1
  16. package/dist/components/card/stretchedLink.d.ts +3 -3
  17. package/dist/components/card/types.d.ts +6 -4
  18. package/dist/components/carousel/types.d.ts +7 -3
  19. package/dist/components/checkbox/Checkbox.vue.d.ts +3 -3
  20. package/dist/components/checkbox/CheckboxGroup.vue.d.ts +1 -1
  21. package/dist/components/checkbox/types.d.ts +10 -4
  22. package/dist/components/chip/Chip.vue.d.ts +1 -1
  23. package/dist/components/chip/ChipGroup.vue.d.ts +0 -1
  24. package/dist/components/chip/types.d.ts +5 -6
  25. package/dist/components/container/Container.vue.d.ts +0 -1
  26. package/dist/components/container/types.d.ts +0 -4
  27. package/dist/components/dialog/Dialog.vue.d.ts +2 -2
  28. package/dist/components/dialog/types.d.ts +5 -2
  29. package/dist/components/drawer/Drawer.vue.d.ts +1 -1
  30. package/dist/components/drawer/types.d.ts +5 -2
  31. package/dist/components/empty-state/EmptyState.vue.d.ts +1 -1
  32. package/dist/components/empty-state/types.d.ts +7 -6
  33. package/dist/components/field-wrapper/FieldWrapper.vue.d.ts +1 -1
  34. package/dist/components/field-wrapper/types.d.ts +5 -2
  35. package/dist/components/filter-panel/FilterPanel.vue.d.ts +4 -4
  36. package/dist/components/filter-panel/facets/shared.d.ts +4 -4
  37. package/dist/components/filter-panel/types.d.ts +5 -2
  38. package/dist/components/form-layout/FormLayout.vue.d.ts +1 -1
  39. package/dist/components/form-layout/types.d.ts +5 -2
  40. package/dist/components/icon/Icon.vue.d.ts +1 -2
  41. package/dist/components/icon/types.d.ts +0 -4
  42. package/dist/components/image/types.d.ts +3 -2
  43. package/dist/components/input/Input.vue.d.ts +6 -6
  44. package/dist/components/input/classes.d.ts +25 -19
  45. package/dist/components/input/types.d.ts +5 -2
  46. package/dist/components/lightbox/Lightbox.vue.d.ts +1 -1
  47. package/dist/components/lightbox/types.d.ts +5 -2
  48. package/dist/components/link/Link.vue.d.ts +1 -1
  49. package/dist/components/link/types.d.ts +5 -2
  50. package/dist/components/load-more/types.d.ts +4 -3
  51. package/dist/components/logo-item/LogoItem.vue.d.ts +1 -1
  52. package/dist/components/logo-item/types.d.ts +2 -1
  53. package/dist/components/nav-menu/NavMenu.vue.d.ts +1 -1
  54. package/dist/components/nav-menu/navLinks.d.ts +1 -1
  55. package/dist/components/nav-menu/types.d.ts +3 -3
  56. package/dist/components/pagination/types.d.ts +5 -2
  57. package/dist/components/popover/Popover.vue.d.ts +1 -1
  58. package/dist/components/popover/types.d.ts +5 -6
  59. package/dist/components/price/types.d.ts +3 -2
  60. package/dist/components/product-card/ProductCard.vue.d.ts +1 -1
  61. package/dist/components/product-card/types.d.ts +3 -2
  62. package/dist/components/quantity-stepper/QuantityStepper.vue.d.ts +4 -4
  63. package/dist/components/quantity-stepper/types.d.ts +5 -2
  64. package/dist/components/radio/Radio.vue.d.ts +3 -3
  65. package/dist/components/radio/RadioGroup.vue.d.ts +3 -3
  66. package/dist/components/radio/recipes.d.ts +11 -7
  67. package/dist/components/radio/types.d.ts +11 -5
  68. package/dist/components/range-slider/RangeSlider.vue.d.ts +1 -1
  69. package/dist/components/range-slider/types.d.ts +5 -2
  70. package/dist/components/rating/Rating.vue.d.ts +1 -1
  71. package/dist/components/rating/types.d.ts +3 -2
  72. package/dist/components/search-bar/SearchBar.vue.d.ts +3 -3
  73. package/dist/components/search-bar/SearchResultsPanel.vue.d.ts +1 -1
  74. package/dist/components/search-bar/types.d.ts +5 -2
  75. package/dist/components/search-modal/SearchModal.vue.d.ts +2 -2
  76. package/dist/components/search-modal/types.d.ts +7 -4
  77. package/dist/components/section/Section.vue.d.ts +0 -1
  78. package/dist/components/section/types.d.ts +0 -4
  79. package/dist/components/select/MultiSelect.vue.d.ts +5 -5
  80. package/dist/components/select/Select.vue.d.ts +4 -4
  81. package/dist/components/select/SelectPanel.vue.d.ts +2 -2
  82. package/dist/components/select/panelParts.d.ts +21 -20
  83. package/dist/components/select/types.d.ts +10 -4
  84. package/dist/components/site-form/SiteForm.vue.d.ts +1 -1
  85. package/dist/components/site-form/types.d.ts +6 -2
  86. package/dist/components/skeleton/Skeleton.vue.d.ts +3 -2
  87. package/dist/components/skeleton/types.d.ts +16 -6
  88. package/dist/components/switch/Switch.vue.d.ts +2 -2
  89. package/dist/components/switch/types.d.ts +5 -2
  90. package/dist/components/tabler-icon/TablerIcon.vue.d.ts +2 -3
  91. package/dist/components/tabler-icon/types.d.ts +0 -4
  92. package/dist/components/tabs/Tab.vue.d.ts +1 -1
  93. package/dist/components/tabs/TabPanel.vue.d.ts +1 -3
  94. package/dist/components/tabs/Tabs.vue.d.ts +1 -1
  95. package/dist/components/tabs/types.d.ts +13 -11
  96. package/dist/components/textarea/Textarea.vue.d.ts +4 -4
  97. package/dist/components/textarea/types.d.ts +5 -2
  98. package/dist/components/toast/types.d.ts +9 -3
  99. package/dist/components/tooltip/types.d.ts +4 -3
  100. package/dist/components/unit-input/UnitInput.vue.d.ts +7 -7
  101. package/dist/components/unit-input/types.d.ts +5 -2
  102. package/dist/components/variant-picker/VariantPicker.vue.d.ts +1 -1
  103. package/dist/components/variant-picker/types.d.ts +3 -2
  104. package/dist/components/visually-hidden/VisuallyHidden.vue.d.ts +0 -1
  105. package/dist/components/visually-hidden/types.d.ts +0 -4
  106. package/dist/components.css +1481 -2342
  107. package/dist/composables/useDialog.d.ts +9 -1
  108. package/dist/composables/useEldraScope.d.ts +7 -9
  109. package/dist/index.d.ts +5 -6
  110. package/dist/index.js +1380 -884
  111. package/dist/style.css +1487 -2348
  112. package/dist/tailwind.css +11 -2234
  113. package/dist/theme.css +108 -0
  114. package/dist/tokens.css +1 -0
  115. package/dist/utilities.css +2228 -0
  116. package/dist/utils/mergeClass.d.ts +3 -0
  117. package/dist/utils/tagRecipe.d.ts +3 -3
  118. package/dist/vee-validate.js +1 -1
  119. package/package.json +4 -3
  120. package/dist/scoped.css +0 -4623
  121. package/dist/utils/cx.d.ts +0 -31
package/dist/tailwind.css CHANGED
@@ -1,2235 +1,12 @@
1
- /* Tailwind v4 theme for @eldrajs/ui. Every value is a --eldra-* variable from tokens.css, so a
2
- consumer restyles by setting variables. Consumers with Tailwind import this file after
3
- `@import 'tailwindcss'`; consumers without Tailwind use style.css.
4
-
5
- Two kinds of value cannot be a variable and are written out here, nowhere else:
6
- - container-query breakpoints, because a `@container (width < ...)` condition may not contain
7
- `var()` — Tailwind inlines the `--container-*` value into the condition at build time;
8
- - the spinner's own animation timings, which the spec fixes at 700ms (spin) and 1.2s (pulse). */
1
+ /* For an app that runs Tailwind itself and wants this package's tokens and utilities on its own
2
+ markup (`bg-primary`, `text-body`, `eldra-focus`, `control-h`): the `--eldra-*` tokens, the
3
+ `@theme` mapping them onto Tailwind's namespaces, and the custom utilities. It does not style
4
+ the components, which come prebuilt in `style.css` or `components.css`.
5
+
6
+ @import 'tailwindcss';
7
+ @import '@eldrajs/ui/tailwind.css';
8
+ @import '@eldrajs/ui/components.css';
9
+ */
9
10
  @import './tokens.css';
10
- @source './';
11
-
12
- @theme {
13
- --color-*: initial;
14
- --color-background: var(--eldra-color-background);
15
- --color-surface: var(--eldra-color-surface);
16
- --color-surface-strong: var(--eldra-color-surface-strong);
17
- --color-border: var(--eldra-color-border);
18
- --color-border-strong: var(--eldra-color-border-strong);
19
- --color-text: var(--eldra-color-text);
20
- --color-muted: var(--eldra-color-muted);
21
- --color-primary: var(--eldra-color-primary);
22
- --color-primary-contrast: var(--eldra-color-primary-contrast);
23
- --color-accent: var(--eldra-color-accent);
24
- --color-accent-contrast: var(--eldra-color-accent-contrast);
25
- --color-success: var(--eldra-color-success);
26
- --color-warning: var(--eldra-color-warning);
27
- --color-danger: var(--eldra-color-danger);
28
- --color-focus: var(--eldra-color-focus);
29
- --color-focus-inner: var(--eldra-color-focus-inner);
30
- --color-overlay: var(--eldra-color-overlay);
31
- --color-transparent: transparent;
32
- --color-current: currentColor;
33
-
34
- --font-heading: var(--eldra-font-heading);
35
- --font-body: var(--eldra-font-body);
36
- --font-mono: var(--eldra-font-mono);
37
-
38
- --spacing-*: initial;
39
- --spacing: 0.25rem;
40
- --spacing-1: var(--eldra-space-1);
41
- --spacing-2: var(--eldra-space-2);
42
- --spacing-3: var(--eldra-space-3);
43
- --spacing-4: var(--eldra-space-4);
44
- --spacing-5: var(--eldra-space-5);
45
- --spacing-6: var(--eldra-space-6);
46
- --spacing-8: var(--eldra-space-8);
47
- --spacing-12: var(--eldra-space-12);
48
- --spacing-16: var(--eldra-space-16);
49
-
50
- --radius-*: initial;
51
- --radius-sm: var(--eldra-radius-sm);
52
- --radius-md: var(--eldra-radius-md);
53
- --radius-lg: var(--eldra-radius-lg);
54
- --radius-xl: var(--eldra-radius-xl);
55
- --radius-full: var(--eldra-radius-full);
56
-
57
- --shadow-*: initial;
58
- --shadow-sm: var(--eldra-shadow-sm);
59
- --shadow-md: var(--eldra-shadow-md);
60
- --shadow-float: var(--eldra-shadow-float);
61
-
62
- --ease-out: var(--eldra-ease-out);
63
- --ease-in: var(--eldra-ease-in);
64
-
65
- /* Container-query conditions cannot reference a custom property — `@container (width >=
66
- var(--x))` is invalid CSS — so Tailwind requires a literal length in the `--container-*` theme
67
- namespace before it emits `@narrow:`/`@content:`/`@wide:` variants at all. Shipping these three
68
- as `var(--eldra-container-*)` (the tokens.css indirection every other value in this file uses)
69
- compiled all three variants to nothing — no build error, no warning, just an absent rule — so
70
- `Container`'s own `@content:px-[var(--eldra-gutter-desktop)]` desktop gutter, and every
71
- starter block's own `@content:` layout, never engaged (bug, fixed 2026-09-27: see the README's
72
- Deviations entry). The three literals below are `eldra-starter-spec/tokens.json`'s
73
- `layout.container-{narrow,content,wide}` values, copied by hand — `scripts/build-tokens.mjs`
74
- only ever emits a `var()`-holding `--eldra-*` custom property into `tokens.css`, never a
75
- literal into this file, so it cannot generate this block for us —
76
- `src/__tests__/containerQueryLiterals.spec.ts` asserts the two stay equal, catching the drift a
77
- future token change could otherwise introduce silently.
78
-
79
- This does not cost consumers runtime overridability of the three *widths*:
80
- `--eldra-container-{narrow,content,wide}` in `tokens.css` are untouched, and `Container.vue`
81
- reads them through its own `eldra-container-{narrow,content,wide}` utilities (declared further
82
- down this file) rather than through Tailwind's auto-generated `max-w-narrow`/`-content`/
83
- `-wide`. Those three still compile from the `--container-*` keys below — fine for an ad-hoc
84
- `max-w-content` in a story or a consumer's own markup — but now to the *literal* number rather
85
- than a `var()`, which would silently defeat `Container`'s own "a consumer restyles this by
86
- setting a variable" contract were its width prop to keep reading them. */
87
- --container-narrow: 40rem;
88
- --container-content: 64rem;
89
- --container-wide: 80rem;
90
-
91
- /* In Tailwind v4 the `--container-*` namespace is the container-query breakpoint scale as well
92
- as the width scale, so the three layout widths above already name the spec's `desktop`
93
- (64rem, `--container-content`) and `wide` (80rem, `--container-wide`) breakpoints. The
94
- mobile/tablet edge at 48rem has no layout width of its own, so it is named here: `@max-tablet`
95
- is the spec's "narrower than 48rem", the breakpoint the spec's own "primary buttons grow to
96
- `target-touch` below 48rem" rule would measure. `Button` no longer grows at any container
97
- width (operator override, recorded under Deviations in the README), so nothing in this
98
- package uses `@max-tablet` today — it stays declared for a future component that needs the
99
- same edge. Declaring these keys does not disturb Tailwind's own `@sm`/`@md`/... container
100
- scale — the theme never resets `--container-*`. */
101
- --container-tablet: 48rem;
102
-
103
- /* The two-column form layout's own edge (spec "Form layout" -> Sizes): "the form's container
104
- >= 36rem", "measured on the containing block, so it works in narrow page-builder columns".
105
- Like `--container-tablet` above it is a breakpoint with no layout width behind it, so it is
106
- named here rather than borrowing whichever stock container key happens to be 36rem:
107
- `@two-col:grid-cols-2` turns the pairs on, `@max-two-col:` is the spec's "narrow container
108
- (< 36rem)" state, where the actions stack full width with the primary first. */
109
- --container-two-col: 36rem;
110
- }
111
-
112
- /* `Container`'s own max-width utilities (spec "Container and section" → Sizes). `--eldra-
113
- container-{narrow,content,wide}` (tokens.css, generated from `layout.container-*`) stay
114
- `var()`-driven, unlike the `--container-*` breakpoint scale above whose values had to become
115
- literals for the container-query engine — `max-width` accepts a `var()` just fine, so a consumer
116
- still restyles a block's width by setting one of these three at runtime. `Container.vue` reads
117
- these named utilities for its own width cap rather than Tailwind's auto-generated `max-w-narrow`/
118
- `-content`/`-wide` (now literal numbers, from the `--container-*` keys above), which would
119
- otherwise defeat that contract for the one place it actually matters. Each shares the stock
120
- `max-w` merge group in `cx.ts`, alongside those three literal utilities, so a consumer's
121
- `classes.root` override or `Container`'s own `full` (`max-w-none`) still replaces it outright. */
122
- @utility eldra-container-narrow {
123
- max-width: var(--eldra-container-narrow);
124
- }
125
- @utility eldra-container-content {
126
- max-width: var(--eldra-container-content);
127
- }
128
- @utility eldra-container-wide {
129
- max-width: var(--eldra-container-wide);
130
- }
131
-
132
- /* Type styles, one per spec style. Weight reads `--tw-font-weight` so a `font-*` utility wins. */
133
- @utility text-display {
134
- font-family: var(--eldra-text-display-family);
135
- font-size: var(--eldra-text-display-size);
136
- line-height: var(--eldra-text-display-line);
137
- font-weight: var(--tw-font-weight, var(--eldra-text-display-weight));
138
- letter-spacing: var(--eldra-text-display-tracking);
139
- }
140
- @utility text-h1 {
141
- font-family: var(--eldra-text-h1-family);
142
- font-size: var(--eldra-text-h1-size);
143
- line-height: var(--eldra-text-h1-line);
144
- font-weight: var(--tw-font-weight, var(--eldra-text-h1-weight));
145
- letter-spacing: var(--eldra-text-h1-tracking);
146
- }
147
- @utility text-h2 {
148
- font-family: var(--eldra-text-h2-family);
149
- font-size: var(--eldra-text-h2-size);
150
- line-height: var(--eldra-text-h2-line);
151
- font-weight: var(--tw-font-weight, var(--eldra-text-h2-weight));
152
- letter-spacing: var(--eldra-text-h2-tracking);
153
- }
154
- @utility text-h3 {
155
- font-family: var(--eldra-text-h3-family);
156
- font-size: var(--eldra-text-h3-size);
157
- line-height: var(--eldra-text-h3-line);
158
- font-weight: var(--tw-font-weight, var(--eldra-text-h3-weight));
159
- letter-spacing: var(--eldra-text-h3-tracking);
160
- }
161
- @utility text-h4 {
162
- font-family: var(--eldra-text-h4-family);
163
- font-size: var(--eldra-text-h4-size);
164
- line-height: var(--eldra-text-h4-line);
165
- font-weight: var(--tw-font-weight, var(--eldra-text-h4-weight));
166
- letter-spacing: var(--eldra-text-h4-tracking);
167
- }
168
- @utility text-body-lg {
169
- font-family: var(--eldra-text-body-lg-family);
170
- font-size: var(--eldra-text-body-lg-size);
171
- line-height: var(--eldra-text-body-lg-line);
172
- font-weight: var(--tw-font-weight, var(--eldra-text-body-lg-weight));
173
- letter-spacing: var(--eldra-text-body-lg-tracking);
174
- }
175
- @utility text-body {
176
- font-family: var(--eldra-text-body-family);
177
- font-size: var(--eldra-text-body-size);
178
- line-height: var(--eldra-text-body-line);
179
- font-weight: var(--tw-font-weight, var(--eldra-text-body-weight));
180
- letter-spacing: var(--eldra-text-body-tracking);
181
- }
182
- @utility text-body-sm {
183
- font-family: var(--eldra-text-body-sm-family);
184
- font-size: var(--eldra-text-body-sm-size);
185
- line-height: var(--eldra-text-body-sm-line);
186
- font-weight: var(--tw-font-weight, var(--eldra-text-body-sm-weight));
187
- letter-spacing: var(--eldra-text-body-sm-tracking);
188
- }
189
- @utility text-caption {
190
- font-family: var(--eldra-text-caption-family);
191
- font-size: var(--eldra-text-caption-size);
192
- line-height: var(--eldra-text-caption-line);
193
- font-weight: var(--tw-font-weight, var(--eldra-text-caption-weight));
194
- letter-spacing: var(--eldra-text-caption-tracking);
195
- }
196
- @utility text-overline {
197
- font-family: var(--eldra-text-overline-family);
198
- font-size: var(--eldra-text-overline-size);
199
- line-height: var(--eldra-text-overline-line);
200
- font-weight: var(--tw-font-weight, var(--eldra-text-overline-weight));
201
- letter-spacing: var(--eldra-text-overline-tracking);
202
- text-transform: uppercase;
203
- }
204
- @utility text-label {
205
- font-family: var(--eldra-text-label-family);
206
- font-size: var(--eldra-text-label-size);
207
- line-height: var(--eldra-text-label-line);
208
- font-weight: var(--tw-font-weight, var(--eldra-text-label-weight));
209
- letter-spacing: var(--eldra-text-label-tracking);
210
- }
211
- @utility text-code {
212
- font-family: var(--eldra-text-code-family);
213
- font-size: var(--eldra-text-code-size);
214
- line-height: var(--eldra-text-code-line);
215
- font-weight: var(--tw-font-weight, var(--eldra-text-code-weight));
216
- letter-spacing: var(--eldra-text-code-tracking);
217
- }
218
-
219
- /* Badge type (spec "Badge" → Sizes): "0.8125rem, weight 600, line-height 1, letter-spacing
220
- 0.01em, no wrapping." The size and tracking already read the caption token exactly; the weight
221
- reads the label token's 600 (the caption token's own weight is 400, which the badge does not
222
- want); only the 1 line ratio has no token of its own, so — like `text-button-md`'s 1.2 — it is
223
- a per-component variable with that literal default. */
224
- @utility text-badge {
225
- font-family: var(--eldra-font-body);
226
- font-size: var(--eldra-text-caption-size);
227
- line-height: var(--eldra-badge-line-height, 1);
228
- font-weight: var(--tw-font-weight, var(--eldra-text-label-weight));
229
- letter-spacing: var(--eldra-text-caption-tracking);
230
- }
231
-
232
- /* The stock status line's own text (spec "Badge" → Sizes, "Status line text" row): "0.875rem,
233
- weight 600." Both numbers already read tokens (`text-label-weight` is 600, `text-body-sm-size`
234
- is 0.875rem); the spec gives no line ratio for this row, so — the same shape as
235
- `text-card-title`'s 1.4 — it is a per-component variable with a literal default. Unlike the
236
- badge text above, the status line is a short sentence rather than a tag, so it is allowed to
237
- wrap on a narrow card rather than forcing `whitespace-nowrap`. */
238
- @utility text-stock-status {
239
- font-family: var(--eldra-font-body);
240
- font-size: var(--eldra-text-body-sm-size);
241
- line-height: var(--eldra-stock-status-line, 1.4);
242
- font-weight: var(--tw-font-weight, var(--eldra-text-label-weight));
243
- }
244
-
245
- /* The Logo item wordmark fallback (spec "Logo item" → Sizes, "Wordmark" row): "heading family,
246
- 1.25rem, weight 700, line-height 1.15, letter-spacing −0.01em." No shared type-scale token gives
247
- that exact combination, but three of its four dimensions individually match ones that do:
248
- `h1`/`h2`'s weight (700), `h2`'s line-height (1.15), `h3`'s tracking (−0.01em) — reused directly
249
- rather than duplicated. Only the 1.25rem size has no token of its own, so — the same shape as
250
- `Button`'s `--eldra-button-font-size-lg` — it is a per-component variable with that literal
251
- default. */
252
- @utility text-logo-wordmark {
253
- font-family: var(--eldra-text-h2-family);
254
- font-size: var(--eldra-logo-wordmark-size, 1.25rem);
255
- line-height: var(--eldra-text-h2-line);
256
- font-weight: var(--tw-font-weight, var(--eldra-text-h2-weight));
257
- letter-spacing: var(--eldra-text-h3-tracking);
258
- }
259
-
260
- /* --- Price -------------------------------------------------------------------------------- */
261
-
262
- /* Price's root size (spec "Price" → Sizes): only `sm` and `lg` set an explicit font-size, on the
263
- root rather than on `current` directly, because `compareAt`/`from` below need to read the same
264
- size to compute their own 0.9em. `md`'s current price "inherits parent (1rem by default)" and
265
- gets no utility of its own, so a `<Price size="md">` sitting inside a product-card title or a
266
- cart line naturally matches whatever text surrounds it, exactly as the spec's own wording asks. */
267
- @utility text-price-sm {
268
- font-size: var(--eldra-price-current-sm-size, 0.9375rem);
269
- }
270
- @utility text-price-lg {
271
- font-size: var(--eldra-price-current-lg-size, 1.5rem);
272
- }
273
-
274
- /* The current price (spec "Price" → Sizes): weight 600, tabular numerals, at the size the root
275
- above sets or inherits. */
276
- @utility text-price-current {
277
- font-family: var(--eldra-font-body);
278
- font-weight: var(--tw-font-weight, var(--eldra-text-label-weight));
279
- font-variant-numeric: tabular-nums;
280
- }
281
-
282
- /* The compare-at and "From" text (spec "Price" → Sizes, "Compare-at / From (0.9em)" column): 90%
283
- of whatever size the root sets, weight 400. `0.9em` is the spec's own explicit multiplier, not a
284
- rem magnitude with a token to reach for, so it is written literally — and it reproduces the
285
- table's 0.84rem/0.9rem/1.35rem rows exactly (0.9 × 0.9375rem/1rem/1.5rem) from the one root size
286
- rather than three more per-size variables. `tabular-nums` is harmless on "From" (no digits) and
287
- required on the compare-at, which shares this utility (spec "Price" → Acceptance criteria:
288
- "Numerals are tabular so prices align in lists"). */
289
- @utility text-price-secondary {
290
- font-family: var(--eldra-font-body);
291
- font-size: 0.9em;
292
- font-weight: var(--tw-font-weight, var(--eldra-text-body-weight));
293
- font-variant-numeric: tabular-nums;
294
- }
295
-
296
- /* The unit-price line (spec "Price" → Sizes, Unit column): "0.8125rem" at every size — the one
297
- part of Price whose size does not scale with the root. Reuses the caption token's size exactly,
298
- the same reuse `text-badge` makes. */
299
- @utility text-price-unit {
300
- font-family: var(--eldra-font-body);
301
- font-size: var(--eldra-text-caption-size);
302
- font-weight: var(--tw-font-weight, var(--eldra-text-body-weight));
303
- font-variant-numeric: tabular-nums;
304
- }
305
-
306
- /* --- Rating --------------------------------------------------------------------------------- */
307
-
308
- /* A half star's filled overlay (spec "Rating" → Anatomy, part 1: "half-filled"; the API contract: "half
309
- star via a clipped overlay"). Stacked absolutely over the same star's full outline icon
310
- (`RatingStars.vue`), clipped to its own left half so the outline shows through the unfilled
311
- half rather than leaving blank space. `50%`/`0` are the shape's own geometry, not a design
312
- token — there is no "half" scale to register this against — so, like `eldra-variant-pill-
313
- selected-line`'s inset line, it is a named utility purely so the one-off `clip-path` value has a
314
- single documented home instead of an arbitrary bracket value repeated at the call site. */
315
- @utility eldra-rating-half {
316
- clip-path: inset(0 50% 0 0);
317
- }
318
-
319
- /* Button type (spec "Button" → Sizes): weight 600 on a 1.2 line at every size, with the size's
320
- own font size. sm and md reuse the body-sm and body token sizes; lg's 1.0625rem sits between two
321
- type styles and has no token, so it is a per-component variable with that default. */
322
- @utility text-button-sm {
323
- font-family: var(--eldra-font-body);
324
- font-size: var(--eldra-text-body-sm-size);
325
- line-height: var(--eldra-button-line-height, 1.2);
326
- font-weight: var(--tw-font-weight, var(--eldra-text-label-weight));
327
- }
328
- @utility text-button-md {
329
- font-family: var(--eldra-font-body);
330
- font-size: var(--eldra-text-body-size);
331
- line-height: var(--eldra-button-line-height, 1.2);
332
- font-weight: var(--tw-font-weight, var(--eldra-text-label-weight));
333
- }
334
- @utility text-button-lg {
335
- font-family: var(--eldra-font-body);
336
- font-size: var(--eldra-button-font-size-lg, 1.0625rem);
337
- line-height: var(--eldra-button-line-height, 1.2);
338
- font-weight: var(--tw-font-weight, var(--eldra-text-label-weight));
339
- }
340
-
341
- /* Compact-control type (spec "Actions and forms" → Compact controls, and "Input" → Sizes): the
342
- text of a text input, textarea or select trigger, at body weight on the spec's fixed 1.5rem
343
- line — not the body token's 1.6 ratio, which is a prose line and would make a 2.5rem box too
344
- tall for its own text. sm and lg reuse the body-sm and body token sizes; md's 0.9375rem sits
345
- between two type styles and has no token, so — like the button's lg size above — it is a
346
- per-component variable with that default. `text-control-mobile` is the spec's viewport
347
- exception: "Below a 48rem viewport the text of inputs … is 1rem, so iOS never zooms into a
348
- focused field", applied as `max-md:text-control-mobile` (Tailwind's `md` *viewport* breakpoint
349
- is 48rem, which is the edge the spec measures for this rule — a viewport query, not the block
350
- `@max-tablet` container query the spec's own button touch-target growth would have measured). */
351
- @utility text-control-sm {
352
- font-family: var(--eldra-font-body);
353
- font-size: var(--eldra-text-body-sm-size);
354
- line-height: var(--eldra-control-line-height, 1.5rem);
355
- font-weight: var(--tw-font-weight, var(--eldra-text-body-weight));
356
- }
357
- @utility text-control {
358
- font-family: var(--eldra-font-body);
359
- font-size: var(--eldra-control-font-size, 0.9375rem);
360
- line-height: var(--eldra-control-line-height, 1.5rem);
361
- font-weight: var(--tw-font-weight, var(--eldra-text-body-weight));
362
- }
363
- @utility text-control-lg {
364
- font-family: var(--eldra-font-body);
365
- font-size: var(--eldra-text-body-size);
366
- line-height: var(--eldra-control-line-height, 1.5rem);
367
- font-weight: var(--tw-font-weight, var(--eldra-text-body-weight));
368
- }
369
- @utility text-control-mobile {
370
- font-family: var(--eldra-font-body);
371
- font-size: var(--eldra-control-font-size-mobile, 1rem);
372
- line-height: var(--eldra-control-line-height, 1.5rem);
373
- font-weight: var(--tw-font-weight, var(--eldra-text-body-weight));
374
- }
375
-
376
- /* A field's character counter (spec "Textarea" → Sizes, Counter row): "0.8125rem, line-height
377
- 1.5, tabular numerals, never wraps." The size reuses the caption token; the 1.5 ratio has no
378
- token of its own (unlike the controls above, whose 1.5rem line is fixed, this one is the
379
- button's kind of bare ratio), so — like `text-button-lg`'s font size — it is a per-component
380
- variable with that literal default. Deliberately no `font-weight` here: the spec's over-limit
381
- state needs `font-semibold` layered on top, and a shorthand `font` property here would fight a
382
- separate `font-weight` utility for the same declaration depending on generation order, so the
383
- component pairs this with the stock `font-normal`/`font-semibold` utilities instead. */
384
- @utility text-counter {
385
- font-family: var(--eldra-font-body);
386
- font-size: var(--eldra-text-caption-size);
387
- line-height: var(--eldra-counter-line-height, 1.5);
388
- }
389
-
390
- /* A field's help and error text (spec "Field wrapper" -> Sizes): both are 0.8125rem on a 1.45
391
- line, and they differ only in weight and colour (help 400 `muted`, error 500 `danger`) — so
392
- they share one type utility. The size reuses the caption token; the 1.45 ratio has no token of
393
- its own, so — exactly like `text-counter` above — it is a per-component variable with that
394
- literal default. Deliberately no `font-weight` here for the same reason `text-counter` has
395
- none: the component pairs it with the stock `font-normal`/`font-medium` utilities, which are
396
- unambiguously ordered against each other, rather than layering a `font-weight` utility over a
397
- shorthand `font` declaration. */
398
- @utility text-field-note {
399
- font-family: var(--eldra-font-body);
400
- font-size: var(--eldra-text-caption-size);
401
- line-height: var(--eldra-field-note-line-height, 1.45);
402
- }
403
-
404
- /* A radio Card's title and meta (spec "Radio group" → Sizes, "Card title / hint / meta" row):
405
- "1rem 600 (line-height 1.4)" for the title, and the same run again for the meta ("1rem 600
406
- tabular, no wrap"), which pairs this with the stock `tabular-nums`/`whitespace-nowrap`
407
- utilities rather than a second near-identical type utility. The weight and size both already
408
- read a token (`text-label-weight` is 600, `text-body-size` is 1rem); only the 1.4 ratio has
409
- none of its own, so — like `text-counter`'s 1.5 above — it is a per-component variable with
410
- that literal default. The card's hint reuses `text-body-sm` `muted`, exactly as `Checkbox`'s
411
- hint does. */
412
- @utility text-card-title {
413
- font-family: var(--eldra-font-body);
414
- font-size: var(--eldra-text-body-size);
415
- line-height: var(--eldra-radio-card-title-line, 1.4);
416
- font-weight: var(--tw-font-weight, var(--eldra-text-label-weight));
417
- }
418
-
419
- /* Accordion's label (spec "Accordion" → Sizes, "Label" row): "1.0625rem / 1.4, weight 600" —
420
- between `text-body` (1rem) and `text-h4` (1.125rem), no token of its own, so — the same shape as
421
- `text-card-title` just above — it is its own utility reusing `--eldra-text-label-weight` (600)
422
- and the body family, with the 1.4 line ratio as a per-component variable carrying that literal
423
- default. */
424
- @utility text-accordion-title {
425
- font-family: var(--eldra-font-body);
426
- font-size: 1.0625rem;
427
- line-height: var(--eldra-accordion-title-line, 1.4);
428
- font-weight: var(--tw-font-weight, var(--eldra-text-label-weight));
429
- }
430
-
431
- /* The Quantity stepper's value (spec "Quantity stepper" → Sizes): "0.9375rem, 600, tabular" at
432
- `md`, "0.875rem" at `sm` (weight and line stay the same size only). The size matches
433
- `text-control`/`text-control-sm` exactly; the weight reuses `--eldra-text-label-weight` (600). */
434
- @utility text-stepper-value {
435
- font-family: var(--eldra-font-body);
436
- font-size: var(--eldra-control-font-size, 0.9375rem);
437
- line-height: var(--eldra-control-line-height, 1.5rem);
438
- font-weight: var(--tw-font-weight, var(--eldra-text-label-weight));
439
- }
440
- @utility text-stepper-value-sm {
441
- font-family: var(--eldra-font-body);
442
- font-size: var(--eldra-text-body-sm-size);
443
- line-height: var(--eldra-control-line-height, 1.5rem);
444
- font-weight: var(--tw-font-weight, var(--eldra-text-label-weight));
445
- }
446
-
447
- /* `FilterGroup`'s trigger label (spec "Filter panel" → Sizes, "Trigger" row): "0.9375rem weight
448
- 600, left-aligned" — the same size and line as `text-control`, at `--eldra-text-label-weight`
449
- (600), the same shape as `text-stepper-value`. */
450
- @utility text-filter-trigger {
451
- font-family: var(--eldra-font-body);
452
- font-size: var(--eldra-control-font-size, 0.9375rem);
453
- line-height: var(--eldra-control-line-height, 1.5rem);
454
- font-weight: var(--tw-font-weight, var(--eldra-text-label-weight));
455
- }
456
-
457
- /* `EmptyState`'s title (spec "Empty and error states" → Sizes, "Title" row): "heading family,
458
- 1.25rem, line-height 1.3, weight 600" — between `text-h4` (1.125rem) and `text-h3` (1.5rem), so
459
- it is its own utility rather than either. The weight is a literal spec number with no token of
460
- its own (like `text-card-title`'s 600 above); the size and the 1.3 line ratio are both
461
- per-component variables with that literal default, the same shape as `text-counter`'s 1.5 — see
462
- the README's Customisation table for `--eldra-empty-state-title-size`. */
463
- @utility text-empty-state-title {
464
- font-family: var(--eldra-font-heading);
465
- font-size: var(--eldra-empty-state-title-size, 1.25rem);
466
- line-height: var(--eldra-empty-state-title-line, 1.3);
467
- font-weight: var(--tw-font-weight, var(--eldra-text-label-weight));
468
- }
469
-
470
- /* `ContentCard`'s title (spec "Content card" → Sizes, "Title" row): "heading family, 1.25rem,
471
- line-height 1.3, weight 600, letter-spacing −0.01em" — the same size/line/weight/family
472
- combination as `text-empty-state-title` just above, but with a tracking value that one has none
473
- of, so it is its own utility rather than that one plus an arbitrary `tracking-*` alongside it.
474
- The weight and tracking both already read tokens (`text-label-weight` is 600, `text-h3-tracking`
475
- is −0.01em, reused directly the same way `text-logo-wordmark` reuses three `h2`/`h3` tokens at
476
- once); the size and the 1.3 line ratio are both per-component variables with that literal
477
- default — the same shape as `text-empty-state-title`'s own — see the README's Customisation
478
- table for `--eldra-content-card-title-size`. */
479
- @utility text-content-card-title {
480
- font-family: var(--eldra-font-heading);
481
- font-size: var(--eldra-content-card-title-size, 1.25rem);
482
- line-height: var(--eldra-content-card-title-line, 1.3);
483
- font-weight: var(--tw-font-weight, var(--eldra-text-label-weight));
484
- letter-spacing: var(--eldra-text-h3-tracking);
485
- }
486
-
487
- /* `ContentCard`'s excerpt and `FeatureCard`'s body (spec "Content card" → Sizes, "Excerpt" row:
488
- "0.9375rem, clamp 3 lines"; "Feature card" → Sizes, "Body" row: "0.9375rem, `muted`") — the same
489
- numeric size in both specs, reused as one utility across the two components rather than two
490
- near-identical ones, the same "share when the numbers actually match" reuse `text-badge`/
491
- `text-stock-status` make across their own components. Neither spec gives a line ratio for this
492
- size, so — like `text-counter`'s 1.5 — it is a per-component variable with a literal default; a
493
- readable paragraph ratio rather than a control's fixed line box, since both are prose. */
494
- @utility text-content-card-excerpt {
495
- font-family: var(--eldra-font-body);
496
- font-size: var(--eldra-content-card-excerpt-size, 0.9375rem);
497
- line-height: var(--eldra-content-card-excerpt-line, 1.5);
498
- font-weight: var(--tw-font-weight, var(--eldra-text-body-weight));
499
- }
500
-
501
- /* Control heights and targets. */
502
- @utility control-h {
503
- height: var(--eldra-control-height);
504
- }
505
- @utility control-h-sm {
506
- height: var(--eldra-control-height-sm);
507
- }
508
- @utility control-h-lg {
509
- height: var(--eldra-control-height-lg);
510
- }
511
- @utility target-min {
512
- min-height: var(--eldra-target-min);
513
- min-width: var(--eldra-target-min);
514
- }
515
- @utility target-touch {
516
- min-height: var(--eldra-target-touch);
517
- }
518
-
519
- /* Motion. */
520
- @utility duration-fast {
521
- transition-duration: var(--eldra-duration-fast);
522
- }
523
- @utility duration-base {
524
- transition-duration: var(--eldra-duration-base);
525
- }
526
- @utility duration-slow {
527
- transition-duration: var(--eldra-duration-slow);
528
- }
529
-
530
- /* Accordion (spec "Accordion" → Behaviour & motion): "Chevron rotation: `duration-base` (200ms)
531
- `ease-out`." self-conditioned on the ancestor `<details>`'s own native `[open]` attribute, so no
532
- JS state is needed for it at all — `AccordionItem.vue` never touches this class beyond putting
533
- it on the chevron `<svg>`. The reduced-motion override is baked into the utility itself, the
534
- same shape as `eldra-focus`'s own `@media` block, rather than a `motion-reduce:` variant at the
535
- call site: this is one bundled rule, not a component assembling stock `transition-*`/`duration-
536
- *` pieces the way `Switch`'s track/thumb do. */
537
- @utility eldra-accordion-chevron {
538
- transition: rotate var(--eldra-duration-base) var(--eldra-ease-out);
539
- details[open] & {
540
- rotate: 180deg;
541
- }
542
- @media (prefers-reduced-motion: reduce) {
543
- transition: none;
544
- }
545
- }
546
-
547
- /* Accordion's panel (spec "Accordion" → Behaviour & motion): "Panel: fades in over `duration-base`
548
- `ease-out` when opened." Deliberately an opacity fade only, not a height animation: the panel
549
- `<div>` is a plain child of `<details>`, and its `display: none` while closed comes entirely
550
- from the browser's own default rendering rule for `<details>` content
551
- (`details:not([open]) > *:not(summary) { display: none; }`, the HTML spec's own UA style) —
552
- nothing here touches or replaces that. `@starting-style` plus `transition-behavior: allow-
553
- discrete` is the standard mechanism for animating *into* a value on an element whose `display`
554
- toggles between `none` and its default (Chrome 117+, Safari 17.4+, Firefox 129+); everywhere
555
- else the panel simply pops open, exactly like `<details>` always has, which is a fine
556
- progressive-enhancement fallback and never a broken one.
557
-
558
- A grid-rows height animation was the first design considered here and was rejected: making it
559
- work at all requires overriding the panel's own `display` so it never actually leaves the
560
- layout while "closed" (only collapsed to a zero-height row) — and the spec's own acceptance
561
- criteria requires "Find-in-page finds text in closed panels and opens the item", which is a
562
- `<details>`-specific browser feature keyed to the element's default closed-content hiding.
563
- Overriding `display` to keep the row always rendered is exactly what would defeat that feature
564
- in whichever engine implements it that way. This utility never sets `display` at all — only
565
- `opacity` and `display`'s own place in the transition list — so the native hide/reveal (and
566
- whatever a browser does with it for find-in-page) is completely untouched.
567
-
568
- Operator override, 2026-09-26 ("the accordion should have some expand transition"):
569
- `AccordionItem.vue` now also plays a *height* animation on the same panel element, through the
570
- Web Animations API (`heightTransition.ts`) rather than CSS — it animates a measured pixel height
571
- (`0` ↔ `scrollHeight`), never touches `display`, and needs no grid wrapper, so the find-in-page
572
- argument above never applies to it. This utility is unchanged and keeps doing exactly what it
573
- always did (the opacity fade); the two run side by side. See the README's Deviations entry for
574
- the fuller account, including the exclusive-group sibling that still closes with no animation of
575
- its own. */
576
- @utility eldra-accordion-panel {
577
- transition:
578
- opacity var(--eldra-duration-base) var(--eldra-ease-out),
579
- display var(--eldra-duration-base) allow-discrete;
580
- @starting-style {
581
- opacity: 0;
582
- }
583
- @media (prefers-reduced-motion: reduce) {
584
- transition: none;
585
- }
586
- }
587
-
588
- /* The Button spinner (spec "Button" → Behaviour & motion): it turns once every 700ms, linear,
589
- without end; with reduced motion it pulses at 60-100% opacity over 1.2s instead of spinning.
590
- These two timings are the spec's own and are the only durations in the package that do not read
591
- `--eldra-duration-*` — the reduced-motion rule in tokens.css zeroes those, which would stop the
592
- pulse as well. */
593
- @keyframes eldra-spin {
594
- to {
595
- rotate: 360deg;
596
- }
597
- }
598
- @keyframes eldra-pulse {
599
- 0%,
600
- 100% {
601
- opacity: 0.6;
602
- }
603
- 50% {
604
- opacity: 1;
605
- }
606
- }
607
- @utility animate-eldra-spin {
608
- animation: eldra-spin 700ms linear infinite;
609
- }
610
- @utility animate-eldra-pulse {
611
- animation: eldra-pulse 1.2s var(--eldra-ease-out) infinite;
612
- }
613
-
614
- /* The skeleton shimmer (spec "Skeleton" → Behaviour & motion): "Shimmer sweeps left to right over
615
- 1.4s, ease-out, infinitely… Reduced motion: shimmer removed; shapes are static." Shared
616
- infrastructure rather than a `Price`-only rule: `Price`'s own loading state below is the first
617
- consumer, and the `Skeleton` primitive (a later task) reuses this same utility for every shape.
618
- The shape itself is a `surface-strong` fill (spec "Skeleton" → States, "Shape" row); the shimmer
619
- is a `background`-coloured band at 60% strength (States, "Shimmer" row) that sweeps across it.
620
- It is layered on with a `::after` that slides across rather than an animated
621
- `background-position` on the shape's own fill, so the base fill and the moving highlight are
622
- independent — reduced motion removes the highlight element outright (`display: none`) instead of
623
- merely freezing it mid-sweep, which is what "shapes are static" asks for rather than an instant
624
- jump to one frame of the animation. */
625
- @keyframes eldra-shimmer {
626
- from {
627
- transform: translateX(-100%);
628
- }
629
- to {
630
- transform: translateX(100%);
631
- }
632
- }
633
- @utility eldra-skeleton {
634
- position: relative;
635
- overflow: hidden;
636
- background-color: var(--color-surface-strong);
637
- &::after {
638
- content: '';
639
- position: absolute;
640
- inset: 0;
641
- background: linear-gradient(
642
- 90deg,
643
- transparent,
644
- color-mix(in oklab, var(--eldra-color-background), transparent 40%),
645
- transparent
646
- );
647
- animation: eldra-shimmer 1.4s var(--eldra-ease-out) infinite;
648
- }
649
- @media (prefers-reduced-motion: reduce) {
650
- &::after {
651
- display: none;
652
- }
653
- }
654
- }
655
-
656
- /* A value that is still on screen while a fresher one is being fetched (`Price`, `StockBadge` and,
657
- through them, `ProductCard`, with `revalidating` set): the value keeps its place and its text and
658
- is drawn at `--eldra-revalidating-opacity`, with the spinner beside it left at full strength. Not
659
- a literal `opacity-75`: the amount of the dim is a token a store restyles, like every other value
660
- in this package. The default is the deepest dim at which every colour these values are drawn in
661
- still clears 3:1 on every ground this package ships — deep enough to read as unsettled rather
662
- than as settled text, and below 4.5:1 for everything but `text` while the read lasts (see
663
- `eldra-starter-spec/tokens.json` for the numbers and for which way to move it). Registered in
664
- `src/utils/cx.ts`'s `opacity` merge group, so a consumer's own `classes.current: 'opacity-100'`
665
- replaces it rather than landing beside it.
666
-
667
- The dim is only half of the treatment: the *change* is eased too. A changed amount, or a changed
668
- stock line, fades in over `--eldra-duration-base` — played in JavaScript on the value's own inner
669
- span (`src/utils/valueFade.ts`), not in CSS and not through a `<Transition>`, so the text itself
670
- is never a frame behind the props. The fade is on that inner span rather than on the value part
671
- for the same reason the dim is on the part: both are `opacity`, and one element cannot animate a
672
- property another rule is holding at the token's value. */
673
- @utility eldra-revalidating {
674
- opacity: var(--eldra-revalidating-opacity);
675
- }
676
-
677
- /* Layers. */
678
- @utility z-sticky {
679
- z-index: var(--eldra-z-sticky);
680
- }
681
- /* A non-modal popup's layer (spec "Select" -> Sizes, Popover row): "Stacks above page content and
682
- the sticky header (z-index 30; the sticky header is 20)." 30 sits between two tokens and has
683
- none of its own, so — like `eldra-link-radius`'s 2px — it is a per-component variable with that
684
- literal default here, and no literal reaches a component class. */
685
- @utility z-popover {
686
- z-index: var(--eldra-z-popover, 30);
687
- }
688
- @utility z-drawer {
689
- z-index: var(--eldra-z-drawer);
690
- }
691
- @utility z-dialog {
692
- z-index: var(--eldra-z-dialog);
693
- }
694
- @utility z-toast {
695
- z-index: var(--eldra-z-toast);
696
- }
697
-
698
- /* The one focus ring (spec 1 "Focus ring"): 2px focus-inner infill hugging the element, 2px focus
699
- ring outside it, arriving over duration-base. `eldra-focus` shows on :focus-visible; text fields
700
- add `eldra-focus-always` so it shows on any focus. `eldra-focus-inset` draws both inside.
701
-
702
- THE RING FADES IN AT FULL SIZE; IT DOES NOT GROW. The spec describes the ring "growing from 0 to
703
- 2px over duration-base", and that is what this first shipped — an `outline-width` and a
704
- `box-shadow` spread animating 0 -> 2px. It looks broken. A browser paints both at whole device
705
- pixels, so a 2px growth has two or three distinct frames however long the transition runs, and a
706
- 200ms stagger of three steps reads as a dropped-frame stutter rather than motion. Drawn at full
707
- size and faded from alpha 0 to 1 the same 200ms is continuous, and the end state — the thing the
708
- contrast requirements are about — is identical. Recorded under Deviations in the README.
709
-
710
- The fade is driven by `--eldra-focus-alpha`, registered with `@property` above so it is a
711
- `<number>` the engine can interpolate (an unregistered custom property is a token string and
712
- jumps). Both ring colours are `color-mix(... calc(var(--eldra-focus-alpha) * 100%), transparent)`,
713
- so one animated number fades both, and the frame-by-frame work is a colour change on a shadow
714
- that never moves. Where `@property` is unsupported the alpha still switches 0 -> 1, so the ring
715
- simply appears at full size — the same thing reduced motion asks for, never a missing ring.
716
-
717
- The ring's geometry is one `box-shadow` pair rather than a shadow plus an `outline`: two spreads
718
- off the same box stay locked together, and the shadow is what fades. `outline` stays at width 0
719
- and is reinstated only under forced colours, where a UA drops `box-shadow` entirely — that rule
720
- is static, because the system Highlight colour is not ours to fade.
721
-
722
- Each mix reads `color-mix(in srgb, transparent, <colour> calc(...))` — transparent FIRST — on
723
- purpose. Tailwind compiles every `color-mix()` with a plain fallback for engines that lack it,
724
- and that fallback is the mix's first colour. Written the other way round the fallback is the
725
- ring's colour at full strength, which paints a permanent black ring around every control in
726
- those engines. This way the fallback is the resting state, and the `@supports not` block on each
727
- focus selector draws the whole ring at once instead — the old behaviour minus the animation,
728
- never a missing indicator.
729
-
730
- `eldra-focus` and `eldra-focus-inset` OWN the transition list of the element they sit on, and a
731
- component must not add a `transition-*`/`duration-*` utility beside them. `transition` is one
732
- shorthand property: a `transition-[background-color] duration-fast` utility on the same element
733
- is a later rule in the same layer, so it replaced the ring's entry outright and the ring arrived
734
- instantly — silently, because the ring was still drawn. So the ring declares every property a
735
- control in this package animates, each at the spec's duration for it: `duration-fast` for the
736
- colour and press changes, `duration-base` for the ring's own alpha. Reduced motion is handled
737
- here too, so components do not carry `motion-reduce:transition-none` either (it stays harmless
738
- where a consumer adds it). `src/__tests__/focus-transition.spec.ts` fails a component that
739
- breaks the rule. */
740
- @property --eldra-focus-alpha {
741
- syntax: '<number>';
742
- inherits: false;
743
- initial-value: 0;
744
- }
745
- /* The ring's `box-shadow` ends with Tailwind's own shadow variables (`--tw-shadow`, `--tw-ring-shadow`
746
- and the rest), each falling back to an empty shadow: a consumer's `shadow-*` or `ring-*` on the
747
- same element is drawn under the ring rather than replaced by it, and with none set the list
748
- paints exactly the ring. */
749
- @utility eldra-focus {
750
- /* Width 0 in every colour mode but forced colours, where the ring below is dropped by the UA. */
751
- outline: 0 solid transparent;
752
- outline-offset: var(--eldra-focus-offset);
753
- --eldra-focus-alpha: 0;
754
- box-shadow:
755
- 0 0 0 var(--eldra-focus-offset)
756
- color-mix(
757
- in srgb,
758
- transparent,
759
- var(--eldra-color-focus-inner) calc(var(--eldra-focus-alpha) * 100%)
760
- ),
761
- 0 0 0 calc(var(--eldra-focus-offset) + var(--eldra-focus-width))
762
- color-mix(
763
- in srgb,
764
- transparent,
765
- var(--eldra-color-focus) calc(var(--eldra-focus-alpha) * 100%)
766
- ),
767
- var(--tw-inset-shadow, 0 0 #0000),
768
- var(--tw-inset-ring-shadow, 0 0 #0000),
769
- var(--tw-ring-offset-shadow, 0 0 #0000),
770
- var(--tw-ring-shadow, 0 0 #0000),
771
- var(--tw-shadow, 0 0 #0000);
772
- transition:
773
- color var(--eldra-duration-fast) var(--eldra-ease-out),
774
- background-color var(--eldra-duration-fast) var(--eldra-ease-out),
775
- border-color var(--eldra-duration-fast) var(--eldra-ease-out),
776
- text-decoration-color var(--eldra-duration-fast) var(--eldra-ease-out),
777
- text-decoration-thickness var(--eldra-duration-fast) var(--eldra-ease-out),
778
- translate var(--eldra-duration-fast) var(--eldra-ease-out),
779
- scale var(--eldra-duration-fast) var(--eldra-ease-out),
780
- opacity var(--eldra-duration-fast) var(--eldra-ease-out),
781
- --eldra-focus-alpha var(--eldra-duration-base) var(--eldra-ease-out);
782
- @media (prefers-reduced-motion: reduce) {
783
- transition: none;
784
- }
785
- &:focus-visible {
786
- --eldra-focus-alpha: 1;
787
- @supports not (color: color-mix(in srgb, red, red)) {
788
- box-shadow:
789
- 0 0 0 var(--eldra-focus-offset) var(--eldra-color-focus-inner),
790
- 0 0 0 calc(var(--eldra-focus-offset) + var(--eldra-focus-width)) var(--eldra-color-focus),
791
- var(--tw-inset-shadow, 0 0 #0000),
792
- var(--tw-inset-ring-shadow, 0 0 #0000),
793
- var(--tw-ring-offset-shadow, 0 0 #0000),
794
- var(--tw-ring-shadow, 0 0 #0000),
795
- var(--tw-shadow, 0 0 #0000);
796
- }
797
- }
798
- @media (forced-colors: active) {
799
- &:focus-visible {
800
- outline-width: var(--eldra-focus-width);
801
- outline-color: Highlight;
802
- }
803
- }
804
- }
805
- @utility eldra-focus-always {
806
- &:focus {
807
- --eldra-focus-alpha: 1;
808
- @supports not (color: color-mix(in srgb, red, red)) {
809
- box-shadow:
810
- 0 0 0 var(--eldra-focus-offset) var(--eldra-color-focus-inner),
811
- 0 0 0 calc(var(--eldra-focus-offset) + var(--eldra-focus-width)) var(--eldra-color-focus),
812
- var(--tw-inset-shadow, 0 0 #0000),
813
- var(--tw-inset-ring-shadow, 0 0 #0000),
814
- var(--tw-ring-offset-shadow, 0 0 #0000),
815
- var(--tw-ring-shadow, 0 0 #0000),
816
- var(--tw-shadow, 0 0 #0000);
817
- }
818
- }
819
- @media (forced-colors: active) {
820
- &:focus {
821
- outline-width: var(--eldra-focus-width);
822
- outline-color: Highlight;
823
- }
824
- }
825
- }
826
- /* The ring while a popup is open (operator request, 2026-09-25). A `Select` or `MultiSelect`
827
- trigger opened with the *pointer* is focused but not `:focus-visible`, so the ring did not show —
828
- and the control then had an open popover attached to a trigger with no visible indication that it
829
- was the thing the keyboard was about to act on. The `SearchBar` has never had this problem: its
830
- trigger is a text field, which carries `eldra-focus-always` and shows the ring on any focus.
831
-
832
- A *modifier* of the same shape as `eldra-focus-always` and `eldra-focus-proxy` — it carries no
833
- ring of its own, it only turns on the one `eldra-focus` already put on the element, keyed to the
834
- state the element itself publishes in `aria-expanded`. So it never needs a second class to be
835
- kept in sync, and closing the popup fades the ring back out over the transition `eldra-focus`
836
- already owns rather than snapping it off. It carries no base, so it must never share a merge
837
- group with `eldra-focus` (see `src/utils/cx.ts`): a modifier never shares a group with the thing
838
- it modifies.
839
-
840
- The forced-colours rule is repeated here for the same reason `eldra-focus-proxy` repeats it: the
841
- one in `eldra-focus` is keyed to that element's own `:focus-visible`, which an open pointer-
842
- opened trigger is not. */
843
- @utility eldra-focus-open {
844
- &[aria-expanded='true'] {
845
- --eldra-focus-alpha: 1;
846
- @supports not (color: color-mix(in srgb, red, red)) {
847
- box-shadow:
848
- 0 0 0 var(--eldra-focus-offset) var(--eldra-color-focus-inner),
849
- 0 0 0 calc(var(--eldra-focus-offset) + var(--eldra-focus-width)) var(--eldra-color-focus),
850
- var(--tw-inset-shadow, 0 0 #0000),
851
- var(--tw-inset-ring-shadow, 0 0 #0000),
852
- var(--tw-ring-offset-shadow, 0 0 #0000),
853
- var(--tw-ring-shadow, 0 0 #0000),
854
- var(--tw-shadow, 0 0 #0000);
855
- }
856
- }
857
- @media (forced-colors: active) {
858
- &[aria-expanded='true'] {
859
- outline-width: var(--eldra-focus-width);
860
- outline-color: Highlight;
861
- }
862
- }
863
- }
864
- /* Proxy focus (spec 1 "Focus ring" → Proxy focus): "When the focusable element is visually hidden
865
- (the radio inside a size pill, the stretched link of a card), draw the ring on the visible shape
866
- (the pill, the whole card), not on the hidden element."
867
-
868
- Exactly the shape of `eldra-focus-always` above, and a *modifier* in the same way: it carries no
869
- ring of its own, it only adds the rule that turns on the one `eldra-focus` already put on this
870
- element. The difference is whose focus turns it on — a descendant's, not the element's own. So a
871
- Checkbox writes `eldra-focus eldra-focus-proxy` on its drawn box and puts the `sr-only`
872
- `<input>` inside it; the transition, the reduced-motion handling and the ring itself all still
873
- live in `eldra-focus`, which is why the two must never share a merge group in `src/utils/cx.ts`.
874
- The forced-colours rule is repeated here because the one in `eldra-focus` is keyed to that
875
- element's own `:focus-visible`, which never happens on a box that is not focusable. */
876
- @utility eldra-focus-proxy {
877
- &:has(:focus-visible) {
878
- --eldra-focus-alpha: 1;
879
- @supports not (color: color-mix(in srgb, red, red)) {
880
- box-shadow:
881
- 0 0 0 var(--eldra-focus-offset) var(--eldra-color-focus-inner),
882
- 0 0 0 calc(var(--eldra-focus-offset) + var(--eldra-focus-width)) var(--eldra-color-focus),
883
- var(--tw-inset-shadow, 0 0 #0000),
884
- var(--tw-inset-ring-shadow, 0 0 #0000),
885
- var(--tw-ring-offset-shadow, 0 0 #0000),
886
- var(--tw-ring-shadow, 0 0 #0000),
887
- var(--tw-shadow, 0 0 #0000);
888
- }
889
- }
890
- @media (forced-colors: active) {
891
- &:has(:focus-visible) {
892
- outline-width: var(--eldra-focus-width);
893
- outline-color: Highlight;
894
- }
895
- }
896
- }
897
-
898
- /* The Link focus ring's corner radius (spec "Link" → Sizes): "2px for every variant." No radius
899
- token is this small — radius-sm is 0.375rem, for badges and chips — so, like the button's
900
- lg font size above, it is a per-component variable with a literal default and no token behind
901
- it; a consumer restyles it with `--eldra-link-radius` on any ancestor. `box-shadow` and modern
902
- `outline` both already follow an element's own `border-radius`, so this is enough to round both
903
- rings the focus ring foundation draws. */
904
- @utility eldra-link-radius {
905
- border-radius: var(--eldra-link-radius, 2px);
906
- }
907
-
908
- /* The inset ring's "any focus" modifier, the exact counterpart of `eldra-focus-always` above and a
909
- modifier in the same way: it carries no ring of its own. A select's search field is a text field,
910
- and the focus-ring foundation's rule for those — "Text fields (Input, Textarea, Search bar, a
911
- select's search field) show it on *any* focus, pointer included, because a caret alone is easy to
912
- miss" — applies whether the ring is drawn outside the element or, as here, just inside it. */
913
- @utility eldra-focus-inset-always {
914
- &:focus {
915
- --eldra-focus-alpha: 1;
916
- @supports not (color: color-mix(in srgb, red, red)) {
917
- box-shadow:
918
- inset 0 0 0 var(--eldra-focus-width) var(--eldra-color-focus),
919
- inset 0 0 0 calc(var(--eldra-focus-offset) + var(--eldra-focus-width))
920
- var(--eldra-color-focus-inner);
921
- }
922
- }
923
- @media (forced-colors: active) {
924
- &:focus {
925
- outline-width: var(--eldra-focus-width);
926
- outline-color: Highlight;
927
- }
928
- }
929
- }
930
-
931
- /* The ring sits against the element's edge and its gap inside it, toward the content: every inset
932
- ring is drawn inside a bordered container, where an outer gap read as padding. */
933
- @utility eldra-focus-inset {
934
- outline: 0 solid transparent;
935
- outline-offset: calc(-1 * (var(--eldra-focus-width) + var(--eldra-focus-offset)));
936
- --eldra-focus-alpha: 0;
937
- box-shadow:
938
- inset 0 0 0 var(--eldra-focus-width)
939
- color-mix(
940
- in srgb,
941
- transparent,
942
- var(--eldra-color-focus) calc(var(--eldra-focus-alpha) * 100%)
943
- ),
944
- inset 0 0 0 calc(var(--eldra-focus-offset) + var(--eldra-focus-width))
945
- color-mix(
946
- in srgb,
947
- transparent,
948
- var(--eldra-color-focus-inner) calc(var(--eldra-focus-alpha) * 100%)
949
- );
950
- transition:
951
- color var(--eldra-duration-fast) var(--eldra-ease-out),
952
- background-color var(--eldra-duration-fast) var(--eldra-ease-out),
953
- border-color var(--eldra-duration-fast) var(--eldra-ease-out),
954
- text-decoration-color var(--eldra-duration-fast) var(--eldra-ease-out),
955
- text-decoration-thickness var(--eldra-duration-fast) var(--eldra-ease-out),
956
- translate var(--eldra-duration-fast) var(--eldra-ease-out),
957
- scale var(--eldra-duration-fast) var(--eldra-ease-out),
958
- opacity var(--eldra-duration-fast) var(--eldra-ease-out),
959
- --eldra-focus-alpha var(--eldra-duration-base) var(--eldra-ease-out);
960
- @media (prefers-reduced-motion: reduce) {
961
- transition: none;
962
- }
963
- &:focus-visible {
964
- --eldra-focus-alpha: 1;
965
- @supports not (color: color-mix(in srgb, red, red)) {
966
- box-shadow:
967
- inset 0 0 0 var(--eldra-focus-width) var(--eldra-color-focus),
968
- inset 0 0 0 calc(var(--eldra-focus-offset) + var(--eldra-focus-width))
969
- var(--eldra-color-focus-inner);
970
- }
971
- }
972
- @media (forced-colors: active) {
973
- &:focus-visible {
974
- outline-width: var(--eldra-focus-width);
975
- outline-color: Highlight;
976
- }
977
- }
978
- }
979
-
980
- /* A field's own boundary (spec "Actions and forms" -> Compact controls: "1px `border-strong`
981
- boundary"). The width is a variable rather than Tailwind's `border`, because the invalid inset
982
- line below is inset by exactly this much and drawn exactly this thick: with `border` hard-wired
983
- to 1px, setting `--eldra-field-border-width` moved the line without moving the border it sits
984
- inside, and the two came apart. One variable now drives both. The literal default lives here,
985
- not in a component class — the same shape as `eldra-link-radius` above. `border-style` comes
986
- from Tailwind's preflight (`*, ::before, ::after { border: 0 solid }`), which both the
987
- `tailwind.css` and the `style.css` route carry, so a width alone is a solid border and
988
- `border-dashed` still wins where a component asks for one. */
989
- @utility eldra-field-border {
990
- border-width: var(--eldra-field-border-width, 1px);
991
- }
992
-
993
- /* The Checkbox box (spec "Checkbox" → Sizes: "Border | 1.5px", and → States, Error row: "**2px**
994
- `danger`"). Neither number is a token — they are this component's own — so each is a variable
995
- with a literal default here, the same shape as `eldra-link-radius` and `eldra-field-border`
996
- above, and neither literal reaches a component class. They are two utilities rather than one
997
- because the error state changes the width as well as the colour, and both sit in the `border-w`
998
- merge group, so the error width replaces the ordinary one instead of landing beside it. */
999
- @utility eldra-checkbox-border {
1000
- border-width: var(--eldra-checkbox-border-width, 1.5px);
1001
- }
1002
- @utility eldra-checkbox-border-invalid {
1003
- border-width: var(--eldra-checkbox-border-width-invalid, 2px);
1004
- }
1005
-
1006
- /* `EditorPlaceholder`'s own boundary (spec "Empty and error states" → Sizes, "Editor hint" row:
1007
- "1.5px dashed border, `radius-lg`") — not a token, and a different number from the panel's own
1008
- `EmptyState` boundary (a stock `border` at 1px, spec's "Panel border and radius" row), so it
1009
- gets a variable of its own rather than reusing `eldra-checkbox-border`, the same shape as that
1010
- utility. `border-style: dashed` is a separate stock `border-dashed` utility on the component,
1011
- same as `EmptyState`'s panel. */
1012
- @utility eldra-editor-placeholder-border {
1013
- border-width: var(--eldra-editor-placeholder-border-width, 1.5px);
1014
- }
1015
-
1016
- /* The error boundary of a field (spec "Input" → States, Error row): "2px `danger` (1px border +
1017
- 1px inset line). On focus the inset line sits inside the `focus-inner` infill."
1018
-
1019
- Two things make that impossible to draw on the `<input>` itself. `eldra-focus` owns the
1020
- element's `box-shadow` (the focus infill) and its `outline` (the ring), and a second rule for
1021
- either would replace the ring rather than add to it; and an `<input>` is a replaced element, so
1022
- it has no `::after` to lend. So the inset line is drawn by the field's own wrapper — the one
1023
- element that shares the input's box exactly — as a pseudo-element inset by the input's border
1024
- width. Keeping the border at 1px in every state is the point: a 2px border would move the value
1025
- by 1px the moment the field went invalid. `pointer-events: none` keeps the clear button
1026
- clickable through it, and because the line is *inside* the box while the focus infill is
1027
- outside it, the two never overlap — which is what the spec's focus sentence asks for. */
1028
- @utility eldra-field-invalid {
1029
- position: relative;
1030
- &::after {
1031
- content: '';
1032
- position: absolute;
1033
- inset: var(--eldra-field-border-width, 1px);
1034
- border: var(--eldra-field-border-width, 1px) solid var(--eldra-color-danger);
1035
- /* The radius is lifted into a custom property of its own rather than written inline in the
1036
- `calc()`. It substitutes to exactly the same token chain — the computed value is unchanged,
1037
- and `source-scan.spec.ts` asserts both halves of it in the compiled stylesheet — but the
1038
- `calc()` a bundler's PostCSS pass then has to parse holds one level of `var()` fallback
1039
- instead of three. Two-deep nesting (`var(--a, var(--b, var(--c)))`) inside a `calc()` is
1040
- what postcss-calc's grammar chokes on, and it printed a "Parse error … got unexpected
1041
- RPAREN" warning on every consumer build (seen in the starter's). It is only a warning — the
1042
- declaration is passed through untouched — but a package cannot ship noise into every
1043
- consumer's build log, and a real parse error in that pass would look exactly the same. */
1044
- --eldra-field-invalid-radius: var(
1045
- --eldra-field-radius,
1046
- var(--eldra-input-radius, var(--eldra-radius-md))
1047
- );
1048
- border-radius: calc(var(--eldra-field-invalid-radius) - var(--eldra-field-border-width, 1px));
1049
- pointer-events: none;
1050
- }
1051
- @media (forced-colors: active) {
1052
- &::after {
1053
- border-color: CanvasText;
1054
- }
1055
- }
1056
- }
1057
-
1058
- /* The radio group Card's own boundary (spec "Radio group" → Sizes, Card row: "1px border"). The
1059
- radio circle inside a card reuses `eldra-checkbox-border`/`-invalid` unchanged — the spec gives
1060
- it the exact same numbers as the Checkbox box (1.5px / 2px) — but the card itself is a
1061
- different element with its own 1px number, so it gets its own variable rather than sharing one
1062
- that happens to have a different default. */
1063
- @utility eldra-radio-card-border {
1064
- border-width: var(--eldra-radio-card-border-width, 1px);
1065
- }
1066
-
1067
- /* The selected Card's boundary (spec "Radio group" → States, Selected row: "2px `primary` (1px
1068
- border + 1px inset line)"). The same technique as `eldra-field-invalid` above, and for the same
1069
- reason: keeping the real border at 1px in every state and adding a second 1px inset line only
1070
- when selected is what stops the card growing — and its neighbours shifting — the moment it is
1071
- chosen. The line's colour defaults to `primary`; the invalid-and-selected state (Decision: an
1072
- invalid `Checkbox` that is also checked keeps its fill and swaps only the border colour) sets
1073
- `--eldra-radio-card-selected-color` to `danger` instead, so one utility serves both cases rather
1074
- than two nearly-identical ones. */
1075
- @utility eldra-radio-card-selected {
1076
- position: relative;
1077
- &::after {
1078
- content: '';
1079
- position: absolute;
1080
- inset: var(--eldra-radio-card-border-width, 1px);
1081
- border: var(--eldra-radio-card-border-width, 1px) solid
1082
- var(--eldra-radio-card-selected-color, var(--eldra-color-primary));
1083
- border-radius: calc(
1084
- var(--eldra-radio-card-radius, var(--eldra-radius-md)) -
1085
- var(--eldra-radio-card-border-width, 1px)
1086
- );
1087
- pointer-events: none;
1088
- }
1089
- }
1090
-
1091
- /* The Switch track's own boundary (spec "Switch" → Sizes: "1.5px border", both sizes). A
1092
- per-component variable with a literal default, the same shape as `eldra-checkbox-border`. */
1093
- @utility eldra-switch-track-border {
1094
- border-width: var(--eldra-switch-track-border-width, 1.5px);
1095
- }
1096
-
1097
- /* The Switch thumb's rest position (spec "Switch" → Sizes: "1rem, 0.1875rem from the track's
1098
- start edge"). 0.1875rem is not a `--spacing` multiple (0.75 of a step), so it is a
1099
- per-component variable rather than a spacing utility; logical so it reads correctly in an RTL
1100
- document. The "on" position is the thumb's own `translate-x-*`, a `--spacing` multiple, added on
1101
- top of this rest position. */
1102
- @utility eldra-switch-thumb-offset {
1103
- inset-inline-start: var(--eldra-switch-thumb-offset, 0.1875rem);
1104
- }
1105
-
1106
- /* The Switch label (spec "Switch" → Sizes: "Label | 1rem" at md; the sm row's "0.875rem / 1.5"
1107
- reuses `text-body-sm` unchanged since the two numbers match a token exactly). 1rem already reads
1108
- the body token's size; only the line-height has no token of its own (the spec gives it once, in
1109
- the "with description" paragraph: "line-height 1.4"), so — like `text-card-title`'s 1.4 before
1110
- it — it is a per-component variable with that literal default. */
1111
- @utility text-switch-label {
1112
- font-family: var(--eldra-font-body);
1113
- font-size: var(--eldra-text-body-size);
1114
- line-height: var(--eldra-switch-label-line, 1.4);
1115
- font-weight: var(--tw-font-weight, var(--eldra-text-body-weight));
1116
- }
1117
-
1118
- /* The Switch description (spec "Switch" → Sizes: "the description is 0.875rem `muted`", and the
1119
- same paragraph's "line-height 1.4"). 0.875rem already reads the body-sm token's size; the line
1120
- ratio is this component's own, exactly like `text-switch-label` above. */
1121
- @utility text-switch-description {
1122
- font-family: var(--eldra-font-body);
1123
- font-size: var(--eldra-text-body-sm-size);
1124
- line-height: var(--eldra-switch-description-line, 1.4);
1125
- font-weight: var(--tw-font-weight, var(--eldra-text-body-weight));
1126
- }
1127
-
1128
- /* --- Select ---------------------------------------------------------------------------------- */
1129
-
1130
- /* A group heading inside a select panel (spec "Select" -> Sizes, Group heading row): "0.75rem,
1131
- 600, uppercase, 0.06em tracking, `muted`". Every number but the tracking is the overline token's
1132
- already; the spec's 0.06em is half the overline token's 0.12em, so it is this component's own
1133
- and gets a variable with that literal default, exactly like `text-card-title`'s 1.4 line. */
1134
- @utility text-select-group {
1135
- font-family: var(--eldra-font-body);
1136
- font-size: var(--eldra-text-overline-size);
1137
- line-height: var(--eldra-text-overline-line);
1138
- font-weight: var(--tw-font-weight, var(--eldra-text-overline-weight));
1139
- letter-spacing: var(--eldra-select-group-tracking, 0.06em);
1140
- text-transform: uppercase;
1141
- }
1142
-
1143
- /* An option row's own text (spec "Select" -> Sizes, Option row): "0.9375rem text on a 1.35 line".
1144
- The size is the control font size the trigger already uses (`--eldra-control-font-size`), so a
1145
- row and the trigger above it read at one size; only the 1.35 line is this component's own. It is
1146
- deliberately not `text-control`, whose fixed 1.5rem line is the height of a 2.5rem field box and
1147
- would push a two-line option (label + hint) past the spec's row. */
1148
- @utility text-select-option {
1149
- font-family: var(--eldra-font-body);
1150
- font-size: var(--eldra-control-font-size, 0.9375rem);
1151
- line-height: var(--eldra-select-option-line, 1.35);
1152
- font-weight: var(--tw-font-weight, var(--eldra-text-body-weight));
1153
- }
1154
-
1155
- /* The "+N" pill on a Multi-select trigger (spec "Multi-select" -> Sizes: "0.75rem 600 tabular").
1156
- The overline token carries both numbers, but `text-overline` itself is uppercase — which "+2"
1157
- must not be — so the pill takes the token pair without the transform, on the pill's own 1.25rem
1158
- height as its line box. */
1159
- @utility text-select-pill {
1160
- font-family: var(--eldra-font-body);
1161
- font-size: var(--eldra-text-overline-size);
1162
- line-height: var(--eldra-select-pill-line, 1.25rem);
1163
- font-weight: var(--tw-font-weight, var(--eldra-text-overline-weight));
1164
- font-variant-numeric: tabular-nums;
1165
- }
1166
-
1167
- /* The popover's own box (spec "Select" -> Sizes, Popover row): "Min width = trigger, grows to fit
1168
- its content up to min(22rem, 90vw). Max height 20rem: the list scrolls while the search field
1169
- stays put." Two utilities rather than one, because they belong to Tailwind's `max-h` and `max-w`
1170
- merge groups respectively — so a consumer's `classes.panel: 'max-h-64'` replaces the height
1171
- without also dropping the width clamp. */
1172
- @utility eldra-select-panel-height {
1173
- max-height: var(--eldra-select-panel-max-height, 20rem);
1174
- }
1175
- @utility eldra-select-panel-width {
1176
- max-width: min(var(--eldra-select-panel-max-width, 22rem), 90vw);
1177
- }
1178
-
1179
- /* The matched run of a filtered option (spec "Select" -> States, "Option filtered match"):
1180
- "matched characters weight 700, 2px underline at 0.15em offset". None of the three is a token —
1181
- the type styles stop at 600 and no underline offset exists anywhere else — so all three are
1182
- per-component variables with the spec's literals as defaults. */
1183
- @utility eldra-select-match {
1184
- font-weight: var(--eldra-select-match-weight, 700);
1185
- text-decoration-line: underline;
1186
- text-decoration-thickness: var(--eldra-select-match-underline, 2px);
1187
- text-underline-offset: var(--eldra-select-match-underline-offset, 0.15em);
1188
- }
1189
-
1190
- /* An option's colour swatch (spec "Select" -> Sizes, Option row): "Swatch 1rem with a 1px inner
1191
- edge of `text` at 30%", which the Accessibility notes explain — "Swatch edges carry a 1px inner
1192
- edge so pale colours stay visible". An inner edge rather than a border, so the swatch stays
1193
- exactly 1rem whatever colour a store's product data carries. */
1194
- @utility eldra-select-swatch {
1195
- box-shadow: inset 0 0 0 var(--eldra-select-swatch-edge, 1px)
1196
- color-mix(in oklab, var(--eldra-color-text), transparent 70%);
1197
- }
1198
-
1199
- /* A Multi-select option's checkbox (spec "Multi-select" -> Sizes, "Checkbox in option"): "1rem
1200
- square, 1.5px `border-strong`, 0.25rem radius". The radius is its own variable rather than
1201
- `--eldra-checkbox-radius`: the box is 1rem where a `Checkbox`'s is 1.125rem or 1.5rem, and
1202
- `radius-sm` (0.375rem) on a 1rem square reads as a pill rather than a checkbox. The border
1203
- width is shared with `Checkbox` through `eldra-checkbox-border`. */
1204
- @utility eldra-select-check-radius {
1205
- border-radius: var(--eldra-select-check-radius, 0.25rem);
1206
- }
1207
-
1208
- /* The active and selected option rows under forced colours (spec "Select" -> States: the active row
1209
- is "`surface-strong`" fill and the selected row is "weight 600 + check"). Forced-colours mode
1210
- replaces every fill with the system canvas and flattens most weight differences, so each of the
1211
- two states needs a real boundary there or the list reads as one undifferentiated block. Both are
1212
- drawn as insets, so a row never changes size when it becomes active or selected.
1213
-
1214
- `Highlight` for the active row is the system's own "this is where you are" colour, the same one
1215
- the focus ring borrows; the selected row takes a thinner `CanvasText` line, which reads as a
1216
- property of the row rather than as the cursor. `eldra-select-option-active` is declared *after*
1217
- `-selected` on purpose: the two write the same `outline`, and on a row that is both, the one
1218
- worth seeing is where the keyboard is — selection is still carried by the check mark beside it.
1219
- Nothing here applies outside forced colours, so the two utilities never fight the fill and weight
1220
- that carry the same states everywhere else. */
1221
- @utility eldra-select-option-selected {
1222
- @media (forced-colors: active) {
1223
- outline: var(--eldra-select-selected-outline, 1px) solid CanvasText;
1224
- outline-offset: calc(-1 * var(--eldra-select-selected-outline, 1px));
1225
- }
1226
- }
1227
- @utility eldra-select-option-active {
1228
- @media (forced-colors: active) {
1229
- outline: var(--eldra-select-active-outline, 2px) solid Highlight;
1230
- outline-offset: calc(-1 * var(--eldra-select-active-outline, 2px));
1231
- }
1232
- }
1233
-
1234
- /* The entrance of EVERY popover in this package — `Select`'s panel, `MultiSelect`'s and the
1235
- `SearchBar`'s results panel — is this one animation: opacity 0 -> 1 and a uniform scale 0.98 -> 1
1236
- over `duration-base` with `ease-out`, growing from the corner the panel is anchored by. Closing
1237
- is instant.
1238
-
1239
- The spec ("Select" -> Behaviour & motion, Opening) writes it as a fade plus a 0.25rem slide plus
1240
- a *vertical* scale, and that is what shipped first. Operator decision, 2026-09-25: drop the slide
1241
- and scale both axes. The slide is what made the panel read as a separate object arriving from
1242
- somewhere rather than as the control opening out, and a `scaleY`-only entrance stretches the type
1243
- inside the panel while it plays. Recorded under Deviations in the README. The `SearchBar`'s panel
1244
- had no entrance at all before that decision; it now plays the same one.
1245
-
1246
- The origin is a custom property the panel sets inline from the placement it resolved to
1247
- (`usePopover`'s `panelStyle`): `top left` below the control, `bottom left` above it, so the panel
1248
- grows out of the edge it is attached to. One keyframe set with that property rather than two sets
1249
- with two names: a panel that flips swaps its origin the frame after it mounts — floating-ui
1250
- measures asynchronously — and a new `animation-name` would restart the animation from zero, so
1251
- the popover visibly faded in twice. A custom property is read by the running animation instead,
1252
- so the entrance plays exactly once whichever way it ends up pointing.
1253
-
1254
- Reduced motion needs nothing here: `--eldra-duration-base` is 0ms under
1255
- `prefers-reduced-motion: reduce` (tokens.css), so the panel simply appears in its end state — the
1256
- same mechanism every transition in this package uses. `transform: scale()` rather than the
1257
- independent `scale` property, because the panel's `transform` is otherwise untouched and the
1258
- shorthand is the more widely animatable of the two. */
1259
- @keyframes eldra-popover-in {
1260
- from {
1261
- opacity: 0;
1262
- transform: scale(0.98);
1263
- }
1264
- to {
1265
- opacity: 1;
1266
- transform: none;
1267
- }
1268
- }
1269
- @utility animate-eldra-popover-in {
1270
- animation: eldra-popover-in var(--eldra-duration-base) var(--eldra-ease-out);
1271
- transform-origin: var(--eldra-popover-origin, top left);
1272
- }
1273
-
1274
- /* --- Tooltip ---------------------------------------------------------------------------------- */
1275
-
1276
- /* Spec "Tooltip" -> Sizes: "0.8125rem / 1.4, weight 500, one line (no wrap)". The size and line
1277
- are `text-caption`'s exactly (0.8125rem / 1.4) -- reused rather than duplicated, the same shape
1278
- as `text-variant-legend` reusing `text-body-sm`'s. The weight is left to the stock
1279
- `font-medium` utility, also `text-variant-legend`'s own reasoning: a `font` shorthand here would
1280
- bake a weight in ahead of it in source order, and `tailwind-merge`'s `font-size` group (this
1281
- utility's own, via `cx.ts`) does not touch `font-weight` anyway. */
1282
- @utility text-tooltip {
1283
- font-family: var(--eldra-font-body);
1284
- font-size: var(--eldra-text-caption-size);
1285
- line-height: var(--eldra-text-caption-line);
1286
- }
1287
-
1288
- /* The arrow (spec "Tooltip" -> Sizes, Arrow row): "0.3125rem, centred (start / end: 1.25rem from
1289
- the aligned edge)" -- a rotated square, half on each side of the boundary between the bubble and
1290
- the trigger, so it reads as a triangle pointing at whichever one is behind it. `0.3125rem` has no
1291
- shared token (nothing else in the package needs a fifth-of-a-rem), so it is a per-component
1292
- variable with that literal default, the same shape as `--eldra-avatar-initials-size-*`; see the
1293
- README's Customisation table. The horizontal alignment (`left-5`/`right-5`/centred) and the
1294
- vertical offset (which edge, since the bubble can flip) are `Tooltip.vue`'s own reactive classes
1295
- and inline style -- this utility only draws the shape. */
1296
- @utility eldra-tooltip-arrow {
1297
- position: absolute;
1298
- width: var(--eldra-tooltip-arrow-size, 0.3125rem);
1299
- height: var(--eldra-tooltip-arrow-size, 0.3125rem);
1300
- background-color: var(--eldra-color-text);
1301
- transform: rotate(45deg);
1302
- pointer-events: none;
1303
- }
1304
-
1305
- /* --- Search bar ------------------------------------------------------------------------------- */
1306
-
1307
- /* A result row's meta (spec "Search bar" -> Sizes, "Title / sub / meta" row): "0.875rem 600
1308
- tabular" — a price. Both numbers already read tokens (`text-label-weight` is 600,
1309
- `text-body-sm-size` is 0.875rem); only the 1.35 line of the row's text stack is this component's
1310
- own, and it is shared with the row's title, which reuses `text-select-option` (the same
1311
- 0.9375rem on the same 1.35 line the spec gives both components). */
1312
- @utility text-search-meta {
1313
- font-family: var(--eldra-font-body);
1314
- font-size: var(--eldra-text-body-sm-size);
1315
- line-height: var(--eldra-search-text-line, 1.35);
1316
- font-weight: var(--tw-font-weight, var(--eldra-text-label-weight));
1317
- font-variant-numeric: tabular-nums;
1318
- }
1319
-
1320
- /* The no-results title (spec -> Sizes, "No-results message" row): "Title 1rem 600". The size and
1321
- the weight are tokens; the 1.4 line has none of its own, so it is a per-component variable with
1322
- that literal default, exactly like `text-card-title`'s. */
1323
- @utility text-search-title {
1324
- font-family: var(--eldra-font-body);
1325
- font-size: var(--eldra-text-body-size);
1326
- line-height: var(--eldra-search-empty-line, 1.4);
1327
- font-weight: var(--tw-font-weight, var(--eldra-text-label-weight));
1328
- }
1329
-
1330
- /* The `/` keyboard-key chip (spec -> Sizes, "Keyboard hint" row): "monospace, 0.75rem". The size
1331
- is the overline token's, the family the mono token's, and the 1rem line box is the chip's own
1332
- height rather than a ratio. */
1333
- @utility text-search-kbd {
1334
- font-family: var(--eldra-font-mono);
1335
- font-size: var(--eldra-text-overline-size);
1336
- line-height: var(--eldra-search-kbd-line, 1rem);
1337
- font-weight: var(--tw-font-weight, var(--eldra-text-body-weight));
1338
- }
1339
-
1340
- /* The results panel's own box (spec -> Sizes, Panel row): "Max height min(32rem, 70vh), scrolls
1341
- inside". Tailwind's `max-h` group, so a consumer's `classes.panel: 'max-h-64'` replaces it
1342
- outright. The panel's *width* is the field's (`useFloating`'s `matchWidth`), so there is no
1343
- width clamp to go with it, unlike the select popover's pair. */
1344
- @utility eldra-search-panel-height {
1345
- max-height: min(var(--eldra-search-panel-max-height, 32rem), 70vh);
1346
- }
1347
-
1348
- /* --- Variant picker --------------------------------------------------------------------------- */
1349
-
1350
- /* The legend's own text (spec "Variant picker" → Sizes, Legend row): "0.875rem; name 600, value
1351
- 400 muted". Deliberately no weight in the shorthand, for the same reason `text-counter` and
1352
- `text-field-note` have none: the name run and the value run need two different weights of the
1353
- *same* size, and layering a `font-weight` utility after a shorthand `font` property that already
1354
- bakes one in is order-dependent (see `text-counter`'s own comment above this component's
1355
- utilities in the earlier "Sizes" section). So the component pairs this with the stock
1356
- `font-semibold`/`font-normal` utilities instead, exactly as those two already do. The size reuses
1357
- the body-sm token; the line ratio has no token of its own, so it is a per-component variable with
1358
- a literal default, the same shape as `text-card-title`'s 1.4. */
1359
- @utility text-variant-legend {
1360
- font-family: var(--eldra-font-body);
1361
- font-size: var(--eldra-text-body-sm-size);
1362
- line-height: var(--eldra-variant-legend-line, 1.4);
1363
- }
1364
-
1365
- /* A pill option's own text (spec "Variant picker" → Sizes, Pill row): "0.9375rem, 500 (600
1366
- selected)". Same reasoning as `text-variant-legend` above — one size, two weights depending on
1367
- selection — so no weight in the shorthand; the component pairs this with `font-medium`/
1368
- `font-semibold`. The size and line reuse the same control-font variables `text-control` already
1369
- reads, so a pill's text sits at the same size as an Input's. */
1370
- @utility text-variant-pill {
1371
- font-family: var(--eldra-font-body);
1372
- font-size: var(--eldra-control-font-size, 0.9375rem);
1373
- line-height: var(--eldra-control-line-height, 1.5rem);
1374
- }
1375
-
1376
- /* A pill's own boundary (spec "Variant picker" → States): "1px" in every row but one. The width is
1377
- a variable rather than Tailwind's `border`, the same shape as `eldra-field-border` and
1378
- `eldra-checkbox-border` above: the "sold out + selected" row's own 2px line (below) is inset by
1379
- exactly this much. */
1380
- @utility eldra-variant-pill-border {
1381
- border-width: var(--eldra-variant-pill-border-width, 1px);
1382
- }
1383
-
1384
- /* The sold-out-and-selected pill's boundary (spec "Variant picker" → States, "Sold out + selected"
1385
- row): "**2px** solid `text`" — the only pill row whose border is thicker than the other four.
1386
- The same technique as `eldra-radio-card-selected` and `eldra-field-invalid`: the real border
1387
- stays `eldra-variant-pill-border`'s 1px in every state, so a pill never resizes (and its row
1388
- neighbours never reflow) the moment it becomes both sold out and selected, and a second 1px
1389
- inset line does the rest. */
1390
- @utility eldra-variant-pill-selected-line {
1391
- position: relative;
1392
- &::after {
1393
- content: '';
1394
- position: absolute;
1395
- inset: var(--eldra-variant-pill-border-width, 1px);
1396
- border: var(--eldra-variant-pill-border-width, 1px) solid
1397
- var(--eldra-variant-pill-selected-color, var(--eldra-color-text));
1398
- border-radius: calc(
1399
- var(--eldra-variant-pill-radius, var(--eldra-radius-md)) -
1400
- var(--eldra-variant-pill-border-width, 1px)
1401
- );
1402
- pointer-events: none;
1403
- }
1404
- }
1405
-
1406
- /* A sold-out pill's diagonal line (spec "Variant picker" → Anatomy: "sold out: dashed border +
1407
- diagonal line"; → States, Sold out row: "a 1px diagonal `border-strong` line (bottom-left to
1408
- top-right)"). Drawn in `VariantPicker.vue` as an inline `<svg viewBox="0 0 100 100"
1409
- preserveAspectRatio="none">` stretched over the pill, with `vector-effect="non-scaling-stroke"`
1410
- on its `<line>` — the SVG spec's own way to keep a stroke a constant screen-pixel width no
1411
- matter how non-uniformly its coordinate system is scaled. A `background: linear-gradient`
1412
- diagonal was tried first and rejected: its stripe is measured along the gradient line, whose
1413
- length shrinks as a box gets wider relative to its height, so the same "1px" stop distance
1414
- inflates into a visibly thick band on a long pill (`LongLabels` story) while staying correct on
1415
- a short one — exactly what a pill's variable, label-dependent width guarantees will happen.
1416
- Nothing in `tailwind.css` needs to know the pill's own colour class here: the `<svg>` reads
1417
- `currentColor` (`text-border-strong`, set alongside it in the component), so it never needs a
1418
- custom utility of its own; only the `<line>`'s literal `stroke-width="1"` (the spec's own
1419
- number) lives outside a class, the same way `Checkbox`'s tick mark carries its own literal
1420
- `stroke-width` and path. Real borders stay real borders in forced-colours mode (spec "Actions
1421
- and forms" → Forced colours): the line sits *beside* the pill's own real
1422
- `eldra-variant-pill-border`, which is what stays visible there; the two together are how the
1423
- spec tells "sold out" from "selected" without colour alone (1.4.1). */
1424
-
1425
- /* The swatch's own ring (spec "Variant picker" → Sizes, Swatch row): "a 2px ring (transparent at
1426
- rest), then a 3px gap, then the colour disc". The ring is drawn as a real `border` on the
1427
- outer 2.75rem shape — the same element the proxy focus ring sits on — kept at this one constant
1428
- width in every state (spec: "transparent at rest"; hover and selected only ever recolour it, in
1429
- `VariantPicker.vue`), so the swatch never resizes when it gains a ring. The 3px gap between the
1430
- ring and the disc is the shape's own padding (`p-0.75`, `--spacing` × 0.75 = 0.1875rem = 3px —
1431
- the same dynamic-spacing technique `RadioGroup`'s `mt-0.75` and `gap-x-2.5` already use), which
1432
- is also what lets the inner disc fill the remaining space with a plain `size-full` rather than a
1433
- second literal measurement. */
1434
- @utility eldra-variant-swatch-ring {
1435
- border-width: var(--eldra-variant-swatch-ring-width, 2px);
1436
- }
1437
-
1438
- /* The colour disc's own edge (spec "Variant picker" → Sizes, Swatch row: "the colour disc with a
1439
- 1px inner `border-strong` edge"; → Accessibility: "The disc edge uses `border-strong`, so pale
1440
- swatches (Ecru, Chalk) keep a 3:1 boundary (1.4.11)"). A real `border`, not `eldra-select-
1441
- swatch`'s inset `box-shadow` (that one is this package's *other* swatch, the 1rem one inside a
1442
- `Select` option row) — forced-colours mode can drop a decorative shadow, and the spec's own
1443
- "Forced colours: borders stay as real borders" rule is written for exactly this boundary, the
1444
- one WCAG 1.4.11 is about. Box-sizing keeps the disc's outer size unchanged by its own border, so
1445
- it still fills the ring's padded interior exactly via `size-full`. */
1446
- @utility eldra-variant-swatch-edge {
1447
- border-width: var(--eldra-variant-swatch-edge-width, 1px);
1448
- }
1449
-
1450
- /* The live "No image" placeholder's hatching (spec "Image" → Sizes, "Placeholder hatching" row:
1451
- "1px diagonal lines (135°) every 0.75rem in `border` at 70% strength over `surface`"). A
1452
- `repeating-linear-gradient` rather than an SVG or a `background-image` data URI: it is one flat
1453
- colour repeated, which a gradient expresses exactly and without shipping a raster/vector asset
1454
- for a one-pixel line. "70% strength" is `border` mixed with 30% transparency, the same
1455
- `color-mix(in oklab, …, transparent <n>%)` shape `eldra-skeleton`'s shimmer above already uses
1456
- for its own "at 60% strength" fill. The repeat distance is a variable with the spec's own
1457
- 0.75rem as its default rather than a literal in the gradient stops, so a consumer who wants a
1458
- finer or coarser hatch does not have to redeclare the whole gradient. */
1459
- @utility eldra-image-placeholder-hatch {
1460
- --eldra-image-hatch-gap: 0.75rem;
1461
- background-color: var(--color-surface);
1462
- background-image: repeating-linear-gradient(
1463
- 135deg,
1464
- color-mix(in oklab, var(--eldra-color-border), transparent 30%) 0,
1465
- color-mix(in oklab, var(--eldra-color-border), transparent 30%) 1px,
1466
- transparent 1px,
1467
- transparent var(--eldra-image-hatch-gap)
1468
- );
1469
- }
1470
-
1471
- /* A sold-out swatch's diagonal line (spec "Variant picker" → States, Sold out row: "2px diagonal
1472
- line in `text` with a 1.5px `background` halo, from 4px inside the top to 4px inside the bottom,
1473
- rotated 45°") is drawn in `VariantPicker.vue` as an inline `<svg>`, not a class-only utility —
1474
- the same reasoning as the pill's line above, and for an even sharper reason here: a first
1475
- version drew it with `background-color` (the line) plus a `box-shadow` (the halo), and *both*
1476
- properties are exactly the ones forced-colours mode empties out — the line vanished completely
1477
- under `forced-colors: active`, the one mode this indicator exists to survive (spec "Actions and
1478
- forms" → Forced colours; WCAG 1.4.1). An SVG `<line stroke="currentColor">` does not have that
1479
- problem: forced-colours remaps a stroke the same way it remaps a real border. Two stacked
1480
- `<line>`s (a wider one in `background`, first, then the spec's own 2px in `text`) draw the halo
1481
- and the line together, at the endpoints the spec's "4px inside the top … rotated 45°" geometry
1482
- actually produces — worked out once in that component's own comment rather than re-derived by a
1483
- consumer reading a CSS transform. */
1484
-
1485
- /* --- Avatar ---------------------------------------------------------------------------------- */
1486
-
1487
- /* Avatar initials/"+N" type (spec "Avatar" → Sizes: the Initials column is "38% of diameter" —
1488
- 0.76rem/0.95rem/1.33rem/2.28rem at sm/md/lg/xl, none of which matches a token in tokens.json —
1489
- plus "Initials weight 600, letter-spacing 0.02em" from the paragraph under the table). Weight
1490
- reuses `--eldra-text-label-weight` (600, the same token every other 600-weight utility in this
1491
- file reads); the size and the 0.02em tracking have no token of their own, so — like
1492
- `text-button-lg`'s 1.0625rem — each is a per-component CSS variable with the spec's own number
1493
- as its literal default. One line (`/ 1`): initials are a single short run, never a wrapped
1494
- paragraph, so there is no ratio to name. `AvatarGroup`'s "+N" counter reuses the same size at
1495
- `sm` (`Avatar.vue`'s own comment) rather than a fifth type style, since the spec's States table
1496
- gives it the identical treatment ("Initials / '+N' … `text`"). */
1497
- @utility text-avatar-initials-sm {
1498
- font-family: var(--eldra-font-body);
1499
- font-size: var(--eldra-avatar-initials-size-sm, 0.76rem);
1500
- line-height: 1;
1501
- font-weight: var(--tw-font-weight, var(--eldra-text-label-weight));
1502
- letter-spacing: var(--eldra-avatar-initials-tracking, 0.02em);
1503
- }
1504
- @utility text-avatar-initials-md {
1505
- font-family: var(--eldra-font-body);
1506
- font-size: var(--eldra-avatar-initials-size-md, 0.95rem);
1507
- line-height: 1;
1508
- font-weight: var(--tw-font-weight, var(--eldra-text-label-weight));
1509
- letter-spacing: var(--eldra-avatar-initials-tracking, 0.02em);
1510
- }
1511
- @utility text-avatar-initials-lg {
1512
- font-family: var(--eldra-font-body);
1513
- font-size: var(--eldra-avatar-initials-size-lg, 1.33rem);
1514
- line-height: 1;
1515
- font-weight: var(--tw-font-weight, var(--eldra-text-label-weight));
1516
- letter-spacing: var(--eldra-avatar-initials-tracking, 0.02em);
1517
- }
1518
- @utility text-avatar-initials-xl {
1519
- font-family: var(--eldra-font-body);
1520
- font-size: var(--eldra-avatar-initials-size-xl, 2.28rem);
1521
- line-height: 1;
1522
- font-weight: var(--tw-font-weight, var(--eldra-text-label-weight));
1523
- letter-spacing: var(--eldra-avatar-initials-tracking, 0.02em);
1524
- }
1525
-
1526
- /* The user-icon fallback's size (spec "Avatar" → Sizes, closing paragraph: "Icon: 1.5rem in lg
1527
- (scale proportionally)"). Only `lg` is given a literal number; the other three are that same
1528
- icon-to-diameter ratio (1.5 / 3.5, the `lg` diameter) applied to their own diameter (2rem,
1529
- 2.5rem, 6rem) and rounded to three decimal places — precise enough for a stroke this thin, and
1530
- consistent with how every other one-off number in this file is a per-component variable with a
1531
- literal default rather than a class-level arbitrary value. Registered in the `size` class group
1532
- in `src/utils/cx.ts` (the same group `size-*` itself belongs to), so `classes.icon: 'size-6'`
1533
- replaces one of these instead of landing beside it. */
1534
- @utility eldra-avatar-icon-sm {
1535
- width: var(--eldra-avatar-icon-size-sm, 0.857rem);
1536
- height: var(--eldra-avatar-icon-size-sm, 0.857rem);
1537
- }
1538
- @utility eldra-avatar-icon-md {
1539
- width: var(--eldra-avatar-icon-size-md, 1.071rem);
1540
- height: var(--eldra-avatar-icon-size-md, 1.071rem);
1541
- }
1542
- @utility eldra-avatar-icon-lg {
1543
- width: var(--eldra-avatar-icon-size-lg, 1.5rem);
1544
- height: var(--eldra-avatar-icon-size-lg, 1.5rem);
1545
- }
1546
- @utility eldra-avatar-icon-xl {
1547
- width: var(--eldra-avatar-icon-size-xl, 2.571rem);
1548
- height: var(--eldra-avatar-icon-size-xl, 2.571rem);
1549
- }
1550
-
1551
- /* --- Container and section -------------------------------------------------------------------- */
1552
-
1553
- /* Spec "Container and section" → Do/Don't: "Do alternate none and surface between neighbouring
1554
- blocks instead of adding divider lines" and the acceptance criterion this rule is actually for —
1555
- two adjacent same-background `Section`s read as one continuous band, not as two spacing bands
1556
- stacked with a visible seam. `Section.vue` marks its own ground on every background (including
1557
- `none`) with `data-section-bg`, and a second `Section` immediately after one with the same value
1558
- drops its own top padding (`Section` splits its spacing into separate `pt-*`/`pb-*` utilities
1559
- instead of the `py-*` shorthand for exactly this: only the top half is ever touched, so the
1560
- bottom edge — what the *next* sibling's own top-drop reads against — never moves).
1561
-
1562
- This is plain CSS, not `@utility`, and deliberately outside every `@layer`: Tailwind's utilities
1563
- compile into `@layer utilities` (`@import 'tailwindcss'` declares the layer order), and a rule
1564
- with no layer at all always wins the cascade over every layered rule regardless of selector
1565
- specificity or source order (CSS Cascade Layers) — which is what lets `Section`'s own `spacing`
1566
- stay an ordinary, always-overridable `pt-*`/`pb-*` utility while this one rule still beats it
1567
- whenever two matching grounds are adjacent. `src/__tests__/sectionAdjacentBackground.spec.ts`
1568
- compiles this file and asserts the built rule wins. Five explicit pairs, not a single generic
1569
- attribute selector, because CSS has no "same value as the previous sibling" selector — only an
1570
- exact value can be matched on each side. */
1571
- [data-section-bg='none'] + [data-section-bg='none'],
1572
- [data-section-bg='surface'] + [data-section-bg='surface'],
1573
- [data-section-bg='surface-strong'] + [data-section-bg='surface-strong'],
1574
- [data-section-bg='primary'] + [data-section-bg='primary'],
1575
- [data-section-bg='accent'] + [data-section-bg='accent'] {
1576
- padding-top: 0;
1577
- }
1578
-
1579
- /* --- Dialog ---------------------------------------------------------------------------------- */
1580
-
1581
- /* The title (spec "Dialog" → Sizes): "heading font, 1.25rem / 1.3, weight 600, letter-spacing
1582
- -0.01em." Weight and tracking already read `h3`'s own tokens exactly (600, -0.01em — the same
1583
- reuse `text-logo-wordmark` makes for its own weight/tracking); only the 1.25rem size and 1.3 line
1584
- sit between two type styles with no token of their own, so, like `Button`'s `lg` size, they are
1585
- per-component variables with the spec's literals as defaults. */
1586
- @utility text-dialog-title {
1587
- font-family: var(--eldra-font-heading);
1588
- font-size: var(--eldra-dialog-title-size, 1.25rem);
1589
- line-height: var(--eldra-dialog-title-line, 1.3);
1590
- font-weight: var(--tw-font-weight, var(--eldra-text-h3-weight));
1591
- letter-spacing: var(--eldra-text-h3-tracking);
1592
- }
1593
-
1594
- /* The panel's own box (spec "Dialog" → Sizes): "Width min(32rem, 100vw − 2rem) (sm: min(24rem,
1595
- 100vw − 2rem))" and "Max height 100vh − 4rem; content beyond that scrolls inside the dialog." The
1596
- width pair keep the viewport clamp inside the utility itself, unlike `eldra-select-panel-width`'s
1597
- `min()` — a Dialog's own width is a fixed spec number a consumer can override with
1598
- `--eldra-dialog-width(-sm)`, and the clamp must still apply to whatever that override is, not
1599
- only to the default. Each is in Tailwind's own `w`/`max-h` group (`src/utils/cx.ts`), so a
1600
- consumer's `classes.panel: 'w-full'` replaces the clamp instead of landing beside it. */
1601
- @utility eldra-dialog-width {
1602
- width: min(var(--eldra-dialog-width, 32rem), calc(100vw - 2rem));
1603
- }
1604
- @utility eldra-dialog-width-sm {
1605
- width: min(var(--eldra-dialog-width-sm, 24rem), calc(100vw - 2rem));
1606
- }
1607
- @utility eldra-dialog-max-height {
1608
- max-height: var(--eldra-dialog-max-height, calc(100vh - 4rem));
1609
- }
1610
-
1611
- /* The dialog's own entrance (spec "Dialog" → Behaviour & motion): "Enter: opacity 0 -> 1, 0.5rem
1612
- rise and scale 0.98 -> 1, duration-slow (250ms) ease-out. Exit: instant." The house pattern is
1613
- `eldra-popover-in` above — fade plus scale over a token duration, nothing to do for reduced
1614
- motion because the duration token itself zeroes — but Dialog's own reduced-motion row is not
1615
- "nothing moves, so the token collapsing to 0ms already reads as done": the spec asks for "a plain
1616
- fade over duration-base (200ms), linear," a real, *visible* fade, the same exception
1617
- `animate-eldra-pulse` makes for the Button spinner and for the same reason — reading
1618
- `--eldra-duration-base` here would zero it too and the dialog would just snap into view with no
1619
- fade at all. So the reduced-motion state is a second keyframe set with its own literal, always-on
1620
- 200ms, applied through `motion-reduce:` (`Dialog.vue`: `animate-eldra-dialog-in
1621
- motion-reduce:animate-eldra-dialog-in-reduced`) rather than through the zeroing token — exactly
1622
- the two-utility shape `animate-eldra-spin`/`animate-eldra-pulse` already uses, registered in the
1623
- same `animate` merge group in `src/utils/cx.ts`. Exit needs no utility at all: the spec's own
1624
- "instant by default" is simply not animating the close. */
1625
- @keyframes eldra-dialog-in {
1626
- from {
1627
- opacity: 0;
1628
- transform: translateY(0.5rem) scale(0.98);
1629
- }
1630
- to {
1631
- opacity: 1;
1632
- transform: none;
1633
- }
1634
- }
1635
- @keyframes eldra-dialog-in-reduced {
1636
- from {
1637
- opacity: 0;
1638
- }
1639
- to {
1640
- opacity: 1;
1641
- }
1642
- }
1643
- @utility animate-eldra-dialog-in {
1644
- animation: eldra-dialog-in var(--eldra-duration-slow) var(--eldra-ease-out);
1645
- }
1646
- @utility animate-eldra-dialog-in-reduced {
1647
- animation: eldra-dialog-in-reduced 200ms linear;
1648
- }
1649
- /* --- Tabs ---------------------------------------------------------------------------------- */
1650
-
1651
- /* Spec "Tabs" → Anatomy, point 1: "scrolls horizontally when the tabs overflow (never wraps),
1652
- scrollbar hidden." Tailwind has no stock utility for hiding a scrollbar — `overflow-x-auto`
1653
- alone still shows the browser's own bar — so this is one small utility rather than an arbitrary
1654
- value repeated at the call site. Registered in `src/utils/cx.ts` under its own class group (see
1655
- `custom-utility-coverage.spec.ts`), the same shape as `target-min`/`target-touch` above: no stock
1656
- Tailwind group covers "show/hide a scrollbar" either. */
1657
- @utility eldra-scrollbar-hide {
1658
- scrollbar-width: none;
1659
- -ms-overflow-style: none;
1660
- &::-webkit-scrollbar {
1661
- display: none;
1662
- }
1663
- }
1664
-
1665
- /* --- Drawer ----------------------------------------------------------------------------------- */
1666
-
1667
- /* The title (spec "Drawer" → Sizes): "heading font, 1.25rem / 1.3, weight 600, letter-spacing
1668
- -0.01em" — the exact same numbers as `text-dialog-title` above, but its own variable pair
1669
- rather than a shared one: a consumer restyling one component's title should not have to think
1670
- about whether the other one moves with it. */
1671
- @utility text-drawer-title {
1672
- font-family: var(--eldra-font-heading);
1673
- font-size: var(--eldra-drawer-title-size, 1.25rem);
1674
- line-height: var(--eldra-drawer-title-line, 1.3);
1675
- font-weight: var(--tw-font-weight, var(--eldra-text-h3-weight));
1676
- letter-spacing: var(--eldra-text-h3-tracking);
1677
- }
1678
-
1679
- /* The panel's own width (spec "Drawer" → Properties, `width` row: "Maximum width; always capped
1680
- at 100% of the viewport") plus the full-screen mobile variant (spec "Drawer" → Mobile: "On any
1681
- viewport narrower than the drawer's width, the drawer is full width and full height"; Global
1682
- Constraints: the full-screen variants of Drawer, Lightbox and Search modal are one of only two
1683
- rules in the whole spec measured on the **viewport**, not a container — operator decision,
1684
- 2026-09-25). `--eldra-drawer-width` is a literal per-component variable (the spec's own 28rem
1685
- default sits between two tokens and has none of its own, the same shape as `--eldra-dialog-
1686
- width`), set from the `width` prop on the panel's own inline style; the viewport cap lives
1687
- inside the utility itself so it still applies to whatever a consumer sets that variable to, not
1688
- only to the default. The `48rem` edge below is a plain `@media` query — Tailwind's own `md`
1689
- *viewport* breakpoint, the same one `max-md:text-control-mobile` above measures — never a
1690
- `@container` query: this is one of the two rules in the whole design spec that measures the
1691
- viewport on purpose, not the enclosing block. */
1692
- @utility eldra-drawer-width {
1693
- width: min(var(--eldra-drawer-width, 28rem), 100vw);
1694
- @media (width < 48rem) {
1695
- width: 100vw;
1696
- }
1697
- }
1698
-
1699
- /* Drawer: the side gutter and the header row's least height from their variables, and the edge paddings, each with
1700
- the device's safe area added (zero unless the page sets `viewport-fit=cover`). One property per utility, so a
1701
- consumer's `px-*`, `pt-*`, `pb-*` or `min-h-*` replaces exactly the one it names. */
1702
- @utility eldra-drawer-gutter {
1703
- padding-inline: calc(
1704
- var(--eldra-drawer-gutter, var(--eldra-space-6)) +
1705
- max(env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px))
1706
- );
1707
- }
1708
-
1709
- @utility eldra-drawer-header-height {
1710
- min-height: calc(
1711
- var(--eldra-drawer-header-height, var(--eldra-space-16)) + env(safe-area-inset-top, 0px)
1712
- );
1713
- }
1714
-
1715
- @utility eldra-drawer-header-top {
1716
- padding-top: calc(
1717
- var(--eldra-drawer-header-padding, var(--eldra-space-4)) + env(safe-area-inset-top, 0px)
1718
- );
1719
- }
1720
-
1721
- @utility eldra-drawer-header-bottom {
1722
- padding-bottom: var(--eldra-drawer-header-padding, var(--eldra-space-4));
1723
- }
1724
-
1725
- @utility eldra-drawer-body-bottom {
1726
- padding-bottom: calc(var(--eldra-space-6) + env(safe-area-inset-bottom, 0px));
1727
- }
1728
-
1729
- @utility eldra-drawer-footer-bottom {
1730
- padding-bottom: calc(var(--eldra-space-5) + env(safe-area-inset-bottom, 0px));
1731
- }
1732
-
1733
- /* The drawer's own entrance (spec "Drawer" → Behaviour & motion): "Enter: slides in from its edge
1734
- (translateX(100%) -> 0 for right, -100% -> 0 for left), duration-slow (250ms) ease-out. Exit:
1735
- instant." Applied to the `<dialog>` root itself (`Drawer.vue`: `animate-eldra-drawer-in-{side}
1736
- motion-reduce:animate-eldra-dialog-in-reduced`), the same placement `Dialog`'s own
1737
- `animate-eldra-dialog-in` uses — the root is a full-viewport transparent flex box that only
1738
- docks its (opaque) panel child to one edge, so translating the root by a full 100% of its own
1739
- (viewport) width slides the panel fully off-screen and back regardless of the panel's own
1740
- width, while the `::backdrop` (a sibling box, not a descendant) is untouched by the transform
1741
- and simply stays put. Reduced motion reuses `Dialog`'s own `eldra-dialog-in-reduced` keyframe
1742
- rather than a third one of its own: the spec's "plain fade over duration-base (200ms), linear"
1743
- is the identical opacity-only fade Dialog's reduced-motion state already draws, so a second
1744
- keyframe with the same two declarations would only be a second name for the same rule. Exit
1745
- needs no utility at all, matching "instant by default" the same way Dialog's own exit does. */
1746
- @keyframes eldra-drawer-in-right {
1747
- from {
1748
- transform: translateX(100%);
1749
- }
1750
- to {
1751
- transform: translateX(0);
1752
- }
1753
- }
1754
- @keyframes eldra-drawer-in-left {
1755
- from {
1756
- transform: translateX(-100%);
1757
- }
1758
- to {
1759
- transform: translateX(0);
1760
- }
1761
- }
1762
- @utility animate-eldra-drawer-in-right {
1763
- animation: eldra-drawer-in-right var(--eldra-duration-slow) var(--eldra-ease-out);
1764
- }
1765
- @utility animate-eldra-drawer-in-left {
1766
- animation: eldra-drawer-in-left var(--eldra-duration-slow) var(--eldra-ease-out);
1767
- }
1768
-
1769
- /* --- Search modal ------------------------------------------------------------------------------ */
1770
-
1771
- /* The field's own type (spec "Search modal" → Sizes, Field row): "1.0625rem text" (desktop and
1772
- tablet); mobile reuses `text-control-mobile`'s existing 1rem (`Input`'s own "the field text is
1773
- 1rem below 48rem, so iOS never zooms into a focused field" rule applies here too), composed
1774
- alongside this one the same way `Input`'s own `FIELD_TEXT.md` pairs `text-control` with
1775
- `max-md:text-control-mobile` — two whole utilities, not one bundling a media query, because the
1776
- mobile number already has a name. 1.0625rem sits between two type-scale steps with no token of
1777
- its own, so, like `text-button-lg`'s identical number, it is a per-component variable with the
1778
- spec's literal as its default. */
1779
- @utility text-search-modal-field {
1780
- font-family: var(--eldra-font-body);
1781
- font-size: var(--eldra-search-modal-field-size, 1.0625rem);
1782
- line-height: var(--eldra-control-line-height, 1.5rem);
1783
- font-weight: var(--tw-font-weight, var(--eldra-text-body-weight));
1784
- }
1785
-
1786
- /* The foot's own text (spec "Search modal" → Sizes, Foot row): "0.75rem `muted` text on `surface`".
1787
- Plain body weight and family — unlike `text-overline` (also 0.75rem), this is sentence-case hint
1788
- copy, not an uppercase, tracked label — so it is its own utility rather than that one plus an
1789
- override. */
1790
- @utility text-search-modal-foot {
1791
- font-family: var(--eldra-font-body);
1792
- font-size: var(--eldra-search-modal-foot-size, 0.75rem);
1793
- line-height: var(--eldra-search-modal-foot-line, 1.4);
1794
- font-weight: var(--tw-font-weight, var(--eldra-text-body-weight));
1795
- }
1796
-
1797
- /* The foot's key caps (spec, same row): "monospace 0.6875rem, min-width 1.25rem" — smaller than
1798
- `text-search-kbd` (the Search bar's own inline `/` chip, 0.75rem), for a denser row of three
1799
- hints. */
1800
- @utility text-search-modal-kbd {
1801
- font-family: var(--eldra-font-mono);
1802
- font-size: var(--eldra-search-modal-kbd-size, 0.6875rem);
1803
- line-height: 1rem;
1804
- font-weight: var(--tw-font-weight, var(--eldra-text-body-weight));
1805
- }
1806
-
1807
- /* The dialog's own box (spec "Search modal" → Sizes, Dialog row): "min(40rem, 100vw − 2rem) wide;
1808
- max-height min(40rem, 100vh − 6rem); top margin 8vh, centred horizontally … radius-lg, 1px
1809
- border, shadow-md" on desktop and tablet (viewport ≥ 48rem); "Full screen: 100% × 100%, no
1810
- margin, radius or border" below it. One utility per CSS property — the same shape as `eldra-
1811
- dialog-width`/`-max-height` — each bundling its own `@media (width < 48rem)` override, the exact
1812
- technique `eldra-drawer-width` above already documents and this file's own
1813
- `search-modal.spec.ts` compiles and asserts directly, rather than a class-level arbitrary value:
1814
- a consumer overriding `classes.root` then replaces the desktop clamp *and* its full-screen
1815
- exception together, never just one half of the rule. The radius/border/shadow removal below
1816
- 48rem is plain `max-md:` utilities in `SearchModal.vue` instead — three independent, already-
1817
- token-driven stock groups (`rounded`, `border-w`, `shadow`) that do not need a fourth bundled
1818
- name of their own the way the three interdependent geometry numbers here do. */
1819
- @utility eldra-search-modal-width {
1820
- width: min(var(--eldra-search-modal-width, 40rem), calc(100vw - 2rem));
1821
- @media (width < 48rem) {
1822
- width: 100vw;
1823
- }
1824
- }
1825
- @utility eldra-search-modal-max-height {
1826
- max-height: min(var(--eldra-search-modal-max-height, 40rem), calc(100vh - 6rem));
1827
- @media (width < 48rem) {
1828
- max-height: 100vh;
1829
- }
1830
- }
1831
- @utility eldra-search-modal-position {
1832
- margin: 8vh auto auto;
1833
- @media (width < 48rem) {
1834
- margin: 0;
1835
- }
1836
- }
1837
-
1838
- /* --- Toast ------------------------------------------------------------------------------------ */
1839
-
1840
- /* The region's own width (spec "Toast" -> Sizes, "Region" row): "min(24rem, 100vw - 2rem) wide ...
1841
- 1rem from the right and bottom edges." Same shape as `eldra-dialog-width`: the viewport clamp
1842
- lives inside the utility itself, so a consumer's `--eldra-toast-width` override still gets
1843
- capped on a narrow screen. In Tailwind's own `w` group (`src/utils/cx.ts`), so `classes.root:
1844
- 'w-full'` replaces the clamp instead of landing beside it. */
1845
- @utility eldra-toast-width {
1846
- width: min(var(--eldra-toast-width, 24rem), calc(100vw - 2rem));
1847
- }
1848
-
1849
- /* The title (spec "Toast" -> Sizes, "Title" row): "0.9375rem, weight 600." The weight already
1850
- reads the label token (600, the same reuse `text-stock-status` makes for its own weight); the
1851
- size sits between two type-scale steps with none of its own — the same shape as `text-price-sm`'s
1852
- 0.9375rem and `text-dialog-title`'s 1.25rem — so it is a per-component variable with that literal
1853
- default. No line-height is given, so, like `text-stock-status`'s 1.4, it gets one too. */
1854
- @utility text-toast-title {
1855
- font-family: var(--eldra-font-body);
1856
- font-size: var(--eldra-toast-title-size, 0.9375rem);
1857
- line-height: var(--eldra-toast-title-line, 1.4);
1858
- font-weight: var(--tw-font-weight, var(--eldra-text-label-weight));
1859
- }
1860
-
1861
- /* The toast's own entrance (spec "Toast" -> Behaviour & motion): "Enter: fade in with a 0.5rem
1862
- rise, duration-base (200ms) ease-out." Unlike `Dialog`, the spec's reduced-motion row here only
1863
- asks that toasts "appear and disappear without movement" — not, as `Dialog`'s own row demands, a
1864
- still-visible fade at a literal duration — so the ordinary zeroing `--eldra-duration-base`
1865
- already satisfies it (an instant appearance has no movement to speak of) and this needs no
1866
- second `-reduced` keyframe. Exit is not animated (no CSS at all): the spec asks for a 150ms fade
1867
- out on removal, but animating a `v-for` departure needs Vue's `<TransitionGroup>`, which nothing
1868
- else in this package uses and which is difficult to drive reliably under `vi.useFakeTimers()`;
1869
- `Toaster` removes a dismissed toast from the DOM immediately, the same "instant by default"
1870
- call `Dialog`'s own exit makes (see its Deviations entry) for the equivalent trade-off. */
1871
- @keyframes eldra-toast-in {
1872
- from {
1873
- opacity: 0;
1874
- transform: translateY(0.5rem);
1875
- }
1876
- to {
1877
- opacity: 1;
1878
- transform: none;
1879
- }
1880
- }
1881
- @utility animate-eldra-toast-in {
1882
- animation: eldra-toast-in var(--eldra-duration-base) var(--eldra-ease-out);
1883
- }
1884
- /* --- Carousel -------------------------------------------------------------------------------- */
1885
-
1886
- /* A slide's own width (spec "Carousel" → Sizes, "Slide width" row): "default 80% of the track;
1887
- product rows `(100% − 3 × 1rem) / 4` from 64rem block width, 3 per view from 48rem, ~80% below
1888
- 48rem (peek); single-slide galleries 100%" — one formula, `(100% - (perView - 1) * gap) /
1889
- perView`, covers every row of that table: `perView: 1` gives 100%, `perView: 4` with a 1rem gap
1890
- gives the product-row formula verbatim, and the default `perView: 1.25` gives "~80%" (literally
1891
- 80% minus a fifth of the gap, which is what the spec's own "~" already concedes).
1892
- `--eldra-carousel-per-view` is set per container-query breakpoint by `eldra-carousel-track`
1893
- below, from the three inline custom properties `carouselPerViewStyle` (`useCarousel.ts`) binds
1894
- on the track — this utility only ever reads the one resolved variable, so `Carousel.vue` and
1895
- `Lightbox` share one definition. The gap defaults to
1896
- `--eldra-space-4` (1rem), the same token `gap-4` on the track itself resolves to, so the two
1897
- numbers in the formula can never drift apart even if a consumer overrides one. */
1898
- @utility eldra-carousel-slide {
1899
- flex: none;
1900
- scroll-snap-align: start;
1901
- width: calc(
1902
- (100% - (var(--eldra-carousel-per-view, 1) - 1) *
1903
- var(--eldra-carousel-gap, var(--eldra-space-4))) /
1904
- var(--eldra-carousel-per-view, 1)
1905
- );
1906
- }
1907
-
1908
- /* The track's own per-view switch: picks one of the three inline custom properties
1909
- `carouselPerViewStyle` (`useCarousel.ts`) binds on the track into the single
1910
- `--eldra-carousel-per-view` its slides read above.
1911
-
1912
- The values arrive as an inline style rather than as Tailwind arbitrary-property classes on
1913
- purpose (bug, fixed 2026-09-27 — see `carouselPerViewStyle`'s own comment, the README's
1914
- Deviations entry and the CHANGELOG): a class name built by interpolating a number is never in
1915
- the text Tailwind scans, so a consumer's build emitted no rule for it and every carousel
1916
- rendered one full-width slide. Keeping the *breakpoints* here, in static CSS, is the other half
1917
- of that fix: nothing about this rule depends on what a component happened to render.
1918
-
1919
- 48rem and 64rem are written out, not `var(--container-tablet)`/`var(--container-content)`,
1920
- for the reason this file's own header states: a `@container` condition may not contain `var()`.
1921
- They are the same two edges Tailwind's own `@tablet:`/`@content:` variants compile to, and
1922
- `src/__tests__/containerQueryBreakpoints.spec.ts` is what keeps the pair in step.
1923
-
1924
- The `var()` fallback chains repeat, in CSS, the narrowest-first resolution
1925
- `carouselPerViewStyle` already does in JavaScript (which always writes all three): they are what
1926
- makes a consumer setting only `--eldra-carousel-per-view-base` by hand behave the same way. */
1927
- @utility eldra-carousel-track {
1928
- --eldra-carousel-per-view: var(--eldra-carousel-per-view-base, 1);
1929
- @container (width >= 48rem) {
1930
- --eldra-carousel-per-view: var(
1931
- --eldra-carousel-per-view-md,
1932
- var(--eldra-carousel-per-view-base, 1)
1933
- );
1934
- }
1935
- @container (width >= 64rem) {
1936
- --eldra-carousel-per-view: var(
1937
- --eldra-carousel-per-view-lg,
1938
- var(--eldra-carousel-per-view-md, var(--eldra-carousel-per-view-base, 1))
1939
- );
1940
- }
1941
- }
1942
-
1943
- /* A dot's own visual (spec "Carousel" → Sizes, Dot row: "1.5rem square target; visible dot 0.5rem
1944
- circle with a 1.5px ring; current: 1.25rem × 0.5rem pill; no gap between dot targets"). The
1945
- 1.5rem target itself is a plain `size-6` button in `Carousel.vue`; this utility is only the
1946
- dot's *visible* inner shape, switched by the button's own `aria-current` — a shape change as
1947
- well as a colour change (spec → States: "shape change, not colour alone", 1.4.1), so the
1948
- component computes no separate "current" class. The ring's width has no stock Tailwind border
1949
- step (1.5px sits between `border-1`'s 1px and `border-2`'s 2px), so — like `eldra-field-border`'s
1950
- own width — it is a per-component variable with that literal default. Motion: width and colour
1951
- change over `duration-fast` `ease-out` (spec → Behaviour & motion), nothing under reduced
1952
- motion — a shape/colour swap has no "motion" to remove, only a transition to skip. */
1953
- @utility eldra-carousel-dot {
1954
- display: block;
1955
- width: var(--eldra-carousel-dot-size, 0.5rem);
1956
- height: var(--eldra-carousel-dot-size, 0.5rem);
1957
- border-radius: var(--radius-full);
1958
- background-color: transparent;
1959
- box-shadow: inset 0 0 0 var(--eldra-carousel-dot-ring, 1.5px) var(--color-border-strong);
1960
- transition:
1961
- width var(--eldra-duration-fast) var(--eldra-ease-out),
1962
- background-color var(--eldra-duration-fast) var(--eldra-ease-out),
1963
- box-shadow var(--eldra-duration-fast) var(--eldra-ease-out);
1964
- @media (prefers-reduced-motion: reduce) {
1965
- transition: none;
1966
- }
1967
- [aria-current='true'] > & {
1968
- width: 1.25rem;
1969
- background-color: var(--color-text);
1970
- box-shadow: inset 0 0 0 var(--eldra-carousel-dot-ring, 1.5px) var(--color-text);
1971
- }
1972
- @media (forced-colors: active) {
1973
- box-shadow: none;
1974
- border: var(--eldra-carousel-dot-ring, 1.5px) solid CanvasText;
1975
- [aria-current='true'] > & {
1976
- background-color: CanvasText;
1977
- }
1978
- }
1979
- }
1980
-
1981
- /* --- Lightbox ----------------------------------------------------------------------------- */
1982
-
1983
- /* The viewer's own entrance (spec "Lightbox" → Behaviour & motion: "Enter: fade in over
1984
- duration-slow (250ms) ease-out. Moving between images scrolls smoothly." / "Reduced motion: the
1985
- viewer fades in over duration-base (200ms) with no movement, and image changes are instant.").
1986
- Unlike `Dialog`'s own entrance, there is no rise or scale here — the spec gives the Lightbox a
1987
- plain fade, full stop, so this needs its own (simpler) keyframe rather than reusing
1988
- `eldra-dialog-in`. The reduced-motion state, though, is the exact "plain opacity fade over
1989
- duration-base (200ms), linear" `eldra-dialog-in-reduced` already draws for `Dialog` and `Drawer`
1990
- — reused rather than given a third identical keyframe, the same call `Drawer`'s own comment on
1991
- that utility makes. */
1992
- @keyframes eldra-lightbox-in {
1993
- from {
1994
- opacity: 0;
1995
- }
1996
- to {
1997
- opacity: 1;
1998
- }
1999
- }
2000
- @utility animate-eldra-lightbox-in {
2001
- animation: eldra-lightbox-in var(--eldra-duration-slow) var(--eldra-ease-out);
2002
- }
2003
-
2004
- /* --- Range slider ----------------------------------------------------------------------------- */
2005
-
2006
- /* The gutter that keeps a thumb — its focus ring and its pointer target included — inside the
2007
- control (spec "Range slider" → Anatomy): a thumb is centred on its value, so the one at `min`
2008
- hangs half its own width past the start of the track, and **two** things hang further still. Its
2009
- ring reaches `--eldra-focus-offset` + `--eldra-focus-width` past the circle; its 2.5.8 target
2010
- (the `::after` box below) is centred on the circle too, so it reaches half the target from the
2011
- thumb's centre — 22px of it below the tablet width, where that target is `--eldra-target-touch`.
2012
-
2013
- The gutter is therefore the **larger** of the two reaches, per side. With only the ring's
2014
- allowance, the maximum thumb at `max` pushed its target 8px past the end of the document at a
2015
- 320px viewport: a horizontal scrollbar on a phone with nothing to pan to, against WCAG 1.4.10
2016
- and the spec section's own 320px acceptance line (`__tests__/rangeSliderRing.browser.spec.ts`
2017
- measures `scrollWidth` against `clientWidth` there, which is the condition the criterion states).
2018
- Clipping the control is not the alternative: that would cut the focus ring, which is the other
2019
- thing this reservation exists to protect.
2020
-
2021
- Sized from the variables themselves, never from the numbers they happen to hold today: a
2022
- consumer enlarging the thumb or the targets moves the gutter with them, and so does a raised ring
2023
- token — a `Carousel` sets `--eldra-focus-offset: 4px` for its slides and a plain custom property
2024
- inherits into everything inside it (the same lesson as `Tabs`' own list reservation).
2025
-
2026
- `48rem` is written out for the reason this file's header states, and it is the same edge the
2027
- target itself switches on below, so the two can never disagree about which target is in force. */
2028
- @utility eldra-range-gutter {
2029
- padding-inline: max(
2030
- calc(
2031
- var(--eldra-range-thumb-size, 1.25rem) / 2 + var(--eldra-focus-offset) +
2032
- var(--eldra-focus-width)
2033
- ),
2034
- calc(var(--eldra-target-min) / 2)
2035
- );
2036
- @container (width < 48rem) {
2037
- padding-inline: max(
2038
- calc(
2039
- var(--eldra-range-thumb-size, 1.25rem) / 2 + var(--eldra-focus-offset) +
2040
- var(--eldra-focus-width)
2041
- ),
2042
- calc(var(--eldra-target-touch) / 2)
2043
- );
2044
- }
2045
- }
2046
-
2047
- /* The gutter a filter panel's price range uses instead (spec "Filter panel" → Sizes, Histogram
2048
- and Range rows: "inset 0.625rem on each side"): the thumb's own radius plus the focus ring's
2049
- reach — never the target half, which is what pushed the track to two thirds of a 15rem sidebar.
2050
- The ring reach stays so a focused end thumb is not clipped by a scrolling drawer body, which
2051
- makes the inset 0.875rem rather than the spec's 0.625rem; the README's Deviations entry says so. */
2052
- @utility eldra-range-gutter-thumb {
2053
- padding-inline: calc(
2054
- var(--eldra-range-thumb-size, 1.25rem) / 2 + var(--eldra-focus-offset) +
2055
- var(--eldra-focus-width)
2056
- );
2057
- }
2058
-
2059
- /* The rail: the band a pointer press lands in (spec "Range slider" → Sizes, Rail row: "`target-
2060
- touch` (2.75rem) below the tablet breakpoint, `target-min` (1.5rem) from it"). The touch size is
2061
- on the *band*, not on the thumb alone, so there is a 44px-tall target across the whole control
2062
- rather than two 44px circles that overlap — and therefore fight — when the range is narrow.
2063
-
2064
- `48rem` is written out rather than `var(--container-tablet)` for the reason this file's header
2065
- states: a `@container` condition may not contain `var()`. It is the same edge Tailwind's own
2066
- `@max-tablet:` variant compiles to, measured against the component's own root (`RangeSlider.vue`
2067
- is a `@container`), which is the spec's own breakpoint rule — the width of the block the control
2068
- sits in, not the viewport. */
2069
- @utility eldra-range-rail {
2070
- min-height: var(--eldra-target-min);
2071
- @container (width < 48rem) {
2072
- min-height: var(--eldra-target-touch);
2073
- }
2074
- }
2075
-
2076
- /* The track and the filled range share one height (spec → Anatomy items 3 and 4: "0.375rem tall,
2077
- `radius-full`"). A literal per-component variable, like `--eldra-carousel-dot-size`: the spec's
2078
- 0.375rem is a bar thickness, which no shared token carries. */
2079
- @utility eldra-range-track {
2080
- height: var(--eldra-range-track-height, 0.375rem);
2081
- }
2082
-
2083
- /* A thumb (spec → Anatomy item 5: "1.25rem, `background` fill, 1.5px `border-strong` edge,
2084
- `shadow-sm`", and → States for the hover and dragging halo). Three things live here rather than
2085
- in the component's classes, because each of them is a literal the spec gives and a variable a
2086
- consumer should be able to move: the circle's size, its 1.5px edge (no stock Tailwind border step
2087
- sits between 1px and 2px — the same call `eldra-carousel-dot`'s ring makes), and the halo.
2088
-
2089
- `::before` is the halo, drawn outside the circle and faded in on hover and while dragging — an
2090
- outline or a box-shadow would collide with `eldra-focus`, which owns this element's `outline`
2091
- *and* its `box-shadow`. `::after` is the pointer target, centred on the thumb at `target-min`
2092
- and growing to `target-touch` below the tablet breakpoint, so the thumb itself satisfies 2.5.8
2093
- at every width (the rail above is the band that satisfies it across the whole control). Neither
2094
- pseudo-element paints anything the thumb's own shape does not already say, so both are invisible
2095
- to assistive technology by construction. */
2096
- @utility eldra-range-thumb {
2097
- width: var(--eldra-range-thumb-size, 1.25rem);
2098
- height: var(--eldra-range-thumb-size, 1.25rem);
2099
- border-width: var(--eldra-range-thumb-border-width, 1.5px);
2100
- &::before {
2101
- content: '';
2102
- position: absolute;
2103
- inset: calc(-1 * var(--eldra-range-thumb-halo, 0.25rem));
2104
- border-radius: var(--radius-full);
2105
- background-color: color-mix(in oklab, var(--color-text), transparent 92%);
2106
- opacity: 0;
2107
- transition: opacity var(--eldra-duration-fast) var(--eldra-ease-out);
2108
- }
2109
- &:hover::before {
2110
- opacity: 1;
2111
- }
2112
- &[data-dragging='true']::before {
2113
- opacity: 1;
2114
- background-color: color-mix(in oklab, var(--color-text), transparent 86%);
2115
- }
2116
- &[aria-disabled='true']::before {
2117
- display: none;
2118
- }
2119
- &::after {
2120
- content: '';
2121
- position: absolute;
2122
- top: 50%;
2123
- left: 50%;
2124
- width: var(--eldra-target-min);
2125
- height: var(--eldra-target-min);
2126
- translate: -50% -50%;
2127
- }
2128
- @container (width < 48rem) {
2129
- &::after {
2130
- width: var(--eldra-target-touch);
2131
- height: var(--eldra-target-touch);
2132
- }
2133
- }
2134
- @media (prefers-reduced-motion: reduce) {
2135
- &::before {
2136
- transition: none;
2137
- }
2138
- }
2139
- }
2140
-
2141
- /* --- Filter panel ----------------------------------------------------------------------------- */
2142
-
2143
- /* A size-system sub-heading (spec "Filter panel" → Sizes, Size-system sub-heading row: "0.75rem
2144
- weight 600, uppercase, 0.06em letter spacing, `muted`"). It is nearly `text-overline` — same
2145
- size, same weight, same transform — and differs only in tracking: the overline token's 0.12em is
2146
- a label over a section, and the same spacing inside a 15rem sidebar pushes "SOCKS (EU)" onto two
2147
- lines. So the size, line and weight read the existing tokens and the tracking is a
2148
- per-component variable with the spec's own 0.06em as its default. */
2149
- @utility text-filter-subheading {
2150
- font-family: var(--eldra-font-body);
2151
- font-size: var(--eldra-text-overline-size);
2152
- line-height: var(--eldra-text-overline-line);
2153
- font-weight: var(--tw-font-weight, var(--eldra-text-label-weight));
2154
- letter-spacing: var(--eldra-filter-subheading-tracking, 0.06em);
2155
- text-transform: uppercase;
2156
- }
2157
-
2158
- /* A swatch tile's count (spec → Sizes, Swatch tile row: "count 0.75rem"). The one 0.75rem number
2159
- in the panel, and the overline token is the only type style at that size — but an overline is
2160
- uppercase with 0.12em of tracking, which on a column of tabular digits reads as a gap between
2161
- them. So it borrows that token's size, the caption's line ratio and the body weight, and adds
2162
- neither transform nor tracking of its own. */
2163
- @utility text-filter-tile-count {
2164
- font-family: var(--eldra-font-body);
2165
- font-size: var(--eldra-text-overline-size);
2166
- line-height: var(--eldra-text-caption-line);
2167
- font-weight: var(--tw-font-weight, var(--eldra-text-body-weight));
2168
- }
2169
-
2170
- /* A colour swatch's own edge (spec → Sizes, Swatch row: "Swatch 1.5rem circle with a 1px inner
2171
- edge of `text` at 22%"). A real `border`, not a `box-shadow`, for the reason
2172
- `eldra-variant-swatch-edge` records: forced-colours mode drops a decorative shadow and keeps a
2173
- real border, and this boundary is the one WCAG 1.4.11 is about — a pale swatch has no other edge.
2174
-
2175
- The width and the colour are bundled in one utility because they are one decision: the colour is
2176
- not a token role (it is `text` at a fraction) and nothing else in the package draws it, so a
2177
- consumer moves it through `--eldra-filter-swatch-edge-width` or replaces the whole rule through
2178
- `classes.swatch`. Deliberately not `border-strong`, which `VariantPicker`'s own disc uses: a
2179
- filter panel draws these at 1.5rem in a dense column where the stronger line reads as a second
2180
- ring beside the selected one. */
2181
- @utility eldra-filter-swatch-edge {
2182
- border-width: var(--eldra-filter-swatch-edge-width, 1px);
2183
- border-color: color-mix(in oklab, var(--color-text), transparent 78%);
2184
- }
2185
-
2186
- /* The ring a selected swatch gains (spec → Sizes, Selected swatch ring: "A 2px `background` gap,
2187
- then a 1.5px `text` ring around the swatch"). The gap is the shape's own padding and the ring is
2188
- a real border on it, kept at this one constant width in **every** state — transparent at rest —
2189
- so the swatch never resizes when it is picked and the column never shifts under the pointer. The
2190
- same shape `eldra-variant-swatch-ring` has, at this panel's own 1.5px rather than that
2191
- component's 2px. */
2192
- @utility eldra-filter-swatch-ring {
2193
- border-width: var(--eldra-filter-swatch-ring-width, 1.5px);
2194
- }
2195
-
2196
- /* One histogram bar (spec → Sizes, Histogram row: "Bar min height 2px, top corners 1px"). The
2197
- minimum height is what keeps an empty bucket visible as an empty bucket rather than as nothing
2198
- at all, which is the difference between "no products here" and "no data"; the 1px top corners
2199
- are the only rounding, because the bars sit on the histogram's own baseline. Two literals with
2200
- no token between them — a bar is thinner than any radius or spacing step the scale carries — so
2201
- each is a per-component variable with the spec's number as its default. */
2202
- @utility eldra-filter-histogram-bar {
2203
- min-height: var(--eldra-filter-histogram-bar-min, 2px);
2204
- border-start-start-radius: var(--eldra-filter-histogram-bar-radius, 1px);
2205
- border-start-end-radius: var(--eldra-filter-histogram-bar-radius, 1px);
2206
- }
2207
-
2208
- /* --- Nav menu --------------------------------------------------------------------------------- */
2209
-
2210
- /* The gap under the bar is the panel's own padding, so a hovering pointer never leaves the menu. */
2211
- @utility eldra-nav-menu-panel {
2212
- padding-top: var(--eldra-nav-menu-offset, var(--eldra-space-2));
2213
- }
2214
-
2215
- @utility eldra-nav-menu-dropdown {
2216
- width: max-content;
2217
- min-width: var(--eldra-nav-menu-dropdown-min, 14rem);
2218
- max-width: min(var(--eldra-nav-menu-dropdown-max, 24rem), calc(100vw - 2rem));
2219
- }
2220
-
2221
- @utility eldra-nav-menu-columns {
2222
- grid-template-columns: repeat(
2223
- auto-fit,
2224
- minmax(min(100%, var(--eldra-nav-menu-column-min, 12rem)), 1fr)
2225
- );
2226
- }
2227
-
2228
- /* NavMenu's phone menu: every top-level row's least height, and a panel's links indented beneath their row. */
2229
- @utility eldra-nav-menu-drawer-row {
2230
- min-height: var(--eldra-nav-menu-drawer-row-height, calc(var(--spacing) * 14));
2231
- }
2232
-
2233
- @utility eldra-nav-menu-drawer-nest {
2234
- padding-inline-start: var(--eldra-nav-menu-drawer-indent, var(--eldra-space-4));
2235
- }
11
+ @import './theme.css';
12
+ @import './utilities.css';