material 3.7.2 → 3.8.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 (313) hide show
  1. package/NOTICE +223 -0
  2. package/README.md +5 -3
  3. package/dist/components/extended-fab/types.d.ts +3 -0
  4. package/dist/components/fab/types.d.ts +3 -0
  5. package/dist/components/slider/features/controller.js +24 -8
  6. package/dist/elements/css/card.css +1 -1
  7. package/dist/elements/css/card.js +1 -1
  8. package/dist/elements/css/dialog.css +1 -1
  9. package/dist/elements/css/dialog.js +1 -1
  10. package/dist/elements/css/menu.css +1 -1
  11. package/dist/elements/css/menu.js +1 -1
  12. package/dist/elements/css/select.css +1 -1
  13. package/dist/elements/css/select.js +1 -1
  14. package/dist/elements/css/slider.css +1 -1
  15. package/dist/elements/css/slider.js +1 -1
  16. package/dist/elements/css/tabs.css +1 -1
  17. package/dist/elements/css/tabs.js +1 -1
  18. package/dist/elements/css/timepicker.css +1 -1
  19. package/dist/elements/css/timepicker.js +1 -1
  20. package/dist/elements/extended-fab.d.ts +1 -0
  21. package/dist/elements/fab.d.ts +1 -0
  22. package/dist/elements/preupgrade/badge.css +1 -1
  23. package/dist/elements/preupgrade/bottom-app-bar.css +1 -1
  24. package/dist/elements/preupgrade/bottom-sheet.css +1 -1
  25. package/dist/elements/preupgrade/button-group.css +1 -1
  26. package/dist/elements/preupgrade/button.css +1 -1
  27. package/dist/elements/preupgrade/card.css +1 -1
  28. package/dist/elements/preupgrade/carousel.css +1 -1
  29. package/dist/elements/preupgrade/checkbox.css +1 -1
  30. package/dist/elements/preupgrade/chips.css +1 -1
  31. package/dist/elements/preupgrade/datepicker.css +1 -1
  32. package/dist/elements/preupgrade/dialog.css +1 -1
  33. package/dist/elements/preupgrade/divider.css +1 -1
  34. package/dist/elements/preupgrade/drawer.css +1 -1
  35. package/dist/elements/preupgrade/extended-fab.css +1 -1
  36. package/dist/elements/preupgrade/fab-menu.css +1 -1
  37. package/dist/elements/preupgrade/fab.css +1 -1
  38. package/dist/elements/preupgrade/icon-button.css +1 -1
  39. package/dist/elements/preupgrade/list.css +1 -1
  40. package/dist/elements/preupgrade/loading-indicator.css +1 -1
  41. package/dist/elements/preupgrade/menu.css +1 -1
  42. package/dist/elements/preupgrade/navigation-bar.css +1 -1
  43. package/dist/elements/preupgrade/navigation-rail.css +1 -1
  44. package/dist/elements/preupgrade/progress.css +1 -1
  45. package/dist/elements/preupgrade/radios.css +1 -1
  46. package/dist/elements/preupgrade/search.css +1 -1
  47. package/dist/elements/preupgrade/select.css +1 -1
  48. package/dist/elements/preupgrade/side-sheet.css +1 -1
  49. package/dist/elements/preupgrade/slider.css +1 -1
  50. package/dist/elements/preupgrade/snackbar.css +1 -1
  51. package/dist/elements/preupgrade/split-button.css +1 -1
  52. package/dist/elements/preupgrade/switch.css +1 -1
  53. package/dist/elements/preupgrade/tabs.css +1 -1
  54. package/dist/elements/preupgrade/text-field.css +1 -1
  55. package/dist/elements/preupgrade/timepicker.css +1 -1
  56. package/dist/elements/preupgrade/toolbar.css +1 -1
  57. package/dist/elements/preupgrade/tooltip.css +1 -1
  58. package/dist/elements/preupgrade/top-app-bar.css +1 -1
  59. package/dist/elements/preupgrade.css +1 -1
  60. package/dist/styles/badge.css +1 -1
  61. package/dist/styles/base-lite.css +2 -2
  62. package/dist/styles/base.css +2 -2
  63. package/dist/styles/bottom-app-bar.css +1 -1
  64. package/dist/styles/bottom-sheet.css +1 -1
  65. package/dist/styles/button-group.css +1 -1
  66. package/dist/styles/button.css +1 -1
  67. package/dist/styles/card.css +2 -2
  68. package/dist/styles/carousel.css +1 -1
  69. package/dist/styles/checkbox.css +1 -1
  70. package/dist/styles/chips.css +1 -1
  71. package/dist/styles/contrast.css +2 -2
  72. package/dist/styles/datepicker.css +1 -1
  73. package/dist/styles/dialog.css +2 -2
  74. package/dist/styles/divider.css +1 -1
  75. package/dist/styles/drawer.css +1 -1
  76. package/dist/styles/extended-fab.css +1 -1
  77. package/dist/styles/fab-menu.css +1 -1
  78. package/dist/styles/fab.css +1 -1
  79. package/dist/styles/icon-button.css +1 -1
  80. package/dist/styles/list.css +1 -1
  81. package/dist/styles/loading-indicator.css +1 -1
  82. package/dist/styles/menu.css +2 -2
  83. package/dist/styles/navigation-bar.css +1 -1
  84. package/dist/styles/navigation-rail.css +1 -1
  85. package/dist/styles/progress.css +1 -1
  86. package/dist/styles/radios.css +1 -1
  87. package/dist/styles/search.css +1 -1
  88. package/dist/styles/select.css +2 -2
  89. package/dist/styles/side-sheet.css +1 -1
  90. package/dist/styles/slider.css +2 -2
  91. package/dist/styles/snackbar.css +1 -1
  92. package/dist/styles/split-button.css +1 -1
  93. package/dist/styles/switch.css +1 -1
  94. package/dist/styles/tabs.css +2 -2
  95. package/dist/styles/text-field.css +1 -1
  96. package/dist/styles/timepicker.css +2 -2
  97. package/dist/styles/toolbar.css +1 -1
  98. package/dist/styles/tooltip.css +1 -1
  99. package/dist/styles/top-app-bar.css +1 -1
  100. package/dist/styles/typography.css +1 -1
  101. package/dist/styles/utilities.css +1 -1
  102. package/dist/styles.css +2 -2
  103. package/dist/theme/image.d.ts +2 -0
  104. package/dist/theme/image.js +5 -0
  105. package/dist/theme/index.d.ts +23 -0
  106. package/dist/theme/index.js +32 -0
  107. package/dist/theme/roles.js +68 -0
  108. package/dist/theme/variants.d.ts +9 -0
  109. package/dist/theme/variants.js +17 -0
  110. package/dist/theme/vendor/contrast/contrast.js +72 -0
  111. package/dist/theme/vendor/dislike/dislike_analyzer.js +31 -0
  112. package/dist/theme/vendor/dynamiccolor/color_spec_2021.d.ts +63 -0
  113. package/dist/theme/vendor/dynamiccolor/color_spec_2021.js +663 -0
  114. package/dist/theme/vendor/dynamiccolor/contrast_curve.js +42 -0
  115. package/dist/theme/vendor/dynamiccolor/dynamic_color.d.ts +24 -0
  116. package/dist/theme/vendor/dynamiccolor/dynamic_color.js +264 -0
  117. package/dist/theme/vendor/dynamiccolor/dynamic_scheme.d.ts +87 -0
  118. package/dist/theme/vendor/dynamiccolor/dynamic_scheme.js +418 -0
  119. package/dist/theme/vendor/dynamiccolor/material_dynamic_colors.d.ts +124 -0
  120. package/dist/theme/vendor/dynamiccolor/material_dynamic_colors.js +311 -0
  121. package/dist/theme/vendor/dynamiccolor/tone_delta_pair.js +27 -0
  122. package/dist/theme/vendor/dynamiccolor/variant.js +28 -0
  123. package/dist/theme/vendor/hct/cam16.js +249 -0
  124. package/dist/theme/vendor/hct/hct.d.ts +23 -0
  125. package/dist/theme/vendor/hct/hct.js +86 -0
  126. package/dist/theme/vendor/hct/hct_solver.js +390 -0
  127. package/dist/theme/vendor/hct/viewing_conditions.js +73 -0
  128. package/dist/theme/vendor/palettes/tonal_palette.js +114 -0
  129. package/dist/theme/vendor/quantize/lab_point_provider.js +31 -0
  130. package/dist/theme/vendor/quantize/quantizer_celebi.js +25 -0
  131. package/dist/theme/vendor/quantize/quantizer_map.js +31 -0
  132. package/dist/theme/vendor/quantize/quantizer_wsmeans.js +178 -0
  133. package/dist/theme/vendor/quantize/quantizer_wu.js +342 -0
  134. package/dist/theme/vendor/scheme/scheme_content.js +30 -0
  135. package/dist/theme/vendor/scheme/scheme_expressive.js +30 -0
  136. package/dist/theme/vendor/scheme/scheme_fidelity.js +30 -0
  137. package/dist/theme/vendor/scheme/scheme_monochrome.js +30 -0
  138. package/dist/theme/vendor/scheme/scheme_neutral.js +30 -0
  139. package/dist/theme/vendor/scheme/scheme_tonal_spot.js +30 -0
  140. package/dist/theme/vendor/scheme/scheme_vibrant.js +30 -0
  141. package/dist/theme/vendor/score/score.js +100 -0
  142. package/dist/theme/vendor/temperature/temperature_cache.js +198 -0
  143. package/dist/theme/vendor/utils/color_utils.js +173 -0
  144. package/dist/theme/vendor/utils/image_utils.js +72 -0
  145. package/dist/theme/vendor/utils/math_utils.js +75 -0
  146. package/dist/theme/vendor/utils/string_utils.js +61 -0
  147. package/dist/themes/autumn-contrast.css +2 -2
  148. package/dist/themes/autumn.css +2 -2
  149. package/dist/themes/baseline-contrast.css +2 -2
  150. package/dist/themes/baseline.css +2 -2
  151. package/dist/themes/brownbeige-contrast.css +2 -2
  152. package/dist/themes/brownbeige.css +2 -2
  153. package/dist/themes/content-contrast.css +2 -2
  154. package/dist/themes/content.css +2 -2
  155. package/dist/themes/desert-contrast.css +2 -2
  156. package/dist/themes/desert.css +2 -2
  157. package/dist/themes/expressive-contrast.css +2 -2
  158. package/dist/themes/expressive.css +2 -2
  159. package/dist/themes/fidelity-contrast.css +2 -2
  160. package/dist/themes/fidelity.css +2 -2
  161. package/dist/themes/forest-contrast.css +2 -2
  162. package/dist/themes/forest.css +2 -2
  163. package/dist/themes/fruit-salad-contrast.css +2 -2
  164. package/dist/themes/fruit-salad.css +2 -2
  165. package/dist/themes/highcontrast-contrast.css +2 -2
  166. package/dist/themes/highcontrast.css +2 -2
  167. package/dist/themes/monochrome-contrast.css +2 -2
  168. package/dist/themes/monochrome.css +2 -2
  169. package/dist/themes/neutral-contrast.css +2 -2
  170. package/dist/themes/neutral.css +2 -2
  171. package/dist/themes/ocean-contrast.css +2 -2
  172. package/dist/themes/ocean.css +2 -2
  173. package/dist/themes/rainbow-contrast.css +2 -2
  174. package/dist/themes/rainbow.css +2 -2
  175. package/dist/themes/sageivory-contrast.css +2 -2
  176. package/dist/themes/sageivory.css +2 -2
  177. package/dist/themes/spring-contrast.css +2 -2
  178. package/dist/themes/spring.css +2 -2
  179. package/dist/themes/summer-contrast.css +2 -2
  180. package/dist/themes/summer.css +2 -2
  181. package/dist/themes/sunset-contrast.css +2 -2
  182. package/dist/themes/sunset.css +2 -2
  183. package/dist/themes/tealcaramel-contrast.css +2 -2
  184. package/dist/themes/tealcaramel.css +2 -2
  185. package/dist/themes/vibrant-contrast.css +2 -2
  186. package/dist/themes/vibrant.css +2 -2
  187. package/package.json +15 -1
  188. package/src/styles/abstract/_base.scss +0 -1
  189. package/src/styles/abstract/_direction.scss +121 -152
  190. package/src/styles/abstract/_emit.scss +7 -16
  191. package/src/styles/abstract/_floating-placement.scss +9 -10
  192. package/src/styles/abstract/_functions.scss +64 -79
  193. package/src/styles/abstract/_mixins.scss +355 -459
  194. package/src/styles/abstract/_theme.scss +122 -136
  195. package/src/styles/abstract/_variables.scss +320 -390
  196. package/src/styles/abstract/chips/_assist.scss +2 -3
  197. package/src/styles/abstract/chips/_filter.scss +2 -3
  198. package/src/styles/abstract/chips/_input.scss +2 -3
  199. package/src/styles/abstract/chips/_suggestion.scss +2 -3
  200. package/src/styles/base/_body-theme.scss +10 -15
  201. package/src/styles/base/_document.scss +10 -33
  202. package/src/styles/base/_reset.scss +20 -40
  203. package/src/styles/base/_tokens.scss +6 -21
  204. package/src/styles/base/_typescale-tokens.scss +12 -16
  205. package/src/styles/base/_typography.scss +28 -37
  206. package/src/styles/components/_badge.scss +171 -193
  207. package/src/styles/components/_bottom-app-bar.scss +72 -90
  208. package/src/styles/components/_bottom-sheet.scss +188 -232
  209. package/src/styles/components/_button-group.scss +140 -189
  210. package/src/styles/components/_button.scss +382 -478
  211. package/src/styles/components/_card.scss +349 -473
  212. package/src/styles/components/_carousel.scss +134 -156
  213. package/src/styles/components/_checkbox.scss +208 -249
  214. package/src/styles/components/_chips.scss +239 -304
  215. package/src/styles/components/_datepicker.scss +172 -222
  216. package/src/styles/components/_dialog.scss +428 -553
  217. package/src/styles/components/_divider.scss +37 -46
  218. package/src/styles/components/_drawer.scss +571 -678
  219. package/src/styles/components/_extended-fab.scss +263 -294
  220. package/src/styles/components/_fab-menu.scss +225 -267
  221. package/src/styles/components/_fab.scss +197 -218
  222. package/src/styles/components/_icon-button.scss +483 -588
  223. package/src/styles/components/_list.scss +115 -144
  224. package/src/styles/components/_loading-indicator.scss +23 -29
  225. package/src/styles/components/_menu.scss +543 -699
  226. package/src/styles/components/_navigation-bar.scss +189 -234
  227. package/src/styles/components/_navigation-rail.scss +256 -312
  228. package/src/styles/components/_progress.scss +60 -85
  229. package/src/styles/components/_radios.scss +170 -207
  230. package/src/styles/components/_search.scss +369 -455
  231. package/src/styles/components/_select.scss +78 -185
  232. package/src/styles/components/_side-sheet.scss +234 -292
  233. package/src/styles/components/_slider.scss +289 -367
  234. package/src/styles/components/_snackbar.scss +149 -198
  235. package/src/styles/components/_split-button.scss +139 -228
  236. package/src/styles/components/_switch.scss +282 -349
  237. package/src/styles/components/_tabs.scss +350 -547
  238. package/src/styles/components/_text-field.scss +788 -980
  239. package/src/styles/components/_timepicker.scss +435 -506
  240. package/src/styles/components/_toolbar.scss +178 -242
  241. package/src/styles/components/_tooltip.scss +152 -197
  242. package/src/styles/components/_top-app-bar.scss +206 -230
  243. package/src/styles/elements/_badge.scss +42 -61
  244. package/src/styles/elements/_bottom-app-bar.scss +14 -20
  245. package/src/styles/elements/_bottom-sheet.scss +0 -3
  246. package/src/styles/elements/_button-group.scss +80 -80
  247. package/src/styles/elements/_button.scss +72 -88
  248. package/src/styles/elements/_card.scss +48 -57
  249. package/src/styles/elements/_carousel.scss +2 -5
  250. package/src/styles/elements/_checkbox.scss +32 -43
  251. package/src/styles/elements/_chips.scss +18 -22
  252. package/src/styles/elements/_config.scss +11 -26
  253. package/src/styles/elements/_datepicker.scss +17 -22
  254. package/src/styles/elements/_dialog.scss +0 -3
  255. package/src/styles/elements/_divider.scss +11 -13
  256. package/src/styles/elements/_drawer.scss +9 -14
  257. package/src/styles/elements/_extended-fab.scss +36 -40
  258. package/src/styles/elements/_fab-menu.scss +21 -25
  259. package/src/styles/elements/_fab.scss +17 -20
  260. package/src/styles/elements/_field.scss +93 -114
  261. package/src/styles/elements/_icon-button.scss +34 -38
  262. package/src/styles/elements/_index.scss +0 -4
  263. package/src/styles/elements/_list.scss +19 -26
  264. package/src/styles/elements/_loading-indicator.scss +6 -9
  265. package/src/styles/elements/_menu.scss +0 -3
  266. package/src/styles/elements/_navigation-bar.scss +5 -9
  267. package/src/styles/elements/_navigation-rail.scss +10 -15
  268. package/src/styles/elements/_progress.scss +15 -18
  269. package/src/styles/elements/_radios.scss +24 -49
  270. package/src/styles/elements/_search.scss +19 -24
  271. package/src/styles/elements/_select.scss +4 -9
  272. package/src/styles/elements/_side-sheet.scss +0 -3
  273. package/src/styles/elements/_slider.scss +15 -35
  274. package/src/styles/elements/_snackbar.scss +0 -3
  275. package/src/styles/elements/_split-button.scss +33 -39
  276. package/src/styles/elements/_switch.scss +50 -90
  277. package/src/styles/elements/_tabs.scss +9 -13
  278. package/src/styles/elements/_text-field.scss +150 -178
  279. package/src/styles/elements/_timepicker.scss +0 -3
  280. package/src/styles/elements/_toolbar.scss +30 -35
  281. package/src/styles/elements/_tooltip.scss +0 -3
  282. package/src/styles/elements/_top-app-bar.scss +38 -45
  283. package/src/styles/main.scss +0 -15
  284. package/src/styles/themes/_autumn.scss +258 -258
  285. package/src/styles/themes/_base-theme.scss +112 -134
  286. package/src/styles/themes/_baseline.scss +291 -314
  287. package/src/styles/themes/_brownbeige.scss +270 -250
  288. package/src/styles/themes/_content.scss +268 -248
  289. package/src/styles/themes/_desert.scss +270 -250
  290. package/src/styles/themes/_expressive.scss +270 -250
  291. package/src/styles/themes/_fidelity.scss +268 -248
  292. package/src/styles/themes/_forest.scss +260 -259
  293. package/src/styles/themes/_fruit-salad.scss +270 -250
  294. package/src/styles/themes/_highcontrast.scss +183 -172
  295. package/src/styles/themes/_index.scss +0 -1
  296. package/src/styles/themes/_monochrome.scss +254 -234
  297. package/src/styles/themes/_neutral.scss +270 -250
  298. package/src/styles/themes/_ocean.scss +260 -259
  299. package/src/styles/themes/_rainbow.scss +270 -250
  300. package/src/styles/themes/_sageivory.scss +270 -250
  301. package/src/styles/themes/_spring.scss +256 -255
  302. package/src/styles/themes/_summer.scss +270 -250
  303. package/src/styles/themes/_sunset.scss +260 -259
  304. package/src/styles/themes/_tealcaramel.scss +270 -250
  305. package/src/styles/themes/_vibrant.scss +270 -250
  306. package/src/styles/utilities/_colors.scss +44 -50
  307. package/src/styles/utilities/_flexbox.scss +48 -59
  308. package/src/styles/utilities/_layout.scss +516 -591
  309. package/src/styles/utilities/_ripple.scss +61 -70
  310. package/src/styles/utilities/_spacing.scss +120 -127
  311. package/src/styles/utilities/_typography.scss +45 -58
  312. package/src/styles/utilities/_visibility.scss +61 -76
  313. 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
  }