material 3.7.1 → 3.7.3

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 (276) hide show
  1. package/README.md +2 -2
  2. package/dist/components/slider/features/controller.js +24 -8
  3. package/dist/elements/css/bottom-app-bar.css +1 -1
  4. package/dist/elements/css/bottom-app-bar.js +1 -1
  5. package/dist/elements/css/card.css +1 -1
  6. package/dist/elements/css/card.js +1 -1
  7. package/dist/elements/css/checkbox.css +1 -1
  8. package/dist/elements/css/checkbox.js +1 -1
  9. package/dist/elements/css/datepicker.css +1 -1
  10. package/dist/elements/css/datepicker.js +1 -1
  11. package/dist/elements/css/dialog.css +1 -1
  12. package/dist/elements/css/dialog.js +1 -1
  13. package/dist/elements/css/menu.css +1 -1
  14. package/dist/elements/css/menu.js +1 -1
  15. package/dist/elements/css/radios.css +1 -1
  16. package/dist/elements/css/radios.js +1 -1
  17. package/dist/elements/css/select.css +1 -1
  18. package/dist/elements/css/select.js +1 -1
  19. package/dist/elements/css/slider.css +1 -1
  20. package/dist/elements/css/slider.js +1 -1
  21. package/dist/elements/css/tabs.css +1 -1
  22. package/dist/elements/css/tabs.js +1 -1
  23. package/dist/elements/css/text-field.css +1 -1
  24. package/dist/elements/css/text-field.js +1 -1
  25. package/dist/elements/css/timepicker.css +1 -1
  26. package/dist/elements/css/timepicker.js +1 -1
  27. package/dist/elements/css/top-app-bar.css +1 -1
  28. package/dist/elements/css/top-app-bar.js +1 -1
  29. package/dist/elements/preupgrade/badge.css +1 -1
  30. package/dist/elements/preupgrade/bottom-app-bar.css +1 -1
  31. package/dist/elements/preupgrade/bottom-sheet.css +1 -1
  32. package/dist/elements/preupgrade/button-group.css +1 -1
  33. package/dist/elements/preupgrade/button.css +1 -1
  34. package/dist/elements/preupgrade/card.css +1 -1
  35. package/dist/elements/preupgrade/carousel.css +1 -1
  36. package/dist/elements/preupgrade/checkbox.css +1 -1
  37. package/dist/elements/preupgrade/chips.css +1 -1
  38. package/dist/elements/preupgrade/datepicker.css +1 -1
  39. package/dist/elements/preupgrade/dialog.css +1 -1
  40. package/dist/elements/preupgrade/divider.css +1 -1
  41. package/dist/elements/preupgrade/drawer.css +1 -1
  42. package/dist/elements/preupgrade/extended-fab.css +1 -1
  43. package/dist/elements/preupgrade/fab-menu.css +1 -1
  44. package/dist/elements/preupgrade/fab.css +1 -1
  45. package/dist/elements/preupgrade/icon-button.css +1 -1
  46. package/dist/elements/preupgrade/list.css +1 -1
  47. package/dist/elements/preupgrade/loading-indicator.css +1 -1
  48. package/dist/elements/preupgrade/menu.css +1 -1
  49. package/dist/elements/preupgrade/navigation-bar.css +1 -1
  50. package/dist/elements/preupgrade/navigation-rail.css +1 -1
  51. package/dist/elements/preupgrade/progress.css +1 -1
  52. package/dist/elements/preupgrade/radios.css +1 -1
  53. package/dist/elements/preupgrade/search.css +1 -1
  54. package/dist/elements/preupgrade/select.css +1 -1
  55. package/dist/elements/preupgrade/side-sheet.css +1 -1
  56. package/dist/elements/preupgrade/slider.css +1 -1
  57. package/dist/elements/preupgrade/snackbar.css +1 -1
  58. package/dist/elements/preupgrade/split-button.css +1 -1
  59. package/dist/elements/preupgrade/switch.css +1 -1
  60. package/dist/elements/preupgrade/tabs.css +1 -1
  61. package/dist/elements/preupgrade/text-field.css +1 -1
  62. package/dist/elements/preupgrade/timepicker.css +1 -1
  63. package/dist/elements/preupgrade/toolbar.css +1 -1
  64. package/dist/elements/preupgrade/tooltip.css +1 -1
  65. package/dist/elements/preupgrade/top-app-bar.css +1 -1
  66. package/dist/elements/preupgrade.css +1 -1
  67. package/dist/styles/badge.css +1 -1
  68. package/dist/styles/base-lite.css +1 -1
  69. package/dist/styles/base.css +1 -1
  70. package/dist/styles/bottom-app-bar.css +2 -2
  71. package/dist/styles/bottom-sheet.css +1 -1
  72. package/dist/styles/button-group.css +1 -1
  73. package/dist/styles/button.css +1 -1
  74. package/dist/styles/card.css +2 -2
  75. package/dist/styles/carousel.css +1 -1
  76. package/dist/styles/checkbox.css +2 -2
  77. package/dist/styles/chips.css +1 -1
  78. package/dist/styles/contrast.css +1 -1
  79. package/dist/styles/datepicker.css +2 -2
  80. package/dist/styles/dialog.css +2 -2
  81. package/dist/styles/divider.css +1 -1
  82. package/dist/styles/drawer.css +1 -1
  83. package/dist/styles/extended-fab.css +1 -1
  84. package/dist/styles/fab-menu.css +1 -1
  85. package/dist/styles/fab.css +1 -1
  86. package/dist/styles/icon-button.css +1 -1
  87. package/dist/styles/list.css +1 -1
  88. package/dist/styles/loading-indicator.css +1 -1
  89. package/dist/styles/menu.css +2 -2
  90. package/dist/styles/navigation-bar.css +1 -1
  91. package/dist/styles/navigation-rail.css +1 -1
  92. package/dist/styles/progress.css +1 -1
  93. package/dist/styles/radios.css +2 -2
  94. package/dist/styles/search.css +1 -1
  95. package/dist/styles/select.css +2 -2
  96. package/dist/styles/side-sheet.css +1 -1
  97. package/dist/styles/slider.css +2 -2
  98. package/dist/styles/snackbar.css +1 -1
  99. package/dist/styles/split-button.css +1 -1
  100. package/dist/styles/switch.css +1 -1
  101. package/dist/styles/tabs.css +2 -2
  102. package/dist/styles/text-field.css +2 -2
  103. package/dist/styles/timepicker.css +2 -2
  104. package/dist/styles/toolbar.css +1 -1
  105. package/dist/styles/tooltip.css +1 -1
  106. package/dist/styles/top-app-bar.css +2 -2
  107. package/dist/styles/typography.css +1 -1
  108. package/dist/styles/utilities.css +1 -1
  109. package/dist/styles.css +2 -2
  110. package/dist/themes/autumn-contrast.css +1 -1
  111. package/dist/themes/autumn.css +1 -1
  112. package/dist/themes/baseline-contrast.css +1 -1
  113. package/dist/themes/baseline.css +1 -1
  114. package/dist/themes/brownbeige-contrast.css +1 -1
  115. package/dist/themes/brownbeige.css +1 -1
  116. package/dist/themes/content-contrast.css +1 -1
  117. package/dist/themes/content.css +1 -1
  118. package/dist/themes/desert-contrast.css +1 -1
  119. package/dist/themes/desert.css +1 -1
  120. package/dist/themes/expressive-contrast.css +1 -1
  121. package/dist/themes/expressive.css +1 -1
  122. package/dist/themes/fidelity-contrast.css +1 -1
  123. package/dist/themes/fidelity.css +1 -1
  124. package/dist/themes/forest-contrast.css +1 -1
  125. package/dist/themes/forest.css +1 -1
  126. package/dist/themes/fruit-salad-contrast.css +1 -1
  127. package/dist/themes/fruit-salad.css +1 -1
  128. package/dist/themes/highcontrast-contrast.css +1 -1
  129. package/dist/themes/highcontrast.css +1 -1
  130. package/dist/themes/monochrome-contrast.css +1 -1
  131. package/dist/themes/monochrome.css +1 -1
  132. package/dist/themes/neutral-contrast.css +1 -1
  133. package/dist/themes/neutral.css +1 -1
  134. package/dist/themes/ocean-contrast.css +1 -1
  135. package/dist/themes/ocean.css +1 -1
  136. package/dist/themes/rainbow-contrast.css +1 -1
  137. package/dist/themes/rainbow.css +1 -1
  138. package/dist/themes/sageivory-contrast.css +1 -1
  139. package/dist/themes/sageivory.css +1 -1
  140. package/dist/themes/spring-contrast.css +1 -1
  141. package/dist/themes/spring.css +1 -1
  142. package/dist/themes/summer-contrast.css +1 -1
  143. package/dist/themes/summer.css +1 -1
  144. package/dist/themes/sunset-contrast.css +1 -1
  145. package/dist/themes/sunset.css +1 -1
  146. package/dist/themes/tealcaramel-contrast.css +1 -1
  147. package/dist/themes/tealcaramel.css +1 -1
  148. package/dist/themes/vibrant-contrast.css +1 -1
  149. package/dist/themes/vibrant.css +1 -1
  150. package/package.json +2 -1
  151. package/src/styles/abstract/_base.scss +0 -1
  152. package/src/styles/abstract/_direction.scss +121 -152
  153. package/src/styles/abstract/_emit.scss +7 -16
  154. package/src/styles/abstract/_floating-placement.scss +9 -10
  155. package/src/styles/abstract/_functions.scss +64 -79
  156. package/src/styles/abstract/_mixins.scss +355 -459
  157. package/src/styles/abstract/_theme.scss +122 -136
  158. package/src/styles/abstract/_variables.scss +320 -390
  159. package/src/styles/abstract/chips/_assist.scss +2 -3
  160. package/src/styles/abstract/chips/_filter.scss +2 -3
  161. package/src/styles/abstract/chips/_input.scss +2 -3
  162. package/src/styles/abstract/chips/_suggestion.scss +2 -3
  163. package/src/styles/base/_body-theme.scss +10 -15
  164. package/src/styles/base/_document.scss +10 -33
  165. package/src/styles/base/_reset.scss +20 -40
  166. package/src/styles/base/_tokens.scss +6 -21
  167. package/src/styles/base/_typescale-tokens.scss +12 -16
  168. package/src/styles/base/_typography.scss +28 -37
  169. package/src/styles/components/_badge.scss +171 -193
  170. package/src/styles/components/_bottom-app-bar.scss +72 -88
  171. package/src/styles/components/_bottom-sheet.scss +188 -232
  172. package/src/styles/components/_button-group.scss +140 -189
  173. package/src/styles/components/_button.scss +382 -478
  174. package/src/styles/components/_card.scss +349 -473
  175. package/src/styles/components/_carousel.scss +134 -156
  176. package/src/styles/components/_checkbox.scss +208 -247
  177. package/src/styles/components/_chips.scss +239 -304
  178. package/src/styles/components/_datepicker.scss +172 -220
  179. package/src/styles/components/_dialog.scss +428 -553
  180. package/src/styles/components/_divider.scss +37 -46
  181. package/src/styles/components/_drawer.scss +571 -678
  182. package/src/styles/components/_extended-fab.scss +263 -294
  183. package/src/styles/components/_fab-menu.scss +225 -267
  184. package/src/styles/components/_fab.scss +197 -218
  185. package/src/styles/components/_icon-button.scss +483 -588
  186. package/src/styles/components/_list.scss +115 -144
  187. package/src/styles/components/_loading-indicator.scss +23 -29
  188. package/src/styles/components/_menu.scss +543 -699
  189. package/src/styles/components/_navigation-bar.scss +189 -234
  190. package/src/styles/components/_navigation-rail.scss +256 -312
  191. package/src/styles/components/_progress.scss +60 -85
  192. package/src/styles/components/_radios.scss +170 -205
  193. package/src/styles/components/_search.scss +369 -455
  194. package/src/styles/components/_select.scss +78 -185
  195. package/src/styles/components/_side-sheet.scss +234 -292
  196. package/src/styles/components/_slider.scss +289 -367
  197. package/src/styles/components/_snackbar.scss +149 -198
  198. package/src/styles/components/_split-button.scss +139 -228
  199. package/src/styles/components/_switch.scss +282 -349
  200. package/src/styles/components/_tabs.scss +350 -547
  201. package/src/styles/components/_text-field.scss +788 -978
  202. package/src/styles/components/_timepicker.scss +435 -506
  203. package/src/styles/components/_toolbar.scss +178 -242
  204. package/src/styles/components/_tooltip.scss +152 -197
  205. package/src/styles/components/_top-app-bar.scss +206 -224
  206. package/src/styles/elements/_badge.scss +42 -61
  207. package/src/styles/elements/_bottom-app-bar.scss +14 -20
  208. package/src/styles/elements/_bottom-sheet.scss +0 -3
  209. package/src/styles/elements/_button-group.scss +80 -80
  210. package/src/styles/elements/_button.scss +72 -88
  211. package/src/styles/elements/_card.scss +48 -57
  212. package/src/styles/elements/_carousel.scss +2 -5
  213. package/src/styles/elements/_checkbox.scss +32 -43
  214. package/src/styles/elements/_chips.scss +18 -22
  215. package/src/styles/elements/_config.scss +11 -26
  216. package/src/styles/elements/_datepicker.scss +17 -22
  217. package/src/styles/elements/_dialog.scss +0 -3
  218. package/src/styles/elements/_divider.scss +11 -13
  219. package/src/styles/elements/_drawer.scss +9 -14
  220. package/src/styles/elements/_extended-fab.scss +36 -40
  221. package/src/styles/elements/_fab-menu.scss +21 -25
  222. package/src/styles/elements/_fab.scss +17 -20
  223. package/src/styles/elements/_field.scss +93 -114
  224. package/src/styles/elements/_icon-button.scss +34 -38
  225. package/src/styles/elements/_index.scss +0 -4
  226. package/src/styles/elements/_list.scss +19 -26
  227. package/src/styles/elements/_loading-indicator.scss +6 -9
  228. package/src/styles/elements/_menu.scss +0 -3
  229. package/src/styles/elements/_navigation-bar.scss +5 -9
  230. package/src/styles/elements/_navigation-rail.scss +10 -15
  231. package/src/styles/elements/_progress.scss +15 -18
  232. package/src/styles/elements/_radios.scss +24 -49
  233. package/src/styles/elements/_search.scss +19 -24
  234. package/src/styles/elements/_select.scss +4 -9
  235. package/src/styles/elements/_side-sheet.scss +0 -3
  236. package/src/styles/elements/_slider.scss +15 -35
  237. package/src/styles/elements/_snackbar.scss +0 -3
  238. package/src/styles/elements/_split-button.scss +33 -39
  239. package/src/styles/elements/_switch.scss +50 -90
  240. package/src/styles/elements/_tabs.scss +9 -13
  241. package/src/styles/elements/_text-field.scss +150 -178
  242. package/src/styles/elements/_timepicker.scss +0 -3
  243. package/src/styles/elements/_toolbar.scss +30 -35
  244. package/src/styles/elements/_tooltip.scss +0 -3
  245. package/src/styles/elements/_top-app-bar.scss +38 -45
  246. package/src/styles/main.scss +0 -15
  247. package/src/styles/themes/_autumn.scss +240 -258
  248. package/src/styles/themes/_base-theme.scss +96 -128
  249. package/src/styles/themes/_baseline.scss +273 -314
  250. package/src/styles/themes/_brownbeige.scss +242 -250
  251. package/src/styles/themes/_content.scss +240 -248
  252. package/src/styles/themes/_desert.scss +242 -250
  253. package/src/styles/themes/_expressive.scss +242 -250
  254. package/src/styles/themes/_fidelity.scss +240 -248
  255. package/src/styles/themes/_forest.scss +242 -259
  256. package/src/styles/themes/_fruit-salad.scss +242 -250
  257. package/src/styles/themes/_highcontrast.scss +164 -172
  258. package/src/styles/themes/_index.scss +0 -1
  259. package/src/styles/themes/_monochrome.scss +226 -234
  260. package/src/styles/themes/_neutral.scss +242 -250
  261. package/src/styles/themes/_ocean.scss +242 -259
  262. package/src/styles/themes/_rainbow.scss +242 -250
  263. package/src/styles/themes/_sageivory.scss +242 -250
  264. package/src/styles/themes/_spring.scss +238 -255
  265. package/src/styles/themes/_summer.scss +242 -250
  266. package/src/styles/themes/_sunset.scss +242 -259
  267. package/src/styles/themes/_tealcaramel.scss +242 -250
  268. package/src/styles/themes/_vibrant.scss +242 -250
  269. package/src/styles/utilities/_colors.scss +44 -50
  270. package/src/styles/utilities/_flexbox.scss +48 -59
  271. package/src/styles/utilities/_layout.scss +516 -591
  272. package/src/styles/utilities/_ripple.scss +61 -70
  273. package/src/styles/utilities/_spacing.scss +120 -127
  274. package/src/styles/utilities/_typography.scss +45 -58
  275. package/src/styles/utilities/_visibility.scss +61 -76
  276. package/dist/package.json +0 -488
@@ -1,4 +1,3 @@
1
- // src/components/switch/_switch.scss
2
1
  @use '../../styles/abstract/base' as base;
3
2
  @use '../../styles/abstract/variables' as v;
4
3
  @use '../../styles/abstract/functions' as f;
@@ -9,352 +8,286 @@
9
8
  $component: '#{base.$prefix}-switch';
10
9
 
11
10
  .#{$component} {
12
- // Base styles
13
- display: inline-flex;
14
- flex-direction: column;
15
- position: relative;
16
- width: 100%;
17
- padding: 4px 0;
18
- user-select: none;
19
-
20
- // Container for switch and label
21
- &__container {
22
- display: flex;
23
- flex-direction: row;
24
- justify-content: space-between;
25
- align-items: center;
26
- min-height: 48px;
27
- width: 100%;
28
- // Between the label and the track on whichever side the label is, in either
29
- // direction; it was a physical margin-right.
30
- column-gap: 12px;
31
- }
32
-
33
- // A switch with neither a label nor supporting text is its own target: no
34
- // gap (the 12px belongs between text and the track, and there is none), so
35
- // the root is the 52px track's width and 48px tall with the 32px track
36
- // centred. M3 "Switch" -> Specs -> Measurements: Track 32x52dp and "Target:
37
- // Size 48dp", with no height for a label row; its Accessibility section:
38
- // "Don't apply density to switches by default — this lowers their targets
39
- // below our best practice of 48x48 CSS pixels." So this row is 48 tall —
40
- // the root's 4px above and below leave the container 40 — while a switch
41
- // with a label, and one whose only text is its supporting text (`__helper`,
42
- // which stands where the label would), keeps the 56px row and the gap.
43
- // `:where` keeps this rule's weight level with `--dense`, which follows and
44
- // so still wins: a switch that opts into the denser row keeps it.
45
- &:where(:not(:has(.#{$component}__label, .#{$component}__helper))) {
46
- .#{$component}__container {
47
- column-gap: 0;
48
- min-height: 40px;
49
- }
50
- }
51
-
52
- // Content wrapper. The gap is on the container, so it stays between the label
53
- // and the track whichever side the label is on, in either direction.
54
- &__content {
55
- display: flex;
56
- flex-direction: column;
57
- flex-grow: 1;
58
- }
59
-
60
- // labelPosition 'end' only added this class, and the label stayed first.
61
- &--label-end &__container {
62
- flex-direction: row-reverse;
63
- }
64
-
65
- // Label
66
- // Body Large, as the checkbox and radio labels: a list item's headline.
67
- &__label {
68
- @include m.typography('body-large');
69
- color: t.color('on-surface');
70
- }
71
-
72
- // Input (visually hidden but accessible)
73
- &__input {
74
- font: inherit;
75
- position: absolute;
76
- opacity: 0;
77
- width: 100%;
78
- height: 100%;
79
- margin: 0;
80
- cursor: pointer;
81
- z-index: 1;
82
-
83
- &:disabled {
84
- cursor: not-allowed;
85
- }
86
-
87
- // md.comp.focus-ring around the track (material-web's switch ring), 3dp
88
- // secondary at a 2dp offset.
89
- &:focus-visible ~ .#{$component}__track {
90
- outline: 3px solid t.color('secondary');
91
- outline-offset: 2px;
92
- }
93
- }
94
-
95
- // The track (52 x 32dp, a 2dp outline). The handle and its state layer are
96
- // placed with inset-inline-start, so both mirror in right-to-left layouts: a
97
- // physical left plus translateX put the selected handle off the track.
98
- &__track {
99
- position: relative;
100
- flex-shrink: 0;
101
- min-width: 52px;
102
- height: 32px;
103
- box-sizing: border-box;
104
- border-radius: v.shape('full'); // SwitchTokens track-shape
105
- background-color: t.color('surface-container-highest');
106
- border: 2px solid t.color('outline');
107
- transition: m.spring(background-color, fast-effects), m.spring(border-color, fast-effects);
108
-
109
- // State layer: 40dp, centred on the handle.
110
- &::after {
111
- content: '';
112
- position: absolute;
113
- width: 40px;
114
- height: 40px;
115
- top: -6px;
116
- @include d.start-value(--#{$component}-layer-start, -6px);
117
- background-color: t.color('on-surface');
118
- opacity: 0;
119
- border-radius: 50%;
120
- z-index: 0;
121
- transition: m.spring(opacity, fast-effects), m.spring(inset-inline-start, fast-spatial),
122
- m.spring(inset, fast-spatial); // see the handle note: covers the lowered sides
123
- pointer-events: none;
124
- }
125
- }
126
-
127
- // The handle: 16dp unselected, 24dp selected or with an icon, 28dp pressed.
128
- // Compose springs it on the fast spatial spring (damping 0.9, stiffness 1400).
129
- // The transition also names `inset`, the physical shorthand for the sides an
130
- // old-target bundler lowers the inset into: the base rule keeps this list
131
- // while the placement moves to `:lang()`-guarded `left`/`right` rules (#125),
132
- // so a list naming only the logical side leaves those builds' handle
133
- // untransitioned and it jumps. `inset` covers those sides and the pressed
134
- // rule's `top` (and `bottom`, which nothing sets — inert) on the same spring
135
- // the separate entries carried; an engine too old to parse `inset` also
136
- // rejects `linear()`, so it never animated these entries on main either. In
137
- // the unbundled sheet nothing sets `left` or `right`, so the entry only ever
138
- // starts the `top` transition the old `top` entry carried.
139
- &__thumb {
140
- position: absolute;
141
- top: 6px;
142
- @include d.start-value(--#{$component}-thumb-start, 6px);
143
- width: 16px;
144
- height: 16px;
145
- border-radius: 50%;
146
- background-color: t.color('outline');
147
- transition: m.spring(inset-inline-start, fast-spatial), m.spring(inset, fast-spatial),
148
- m.spring(width, fast-spatial), m.spring(height, fast-spatial), m.spring(background-color, fast-effects);
149
- display: flex;
150
- align-items: center;
151
- justify-content: center;
152
- z-index: 1; /* Ensure thumb is above ripple */
153
- pointer-events: none;
154
-
155
- // Icons: 16dp. The selected one is on-primary-container, the unselected one
156
- // surface-container-highest (SwitchTokens).
157
- &-icon {
158
- position: absolute;
159
- display: flex;
160
- align-items: center;
161
- justify-content: center;
162
- opacity: 0;
163
- transform: scale(0);
164
- transition: m.spring(opacity, fast-effects), m.spring(transform, fast-spatial);
165
- color: t.color('on-primary-container');
166
-
167
- svg {
168
- width: 16px;
169
- height: 16px;
170
- }
171
-
172
- &--unselected {
173
- color: t.color('surface-container-highest');
174
- }
175
- }
176
- }
177
-
178
- // Supporting text
179
- &__helper {
180
- @include m.typography('body-medium');
181
- color: t.color('on-surface-variant');
182
-
183
- &--error {
184
- color: t.color('error');
185
- }
186
- }
187
-
188
- // With an unselected icon, the unselected handle is 24dp and shows it.
189
- &--icons:not(&--checked) {
190
- .#{$component}__thumb {
191
- width: 24px;
192
- height: 24px;
193
- top: 2px;
194
- @include d.start-value-set(--#{$component}-thumb-start, 2px);
195
- }
196
-
197
- .#{$component}__thumb-icon--unselected {
198
- opacity: 1;
199
- transform: scale(1);
200
- }
201
- }
202
-
203
- // Checked state
204
- &--checked {
205
- .#{$component}__track {
206
- background-color: t.color('primary');
207
- border-color: t.color('primary');
208
-
209
- &::after {
210
- @include d.start-value-set(--#{$component}-layer-start, 14px);
211
- background-color: t.color('primary');
212
- }
213
- }
214
-
215
- .#{$component}__thumb {
216
- background-color: t.color('on-primary');
217
- width: 24px;
218
- height: 24px;
219
- top: 2px;
220
- @include d.start-value-set(--#{$component}-thumb-start, 22px);
221
- }
222
-
223
- .#{$component}__thumb-icon:not(.#{$component}__thumb-icon--unselected) {
224
- opacity: 1;
225
- transform: scale(1);
226
- }
227
- }
228
-
229
- &--dense {
230
- .#{$component}__container {
231
- min-height: initial;
232
- }
233
- }
234
-
235
- // Error state
236
- &--error {
237
- .#{$component}__track {
238
- border-color: t.color('error');
239
- }
240
- }
241
-
242
- // Disabled state. SwitchTokens splits these: DisabledTrackOpacity is 0.12, while
243
- // the handle carries its own alpha — DisabledUnselectedHandleOpacity 0.38 over
244
- // OnSurface, and DisabledSelectedHandleOpacity 1.0 over Surface. A single opacity on
245
- // the track cascaded onto the handle, so no part matched its token.
246
- &--disabled {
247
- pointer-events: none;
248
-
249
- .#{$component}__track {
250
- background-color: t.alpha('on-surface', 0.12);
251
- border-color: t.alpha('on-surface', 0.12);
252
- }
253
-
254
- .#{$component}__thumb {
255
- background-color: t.alpha('on-surface', 0.38);
256
-
257
- &-icon--unselected {
258
- color: t.alpha('surface-container-highest', 0.38);
259
- }
260
- }
261
-
262
- .#{$component}__label, .#{$component}__helper {
263
- color: t.alpha('on-surface', 0.38);
264
- }
265
-
266
- // Selected: the track keeps 0.12 (the disabled rule above wins the cascade
267
- // over the checked track colour), and the handle is Surface at full opacity.
268
- &.#{$component}--checked {
269
- .#{$component}__track {
270
- border-color: transparent;
271
- }
272
-
273
- .#{$component}__thumb {
274
- background-color: t.color('surface');
275
-
276
- &-icon {
277
- color: t.alpha('on-surface', 0.38);
278
- }
279
- }
280
- }
281
- }
282
-
283
- // Interaction states. The handle takes on-surface-variant (unselected) or
284
- // primary-container (selected) on hover, focus and press, over an on-surface or
285
- // primary layer at the hover, focus and pressed opacities.
286
- &:not(.#{$component}--disabled) {
287
- .#{$component}__input:is(:hover, :focus-visible, :active) ~ .#{$component}__track .#{$component}__thumb {
288
- background-color: t.color('on-surface-variant');
289
- }
290
-
291
- &.#{$component}--checked .#{$component}__input:is(:hover, :focus-visible, :active) ~ .#{$component}__track .#{$component}__thumb {
292
- background-color: t.color('primary-container');
293
- }
294
-
295
- .#{$component}__input:hover ~ .#{$component}__track::after {
296
- opacity: v.state('hover-state-layer-opacity');
297
- }
298
-
299
- .#{$component}__input:focus-visible ~ .#{$component}__track::after {
300
- opacity: v.state('focus-state-layer-opacity');
301
- }
302
-
303
- .#{$component}__input:active ~ .#{$component}__track::after {
304
- opacity: v.state('pressed-state-layer-opacity');
305
- }
306
-
307
- // Pressed handle: 28dp, centred where the handle sits.
308
- .#{$component}__input:active ~ .#{$component}__track .#{$component}__thumb {
309
- width: 28px;
310
- height: 28px;
311
- top: 0;
312
- @include d.start-value-set(--#{$component}-thumb-start, 0);
313
- }
314
-
315
- &.#{$component}--checked .#{$component}__input:active ~ .#{$component}__track .#{$component}__thumb {
316
- @include d.start-value-set(--#{$component}-thumb-start, 20px);
317
- }
318
- }
319
-
320
- // The mirrored handle and layer positions, one arm per subject: every
321
- // state's move rides the custom property the arms form's base names, and a
322
- // bundler lowers no custom property, so the move animates on whichever side
323
- // the direction placed it — the transitions above already name both sides
324
- // in the arms form. The arm resets the base side to auto, exactly as the
325
- // logical property resolves one side per direction. Nothing of it in the
326
- // logical form, where the insets mirror natively.
327
- @include d.arms($self: true) {
328
- .#{$component}__track::after {
329
- left: auto;
330
- right: var(--#{$component}-layer-start, -6px);
331
- }
332
-
333
- .#{$component}__thumb {
334
- left: auto;
335
- right: var(--#{$component}-thumb-start, 6px);
336
- }
337
- }
338
-
339
- // Accessibility
340
- @include m.reduced-motion {
341
- .#{$component}__track,
342
- .#{$component}__thumb,
343
- .#{$component}__thumb-icon {
344
- transition: none;
345
- }
346
- }
347
-
348
- @include m.high-contrast {
349
- .#{$component}__track {
350
- border-width: 2px;
351
- }
352
-
353
- &--checked .#{$component}__track {
354
- border-color: currentColor;
355
- }
356
- }
357
-
358
- // Touch target for better mobile experience
359
- // @include m.touch-target;
11
+ display: inline-flex;
12
+ flex-direction: column;
13
+ position: relative;
14
+ width: 100%;
15
+ padding: 4px 0;
16
+ user-select: none;
17
+
18
+ &__container {
19
+ display: flex;
20
+ flex-direction: row;
21
+ justify-content: space-between;
22
+ align-items: center;
23
+ min-height: 48px;
24
+ width: 100%;
25
+ column-gap: 12px;
26
+ }
27
+
28
+ &:where(:not(:has(.#{$component}__label, .#{$component}__helper))) {
29
+ .#{$component}__container {
30
+ column-gap: 0;
31
+ min-height: 40px;
32
+ }
33
+ }
34
+
35
+ &__content {
36
+ display: flex;
37
+ flex-direction: column;
38
+ flex-grow: 1;
39
+ }
40
+
41
+ &--label-end &__container {
42
+ flex-direction: row-reverse;
43
+ }
44
+
45
+ &__label {
46
+ @include m.typography('body-large');
47
+ color: t.color('on-surface');
48
+ }
49
+
50
+ &__input {
51
+ font: inherit;
52
+ position: absolute;
53
+ opacity: 0;
54
+ width: 100%;
55
+ height: 100%;
56
+ margin: 0;
57
+ cursor: pointer;
58
+ z-index: 1;
59
+
60
+ &:disabled {
61
+ cursor: not-allowed;
62
+ }
63
+
64
+ &:focus-visible ~ .#{$component}__track {
65
+ outline: 3px solid t.color('secondary');
66
+ outline-offset: 2px;
67
+ }
68
+ }
69
+
70
+ &__track {
71
+ position: relative;
72
+ flex-shrink: 0;
73
+ min-width: 52px;
74
+ height: 32px;
75
+ box-sizing: border-box;
76
+ border-radius: v.shape('full');
77
+ background-color: t.color('surface-container-highest');
78
+ border: 2px solid t.color('outline');
79
+ transition: m.spring(background-color, fast-effects), m.spring(border-color, fast-effects);
80
+
81
+ &::after {
82
+ content: '';
83
+ position: absolute;
84
+ width: 40px;
85
+ height: 40px;
86
+ top: -6px;
87
+ @include d.start-value(--#{$component}-layer-start, -6px);
88
+ background-color: t.color('on-surface');
89
+ opacity: 0;
90
+ border-radius: 50%;
91
+ z-index: 0;
92
+ transition: m.spring(opacity, fast-effects), m.spring(inset-inline-start, fast-spatial),
93
+ m.spring(inset, fast-spatial);
94
+ pointer-events: none;
95
+ }
96
+ }
97
+
98
+ &__thumb {
99
+ position: absolute;
100
+ top: 6px;
101
+ @include d.start-value(--#{$component}-thumb-start, 6px);
102
+ width: 16px;
103
+ height: 16px;
104
+ border-radius: 50%;
105
+ background-color: t.color('outline');
106
+ transition: m.spring(inset-inline-start, fast-spatial), m.spring(inset, fast-spatial),
107
+ m.spring(width, fast-spatial), m.spring(height, fast-spatial), m.spring(background-color, fast-effects);
108
+ display: flex;
109
+ align-items: center;
110
+ justify-content: center;
111
+ z-index: 1; /* Ensure thumb is above ripple */
112
+ pointer-events: none;
113
+
114
+ &-icon {
115
+ position: absolute;
116
+ display: flex;
117
+ align-items: center;
118
+ justify-content: center;
119
+ opacity: 0;
120
+ transform: scale(0);
121
+ transition: m.spring(opacity, fast-effects), m.spring(transform, fast-spatial);
122
+ color: t.color('on-primary-container');
123
+
124
+ svg {
125
+ width: 16px;
126
+ height: 16px;
127
+ }
128
+
129
+ &--unselected {
130
+ color: t.color('surface-container-highest');
131
+ }
132
+ }
133
+ }
134
+
135
+ &__helper {
136
+ @include m.typography('body-medium');
137
+ color: t.color('on-surface-variant');
138
+
139
+ &--error {
140
+ color: t.color('error');
141
+ }
142
+ }
143
+
144
+ &--icons:not(&--checked) {
145
+ .#{$component}__thumb {
146
+ width: 24px;
147
+ height: 24px;
148
+ top: 2px;
149
+ @include d.start-value-set(--#{$component}-thumb-start, 2px);
150
+ }
151
+
152
+ .#{$component}__thumb-icon--unselected {
153
+ opacity: 1;
154
+ transform: scale(1);
155
+ }
156
+ }
157
+
158
+ &--checked {
159
+ .#{$component}__track {
160
+ background-color: t.color('primary');
161
+ border-color: t.color('primary');
162
+
163
+ &::after {
164
+ @include d.start-value-set(--#{$component}-layer-start, 14px);
165
+ background-color: t.color('primary');
166
+ }
167
+ }
168
+
169
+ .#{$component}__thumb {
170
+ background-color: t.color('on-primary');
171
+ width: 24px;
172
+ height: 24px;
173
+ top: 2px;
174
+ @include d.start-value-set(--#{$component}-thumb-start, 22px);
175
+ }
176
+
177
+ .#{$component}__thumb-icon:not(.#{$component}__thumb-icon--unselected) {
178
+ opacity: 1;
179
+ transform: scale(1);
180
+ }
181
+ }
182
+
183
+ &--dense {
184
+ .#{$component}__container {
185
+ min-height: initial;
186
+ }
187
+ }
188
+
189
+ &--error {
190
+ .#{$component}__track {
191
+ border-color: t.color('error');
192
+ }
193
+ }
194
+
195
+ &--disabled {
196
+ pointer-events: none;
197
+
198
+ .#{$component}__track {
199
+ background-color: t.alpha('on-surface', 0.12);
200
+ border-color: t.alpha('on-surface', 0.12);
201
+ }
202
+
203
+ .#{$component}__thumb {
204
+ background-color: t.alpha('on-surface', 0.38);
205
+
206
+ &-icon--unselected {
207
+ color: t.alpha('surface-container-highest', 0.38);
208
+ }
209
+ }
210
+
211
+ .#{$component}__label, .#{$component}__helper {
212
+ color: t.alpha('on-surface', 0.38);
213
+ }
214
+
215
+ &.#{$component}--checked {
216
+ .#{$component}__track {
217
+ border-color: transparent;
218
+ }
219
+
220
+ .#{$component}__thumb {
221
+ background-color: t.color('surface');
222
+
223
+ &-icon {
224
+ color: t.alpha('on-surface', 0.38);
225
+ }
226
+ }
227
+ }
228
+ }
229
+
230
+ &:not(.#{$component}--disabled) {
231
+ .#{$component}__input:is(:hover, :focus-visible, :active) ~ .#{$component}__track .#{$component}__thumb {
232
+ background-color: t.color('on-surface-variant');
233
+ }
234
+
235
+ &.#{$component}--checked .#{$component}__input:is(:hover, :focus-visible, :active) ~ .#{$component}__track .#{$component}__thumb {
236
+ background-color: t.color('primary-container');
237
+ }
238
+
239
+ .#{$component}__input:hover ~ .#{$component}__track::after {
240
+ opacity: v.state('hover-state-layer-opacity');
241
+ }
242
+
243
+ .#{$component}__input:focus-visible ~ .#{$component}__track::after {
244
+ opacity: v.state('focus-state-layer-opacity');
245
+ }
246
+
247
+ .#{$component}__input:active ~ .#{$component}__track::after {
248
+ opacity: v.state('pressed-state-layer-opacity');
249
+ }
250
+
251
+ .#{$component}__input:active ~ .#{$component}__track .#{$component}__thumb {
252
+ width: 28px;
253
+ height: 28px;
254
+ top: 0;
255
+ @include d.start-value-set(--#{$component}-thumb-start, 0);
256
+ }
257
+
258
+ &.#{$component}--checked .#{$component}__input:active ~ .#{$component}__track .#{$component}__thumb {
259
+ @include d.start-value-set(--#{$component}-thumb-start, 20px);
260
+ }
261
+ }
262
+
263
+ @include d.arms($self: true) {
264
+ .#{$component}__track::after {
265
+ left: auto;
266
+ right: var(--#{$component}-layer-start, -6px);
267
+ }
268
+
269
+ .#{$component}__thumb {
270
+ left: auto;
271
+ right: var(--#{$component}-thumb-start, 6px);
272
+ }
273
+ }
274
+
275
+ @include m.reduced-motion {
276
+ .#{$component}__track,
277
+ .#{$component}__thumb,
278
+ .#{$component}__thumb-icon {
279
+ transition: none;
280
+ }
281
+ }
282
+
283
+ @include m.high-contrast {
284
+ .#{$component}__track {
285
+ border-width: 2px;
286
+ }
287
+
288
+ &--checked .#{$component}__track {
289
+ border-color: currentColor;
290
+ }
291
+ }
292
+
360
293
  }