opui-css 3.3.4 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. package/CHANGELOG.md +235 -0
  2. package/LICENSE +21 -21
  3. package/MIGRATING.md +105 -0
  4. package/README.md +66 -29
  5. package/astro/index.ts +46 -0
  6. package/components/AGENTS.md +247 -0
  7. package/components/Accordion/Accordion.astro +42 -0
  8. package/components/Anchor/Anchor.astro +51 -0
  9. package/components/Avatar/Avatar.astro +44 -0
  10. package/components/Badge/Badge.astro +54 -0
  11. package/components/Button/Button.astro +45 -0
  12. package/components/ButtonGroup/ButtonGroup.astro +29 -0
  13. package/components/Callout/Callout.astro +75 -0
  14. package/components/Card/Card.astro +38 -0
  15. package/components/Checkbox/Checkbox.astro +76 -0
  16. package/components/Checkbox/CheckboxInput.astro +32 -0
  17. package/components/Chip/Chip.astro +37 -0
  18. package/components/ClassicSelect/ClassicSelect.astro +83 -0
  19. package/components/DescriptionList/Description.astro +12 -0
  20. package/components/DescriptionList/DescriptionList.astro +22 -0
  21. package/components/DescriptionList/Item.astro +12 -0
  22. package/components/DescriptionList/Term.astro +12 -0
  23. package/components/DescriptionList/index.ts +12 -0
  24. package/components/Dialog/Dialog.astro +43 -0
  25. package/components/Divider/Divider.astro +14 -0
  26. package/components/Drawer/Drawer.astro +49 -0
  27. package/components/Drawer/DrawerFooter.astro +14 -0
  28. package/components/Drawer/DrawerHeader.astro +31 -0
  29. package/components/FieldDescription/FieldDescription.astro +13 -0
  30. package/components/FieldGroup/FieldGroup.astro +31 -0
  31. package/components/FieldLegend/FieldLegend.astro +15 -0
  32. package/components/FieldSet/FieldSet.astro +15 -0
  33. package/components/Form/Form.astro +15 -0
  34. package/components/IconButton/IconButton.astro +26 -0
  35. package/components/List/List.astro +36 -0
  36. package/components/ListItem/ListItem.astro +118 -0
  37. package/components/Progress/Progress.astro +40 -0
  38. package/components/Radio/Radio.astro +70 -0
  39. package/components/Radio/RadioInput.astro +24 -0
  40. package/components/Range/Range.astro +136 -0
  41. package/components/Select/Select.astro +106 -0
  42. package/components/Switch/Switch.astro +101 -0
  43. package/components/Switch/SwitchInput.astro +25 -0
  44. package/components/Table/Body.astro +13 -0
  45. package/components/Table/Cell.astro +13 -0
  46. package/components/Table/Column.astro +15 -0
  47. package/components/Table/ColumnGroup.astro +13 -0
  48. package/components/Table/Head.astro +13 -0
  49. package/components/Table/HeaderCell.astro +13 -0
  50. package/components/Table/Row.astro +13 -0
  51. package/components/Table/Table.astro +15 -0
  52. package/components/Table/index.ts +20 -0
  53. package/components/Tabs/Tabs.astro +28 -0
  54. package/components/Tabs/TabsItem.astro +47 -0
  55. package/components/Tabs/TabsPanel.astro +21 -0
  56. package/components/Tabs/TabsTab.astro +19 -0
  57. package/components/Tabs/index.ts +14 -0
  58. package/components/TextField/TextField.astro +128 -0
  59. package/components/Textarea/Textarea.astro +106 -0
  60. package/components/Toast/Toast.astro +42 -0
  61. package/components/ToggleButton/ToggleButton.astro +53 -0
  62. package/components/ToggleGroup/ToggleGroup.astro +49 -0
  63. package/components/Tooltip/Tooltip.astro +30 -0
  64. package/{src/core → core}/normalize.css +194 -196
  65. package/core/palette.css +59 -0
  66. package/{src/core → core}/utils.css +71 -60
  67. package/css/components/accordion.css +174 -0
  68. package/css/components/anchor.css +27 -0
  69. package/{src/themes/theme-two → css}/components/avatar.css +65 -68
  70. package/css/components/badge.css +107 -0
  71. package/css/components/button-group.css +179 -0
  72. package/css/components/button.css +215 -0
  73. package/css/components/callout.css +109 -0
  74. package/css/components/card.css +117 -0
  75. package/css/components/checkbox.css +205 -0
  76. package/{src/themes/theme-one → css}/components/chip.css +87 -135
  77. package/{src/themes/theme-two/components/definition-list.css → css/components/description-list.css} +77 -68
  78. package/{src/themes/theme-two → css}/components/dialog.css +68 -59
  79. package/css/components/divider.css +20 -0
  80. package/css/components/drawer.css +171 -0
  81. package/css/components/form.css +146 -0
  82. package/css/components/icon-button.css +139 -0
  83. package/{src/themes/theme-two → css}/components/link.css +21 -21
  84. package/{src/themes/theme-two → css}/components/list.css +345 -318
  85. package/{src/themes/theme-one → css}/components/progress.css +97 -83
  86. package/css/components/radio.css +172 -0
  87. package/css/components/range.css +337 -0
  88. package/{src/themes/theme-two → css}/components/select.css +169 -162
  89. package/{src/themes/theme-two → css}/components/spinner.css +37 -38
  90. package/{src/themes/theme-two → css}/components/switch.css +268 -225
  91. package/css/components/table.css +179 -0
  92. package/css/components/tabs.css +77 -0
  93. package/css/components/text-field.css +450 -0
  94. package/css/components/text-input.css +53 -0
  95. package/{src/themes/theme-two → css}/components/textarea.css +24 -25
  96. package/css/components/toast.css +161 -0
  97. package/css/components/toggle-button.css +87 -0
  98. package/css/components/toggle-group.css +56 -0
  99. package/css/components/tooltip.css +67 -0
  100. package/css/components/typography.css +585 -0
  101. package/{src/themes/theme-two → css}/components.css +41 -37
  102. package/{src/themes/theme-two → css}/imports.css +16 -16
  103. package/css/js/checkbox.js +21 -0
  104. package/css/js/toast.js +94 -0
  105. package/css/theme.css +132 -0
  106. package/dist/op.css +1001 -32
  107. package/dist/op.css.map +1 -0
  108. package/dist/opui.components.css +5135 -0
  109. package/dist/opui.components.css.map +1 -0
  110. package/dist/opui.css +6604 -0
  111. package/dist/opui.css.map +1 -0
  112. package/env.d.ts +14 -0
  113. package/open-props.css +9 -0
  114. package/package.json +64 -55
  115. package/dist/theme-one/components.css +0 -3869
  116. package/dist/theme-one/theme-one.css +0 -4424
  117. package/dist/theme-two/components.css +0 -3591
  118. package/dist/theme-two/theme-two.css +0 -4141
  119. package/src/open-props.css +0 -10
  120. package/src/themes/theme-one/components/accordion.css +0 -172
  121. package/src/themes/theme-one/components/alert.css +0 -85
  122. package/src/themes/theme-one/components/avatar.css +0 -68
  123. package/src/themes/theme-one/components/badge.css +0 -101
  124. package/src/themes/theme-one/components/button-group.css +0 -69
  125. package/src/themes/theme-one/components/button.css +0 -281
  126. package/src/themes/theme-one/components/card.css +0 -82
  127. package/src/themes/theme-one/components/checkbox-radio.css +0 -123
  128. package/src/themes/theme-one/components/definition-list.css +0 -68
  129. package/src/themes/theme-one/components/dialog.css +0 -59
  130. package/src/themes/theme-one/components/divider.css +0 -7
  131. package/src/themes/theme-one/components/field-group.css +0 -83
  132. package/src/themes/theme-one/components/field.css +0 -494
  133. package/src/themes/theme-one/components/icon-button.css +0 -40
  134. package/src/themes/theme-one/components/link.css +0 -21
  135. package/src/themes/theme-one/components/list.css +0 -318
  136. package/src/themes/theme-one/components/range.css +0 -121
  137. package/src/themes/theme-one/components/rich-text.css +0 -210
  138. package/src/themes/theme-one/components/select.css +0 -163
  139. package/src/themes/theme-one/components/snackbar.css +0 -148
  140. package/src/themes/theme-one/components/spinner.css +0 -38
  141. package/src/themes/theme-one/components/switch.css +0 -225
  142. package/src/themes/theme-one/components/tab-buttons.css +0 -120
  143. package/src/themes/theme-one/components/table.css +0 -92
  144. package/src/themes/theme-one/components/text-field.css +0 -57
  145. package/src/themes/theme-one/components/textarea.css +0 -25
  146. package/src/themes/theme-one/components/toggle-button-group.css +0 -135
  147. package/src/themes/theme-one/components/tooltip.css +0 -94
  148. package/src/themes/theme-one/components/typography.css +0 -209
  149. package/src/themes/theme-one/components.css +0 -37
  150. package/src/themes/theme-one/imports.css +0 -16
  151. package/src/themes/theme-one/theme.css +0 -163
  152. package/src/themes/theme-two/components/accordion.css +0 -172
  153. package/src/themes/theme-two/components/alert.css +0 -85
  154. package/src/themes/theme-two/components/badge.css +0 -101
  155. package/src/themes/theme-two/components/button-group.css +0 -50
  156. package/src/themes/theme-two/components/button.css +0 -229
  157. package/src/themes/theme-two/components/card.css +0 -82
  158. package/src/themes/theme-two/components/checkbox-radio.css +0 -123
  159. package/src/themes/theme-two/components/chip.css +0 -135
  160. package/src/themes/theme-two/components/divider.css +0 -7
  161. package/src/themes/theme-two/components/field-group.css +0 -83
  162. package/src/themes/theme-two/components/field.css +0 -281
  163. package/src/themes/theme-two/components/icon-button.css +0 -40
  164. package/src/themes/theme-two/components/progress.css +0 -83
  165. package/src/themes/theme-two/components/range.css +0 -121
  166. package/src/themes/theme-two/components/rich-text.css +0 -210
  167. package/src/themes/theme-two/components/snackbar.css +0 -148
  168. package/src/themes/theme-two/components/tab-buttons.css +0 -120
  169. package/src/themes/theme-two/components/table.css +0 -99
  170. package/src/themes/theme-two/components/text-field.css +0 -57
  171. package/src/themes/theme-two/components/toggle-button-group.css +0 -135
  172. package/src/themes/theme-two/components/tooltip.css +0 -94
  173. package/src/themes/theme-two/components/typography.css +0 -209
  174. package/src/themes/theme-two/theme.css +0 -158
@@ -1,83 +1,97 @@
1
- @layer components.root {
2
- :where(progress) {
3
- --_accent-color: var(--primary);
4
- --_bg-color: var(--surface-tonal);
5
-
6
- appearance: none;
7
- background-color: var(--_bg-color);
8
- border-radius: var(--border-radius, 0.25rem);
9
- border: 0;
10
- display: inline-block;
11
- block-size: var(--size-1);
12
- overflow: hidden;
13
- position: relative;
14
- vertical-align: baseline;
15
- inline-size: 100%;
16
-
17
- &::-webkit-progress-bar {
18
- border-radius: var(--border-radius, 0.25rem);
19
- background: none;
20
- }
21
-
22
- &[value]::-webkit-progress-value {
23
- background-color: var(--_accent-color);
24
-
25
- @media (prefers-reduced-motion: no-preference) {
26
- transition: inline-size 0.2s
27
- var(--ease-out-4, cubic-bezier(0, 0, 0.1, 1));
28
- }
29
- }
30
-
31
- &::-moz-progress-bar {
32
- background-color: var(--_accent-color);
33
- }
34
- }
35
-
36
- @media (prefers-reduced-motion: no-preference) {
37
- progress:indeterminate {
38
- background-color: var(--_bg-color);
39
-
40
- &::after {
41
- animation: indeterminate 2s linear infinite;
42
- background-color: var(--_accent-color);
43
- content: "";
44
- inset: 0 auto 0 0;
45
- position: absolute;
46
- will-change: inset-inline-start, inset-inline-end;
47
- }
48
-
49
- &[value]::-webkit-progress-value {
50
- background-color: transparent;
51
- }
52
-
53
- &::-moz-progress-bar {
54
- background-color: transparent;
55
- }
56
- }
57
-
58
- [dir="rtl"] {
59
- :where(progress):indeterminate {
60
- animation-direction: reverse;
61
-
62
- &::after {
63
- animation-direction: reverse;
64
- }
65
- }
66
- }
67
- }
68
-
69
- @keyframes indeterminate {
70
- 0% {
71
- left: -200%;
72
- right: 100%;
73
- }
74
- 60% {
75
- left: 107%;
76
- right: -8%;
77
- }
78
- 100% {
79
- left: 107%;
80
- right: -8%;
81
- }
82
- }
83
- }
1
+ @layer components.root {
2
+ :where(progress) {
3
+ --_accent-color: var(--primary);
4
+ --_bg-color: var(--surface-tonal);
5
+
6
+ appearance: none;
7
+ background-color: var(--_bg-color);
8
+ block-size: var(--size-1);
9
+ border: 0;
10
+ border-radius: var(--border-radius, 0.25rem);
11
+ display: inline-block;
12
+ inline-size: 100%;
13
+ overflow: hidden;
14
+ position: relative;
15
+ vertical-align: baseline;
16
+
17
+ /* Color */
18
+ &.filled {
19
+ --_bg-color: var(--surface-filled);
20
+ }
21
+
22
+ &.default {
23
+ --_bg-color: var(--surface-default);
24
+ }
25
+
26
+ &.tonal {
27
+ --_bg-color: var(--surface-tonal);
28
+ }
29
+
30
+ &::-webkit-progress-bar {
31
+ background: none;
32
+ border-radius: var(--border-radius, 0.25rem);
33
+ }
34
+
35
+ &[value]::-webkit-progress-value {
36
+ background-color: var(--_accent-color);
37
+
38
+ @media (prefers-reduced-motion: no-preference) {
39
+ transition: inline-size 0.2s var(--ease-out-4, cubic-bezier(0, 0, 0.1, 1));
40
+ }
41
+ }
42
+
43
+ &::-moz-progress-bar {
44
+ background-color: var(--_accent-color);
45
+ }
46
+ }
47
+
48
+ @media (prefers-reduced-motion: no-preference) {
49
+ progress:indeterminate {
50
+ background-color: var(--_bg-color);
51
+
52
+ &::after {
53
+ animation: indeterminate 2s linear infinite;
54
+ background-color: var(--_accent-color);
55
+ content: "";
56
+ inset: 0 auto 0 0;
57
+ position: absolute;
58
+ will-change: inset-inline-start, inset-inline-end;
59
+ }
60
+
61
+ &[value]::-webkit-progress-value {
62
+ background-color: transparent;
63
+ }
64
+
65
+ &::-moz-progress-bar {
66
+ background-color: transparent;
67
+ }
68
+ }
69
+
70
+ [dir="rtl"] {
71
+ :where(progress):indeterminate {
72
+ animation-direction: reverse;
73
+
74
+ &::after {
75
+ animation-direction: reverse;
76
+ }
77
+ }
78
+ }
79
+ }
80
+
81
+ @keyframes indeterminate {
82
+ 0% {
83
+ inset-inline-start: -200%;
84
+ inset-inline-end: 100%;
85
+ }
86
+
87
+ 60% {
88
+ inset-inline-start: 107%;
89
+ inset-inline-end: -8%;
90
+ }
91
+
92
+ 100% {
93
+ inset-inline-start: 107%;
94
+ inset-inline-end: -8%;
95
+ }
96
+ }
97
+ }
@@ -0,0 +1,172 @@
1
+ @layer components.root {
2
+ label.radio {
3
+ --_input-size: 1.125rem;
4
+ --_indicator-size: 50%;
5
+
6
+ align-items: center;
7
+ color: var(--text-primary);
8
+ cursor: pointer;
9
+ display: inline-grid;
10
+ gap: 0 var(--size-2);
11
+ grid-auto-columns: auto;
12
+ grid-auto-flow: column;
13
+ inline-size: fit-content;
14
+ line-height: 1.5;
15
+ transform: translateZ(0);
16
+ user-select: none;
17
+
18
+ /* Disabled */
19
+ &:has([disabled]) {
20
+ cursor: not-allowed;
21
+ opacity: 0.64;
22
+ user-select: none;
23
+
24
+ input {
25
+ cursor: not-allowed;
26
+ }
27
+ }
28
+
29
+ /* Required dot */
30
+ &:has(:invalid) {
31
+ .label:after {
32
+ color: var(--red);
33
+ content: "*";
34
+ inset: 0 -0.25ex auto auto;
35
+ position: absolute;
36
+ }
37
+ }
38
+
39
+ /* Label */
40
+ .label {
41
+ color: var(--text-primary);
42
+ font-size: var(--font-size-05);
43
+ grid-column: 2;
44
+ grid-row: 1;
45
+ padding-inline: 0 1ex;
46
+ position: relative;
47
+ }
48
+
49
+ /* End text */
50
+ :where(.end-text) {
51
+ color: var(--text-muted);
52
+ font-size: var(--font-size-0);
53
+ grid-column: 2;
54
+ grid-row: 2;
55
+ line-height: 1.5;
56
+ z-index: 1;
57
+ }
58
+
59
+ /* Stacked layout */
60
+ &.stack {
61
+ grid-auto-columns: unset;
62
+ justify-items: center;
63
+
64
+ .label {
65
+ grid-column: 1/-1;
66
+ grid-row: 2;
67
+ margin-block-start: var(--size-1);
68
+ padding-inline: 1ex;
69
+
70
+ /* Required dot */
71
+ &::after {
72
+ inset: 0 -0.25ex auto auto;
73
+ }
74
+ }
75
+
76
+ .end-text {
77
+ grid-column: 1/-1;
78
+ grid-row: 3;
79
+ }
80
+ }
81
+
82
+ /* Input */
83
+ input[type="radio"] {
84
+ appearance: none;
85
+ aspect-ratio: 1;
86
+ background-color: var(--surface-default);
87
+ block-size: var(--_input-size);
88
+ border: 1px solid var(--field-border-color);
89
+ border-radius: var(--radius-round);
90
+ box-sizing: border-box;
91
+ cursor: pointer;
92
+ display: grid;
93
+ inline-size: var(--_input-size);
94
+ margin: 0;
95
+ padding: 0;
96
+ place-items: center;
97
+ position: relative;
98
+
99
+ &:checked {
100
+ background-color: var(--primary);
101
+ border-color: var(--primary);
102
+ }
103
+
104
+ /* Dot */
105
+ &::after {
106
+ background-color: var(--primary-contrast);
107
+ block-size: var(--_indicator-size);
108
+ border-radius: var(--radius-round);
109
+ content: "";
110
+ inline-size: var(--_indicator-size);
111
+ margin: auto;
112
+ opacity: 0;
113
+ }
114
+
115
+ &:checked::after {
116
+ opacity: 1;
117
+ }
118
+
119
+ &::before {
120
+ --highlight-size: 175%;
121
+ }
122
+ }
123
+
124
+ /* Sizes */
125
+ &.small {
126
+ input[type="radio"] {
127
+ --_input-size: var(--size-3);
128
+
129
+ }
130
+ }
131
+
132
+ &.large {
133
+ input[type="radio"] {
134
+ --_input-size: var(--size-4);
135
+
136
+ }
137
+ }
138
+
139
+ /* Validation */
140
+ &[data-invalid],
141
+ &:has(:user-invalid) {
142
+ --palette-source: oklch(0.58 0.21 var(--hue-red));
143
+
144
+ :where(.end-text) {
145
+ color: var(--primary);
146
+ }
147
+ }
148
+
149
+ /* Touch devices */
150
+ @media (pointer: coarse) {
151
+ input[type="radio"] {
152
+ block-size: var(--size-4);
153
+ inline-size: var(--size-4);
154
+ }
155
+ }
156
+
157
+ @media (forced-colors: active) {
158
+ input[type="radio"] {
159
+ border: 1px solid CanvasText;
160
+
161
+ &:checked {
162
+ background-color: SelectedItem;
163
+ border-color: SelectedItem;
164
+
165
+ &::after {
166
+ background-color: SelectedItemText;
167
+ }
168
+ }
169
+ }
170
+ }
171
+ }
172
+ }
@@ -0,0 +1,337 @@
1
+ @layer components.root {
2
+ :where(.range) {
3
+ display: grid;
4
+ gap: var(--size-1) 0;
5
+ /* Two-column base so the optional .value cell can sit next to the
6
+ label on row 1. Children that span the full width keep using
7
+ `grid-column: 1/-1`, so this is backwards compatible. */
8
+ grid-template-columns: 1fr auto;
9
+ position: relative;
10
+
11
+ .label {
12
+ color: var(--text-primary);
13
+ font-size: var(--font-size-05);
14
+ font-weight: 600;
15
+ grid-column: 1;
16
+ grid-row: 1;
17
+ }
18
+
19
+ /* Live current-value readout. Pairs with the <output> element
20
+ rendered by the Range component (or hand-written .value markup). */
21
+ :where(.value) {
22
+ color: var(--text-muted);
23
+ font-size: var(--font-size-0);
24
+ font-variant-numeric: tabular-nums;
25
+ font-weight: 600;
26
+ grid-column: 2;
27
+ grid-row: 1;
28
+ line-height: 1.5;
29
+ text-align: end;
30
+ }
31
+
32
+ .start-text {
33
+ color: var(--text-muted);
34
+ font-size: var(--font-size-0);
35
+ grid-column: 1/-1;
36
+ grid-row: 2;
37
+ line-height: 1.5;
38
+ }
39
+
40
+ :where(.end-text) {
41
+ color: var(--text-muted);
42
+ font-size: var(--font-size-0);
43
+ grid-column: 1/-1;
44
+ grid-row: 5;
45
+ line-height: 1.5;
46
+ }
47
+
48
+ /* Datalist (tick mark labels) */
49
+ :where(datalist) {
50
+ color: var(--text-muted);
51
+ display: flex;
52
+ font-size: var(--font-size-0);
53
+ grid-column: 1/-1;
54
+ grid-row: 4;
55
+ justify-content: space-between;
56
+ margin-top: calc(var(--size-1) * -1);
57
+ padding-inline: calc(3ex / 2);
58
+
59
+ &>option {
60
+ display: flex;
61
+ inline-size: 0;
62
+ justify-content: center;
63
+ padding: 0;
64
+ white-space: nowrap;
65
+ }
66
+ }
67
+
68
+ /* Disabled */
69
+ &:has([disabled]) {
70
+ cursor: not-allowed;
71
+ opacity: 0.64;
72
+ user-select: none;
73
+
74
+ .label,
75
+ .value,
76
+ .start-text,
77
+ .end-text {
78
+ cursor: not-allowed;
79
+ }
80
+ }
81
+
82
+ /* Color */
83
+ &.filled input[type="range"] {
84
+ --_track-color: var(--surface-filled);
85
+ }
86
+
87
+ &.default input[type="range"] {
88
+ --_track-color: var(--surface-default);
89
+ }
90
+
91
+ &.tonal input[type="range"] {
92
+ --_track-color: var(--surface-tonal);
93
+ }
94
+
95
+ /* Orientation */
96
+ &.spread {
97
+ align-items: center;
98
+ column-gap: var(--size-4);
99
+ container-type: inline-size;
100
+ grid-template-columns: 1fr auto;
101
+
102
+ .label {
103
+ grid-column: 1;
104
+ grid-row: 1;
105
+ }
106
+
107
+ .start-text {
108
+ color: var(--text-muted);
109
+ display: block;
110
+ font-size: var(--font-size-0);
111
+ grid-column: 1;
112
+ grid-row: 2;
113
+ line-height: 1.5;
114
+ }
115
+
116
+ input[type="range"] {
117
+ align-self: center;
118
+ grid-column: 2;
119
+ grid-row: 1;
120
+ min-inline-size: 25ch;
121
+ }
122
+
123
+ /* In spread mode, the value sits below the slider in col 2
124
+ (where end-text would normally land). When end-text is also
125
+ present it shifts down a row to avoid collision. */
126
+ :where(.value) {
127
+ grid-column: 2;
128
+ grid-row: 2;
129
+ }
130
+
131
+ :where(.end-text) {
132
+ grid-column: 2;
133
+ grid-row: 2;
134
+ text-align: end;
135
+ }
136
+
137
+ datalist {
138
+ grid-column: 2;
139
+ grid-row: 2;
140
+ }
141
+
142
+ /* When both datalist and end-text exist, push end-text below the datalist
143
+ so they don't collide on the same grid cell. */
144
+ &:has(datalist) :where(.end-text) {
145
+ grid-row: 3;
146
+ }
147
+
148
+ &:has(.value) :where(.end-text) {
149
+ grid-row: 3;
150
+ }
151
+
152
+ &:has(.value):has(datalist) :where(.end-text) {
153
+ grid-row: 4;
154
+ }
155
+
156
+ @container (width < 400px) {
157
+ grid-template-columns: 1fr;
158
+
159
+ * {
160
+ grid-column: 1/-1;
161
+ }
162
+
163
+ .label {
164
+ grid-row: 1;
165
+ }
166
+
167
+ /* Share row 1 with the label: the label's text stays left-aligned
168
+ in its full-width cell, while the value shrinks to fit and
169
+ right-aligns. Visually reads as a "[name ........ value]" row. */
170
+ :where(.value) {
171
+ grid-row: 1;
172
+ justify-self: end;
173
+ text-align: end;
174
+ }
175
+
176
+ .start-text {
177
+ grid-row: 2;
178
+ }
179
+
180
+ input[type="range"] {
181
+ grid-column: 1/-1;
182
+ grid-row: 3;
183
+ }
184
+
185
+ datalist {
186
+ grid-column: 1/-1;
187
+ grid-row: 4;
188
+ }
189
+
190
+ :where(.end-text) {
191
+ grid-row: 5;
192
+ text-align: start;
193
+ }
194
+ }
195
+ }
196
+
197
+ /* Validation */
198
+ &[data-invalid],
199
+ &:has(:user-invalid) {
200
+ --_thumb-bg: var(--color-9);
201
+ --_thumb-highlight-color: oklch(from var(--color-9) 70% 100% h / 20%);
202
+
203
+ .start-text,
204
+ .end-text,
205
+ .value {
206
+ color: var(--color-9);
207
+ }
208
+ }
209
+
210
+ /* Range input */
211
+ :where(& > input[type="range"]) {
212
+ --_thumb-bg: var(--primary);
213
+ --_thumb-highlight-color: oklch(from var(--primary) 70% 100% h / 20%);
214
+ --_thumb-highlight-size: 0px;
215
+ --_thumb-offset: -1.125ex;
216
+ --_thumb-size: 3ex;
217
+ --_track-color: var(--field-border-color);
218
+ --_track-fill: 0%;
219
+ --_track-fill-color: var(--primary);
220
+ --_track-height: 0.75ex;
221
+ --_track-radius: 1e5px;
222
+
223
+ appearance: none;
224
+ background: transparent;
225
+ block-size: var(--size-4);
226
+ display: block;
227
+ grid-column: 1/-1;
228
+ grid-row: 3;
229
+ inline-size: 100%;
230
+ outline-offset: 1ex;
231
+
232
+ @media (hover: none) {
233
+ --_thumb-offset: -11.5px;
234
+ --_thumb-size: 30px;
235
+ }
236
+
237
+ /* Track */
238
+ &::-webkit-slider-runnable-track {
239
+ appearance: none;
240
+ background: linear-gradient(to right,
241
+ var(--_track-fill-color) var(--_track-fill, 0%),
242
+ var(--_track-color) 0%);
243
+ block-size: var(--_track-height);
244
+ border-radius: var(--_track-radius);
245
+ }
246
+
247
+ &::-moz-range-track {
248
+ appearance: none;
249
+ background: var(--_track-color);
250
+ block-size: var(--_track-height);
251
+ border-radius: var(--_track-radius);
252
+ }
253
+
254
+ &::-moz-range-progress {
255
+ appearance: none;
256
+ background: var(--_track-fill-color);
257
+ block-size: var(--_track-height);
258
+ border-radius: var(--_track-radius);
259
+ }
260
+
261
+ /* Ring */
262
+ &::-webkit-slider-thumb {
263
+ appearance: none;
264
+ background: var(--_thumb-bg);
265
+ block-size: var(--_thumb-size);
266
+ border: 3px solid var(--surface-default);
267
+ border-radius: 50%;
268
+ box-shadow: 0 0 0 var(--_thumb-highlight-size) var(--_thumb-highlight-color);
269
+ cursor: ew-resize;
270
+ inline-size: var(--_thumb-size);
271
+ margin-block-start: var(--_thumb-offset);
272
+
273
+ @media (prefers-reduced-motion: no-preference) {
274
+ transition: box-shadow 0.1s ease;
275
+ }
276
+
277
+ .fieldset-item:focus-within & {
278
+ border-color: var(--gray-14);
279
+ }
280
+ }
281
+
282
+ &::-moz-range-thumb {
283
+ appearance: none;
284
+ background: var(--_thumb-bg);
285
+ block-size: var(--_thumb-size);
286
+ border: 3px solid var(--surface-default);
287
+ border-radius: 50%;
288
+ box-shadow: 0 0 0 var(--_thumb-highlight-size) var(--_thumb-highlight-color);
289
+ cursor: ew-resize;
290
+ inline-size: var(--_thumb-size);
291
+ margin-block-start: var(--_thumb-offset);
292
+
293
+ @media (prefers-reduced-motion: no-preference) {
294
+ transition: box-shadow 0.1s ease;
295
+ }
296
+
297
+ .fieldset-item:focus-within & {
298
+ border-color: var(--gray-14);
299
+ }
300
+ }
301
+
302
+ /* Element state */
303
+ .range:has(:user-invalid) &,
304
+ .range[data-invalid] & {
305
+ --_track-fill-color: var(--color-9);
306
+ }
307
+
308
+ &:not([disabled]) {
309
+ &:hover {
310
+ --_thumb-highlight-size: var(--size-1);
311
+ }
312
+
313
+ &:active {
314
+ --_thumb-highlight-size: var(--size-2);
315
+ --_track-color: light-dark(oklch(from var(--field-border-color) calc(l * 0.9) c h),
316
+ oklch(from var(--field-border-color) calc(l * 1.1) c h));
317
+ }
318
+ }
319
+
320
+ &[disabled] {
321
+ --_thumb-bg: oklch(from var(--text-primary) l c h / 50%);
322
+ --_track-color: var(--field-border-color);
323
+
324
+ cursor: not-allowed;
325
+
326
+ &::-webkit-slider-thumb {
327
+ cursor: not-allowed;
328
+ }
329
+
330
+ &::-moz-range-thumb {
331
+ cursor: not-allowed;
332
+ }
333
+ }
334
+ }
335
+ }
336
+
337
+ }