@zazz-ui/core 0.10.0 → 0.12.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 (89) hide show
  1. package/AUTHORING.md +3 -3
  2. package/CHANGELOG.md +175 -0
  3. package/README.md +2 -2
  4. package/dist/{csp-DR-s45Kg.js → csp-LRx1fynI.js} +1 -1
  5. package/dist/sri.json +53 -53
  6. package/dist/zazz.css +1 -1
  7. package/dist/zazz.js +1 -1
  8. package/editor/zazz.css-data.json +184 -4
  9. package/editor/zazz.html-data.json +32 -0
  10. package/editor/zazz.language-data.json +209 -42
  11. package/editor/zazz.lint-data.json +1750 -1652
  12. package/package.json +5 -4
  13. package/src/base/_defaults.css +8 -2
  14. package/src/base/_properties-2xl.css +2 -0
  15. package/src/base/_properties-lg.css +2 -0
  16. package/src/base/_properties-md.css +2 -0
  17. package/src/base/_properties-sm.css +2 -0
  18. package/src/base/_properties-xl.css +2 -0
  19. package/src/base/_properties.css +6 -0
  20. package/src/base/_shadows.css +28 -28
  21. package/src/base/_utilities-box.css +3 -2
  22. package/src/base/_utilities-effects.css +25 -4
  23. package/src/base/_utilities-tier-2xl.css +1 -0
  24. package/src/base/_utilities-tier-lg.css +1 -0
  25. package/src/base/_utilities-tier-md.css +1 -0
  26. package/src/base/_utilities-tier-sm.css +1 -0
  27. package/src/base/_utilities-tier-xl.css +1 -0
  28. package/src/base/_variables.css +32 -2
  29. package/src/base/csp.d.ts.map +1 -1
  30. package/src/base/csp.js +7 -3
  31. package/src/base/csp.ts +9 -3
  32. package/src/base/kit-styling.d.ts.map +1 -1
  33. package/src/base/kit-styling.js +172 -158
  34. package/src/base/kit-styling.ts +172 -158
  35. package/src/base/utilities.d.ts +4 -1
  36. package/src/base/utilities.d.ts.map +1 -1
  37. package/src/base/utilities.js +28 -1
  38. package/src/base/utilities.ts +33 -2
  39. package/src/base/zazz-element.d.ts +1 -1
  40. package/src/base/zazz-element.js +1 -1
  41. package/src/base/zazz-element.ts +1 -1
  42. package/src/manifest.d.ts +1 -1
  43. package/src/manifest.d.ts.map +1 -1
  44. package/src/manifest.js +10 -2
  45. package/src/manifest.ts +10 -2
  46. package/src/primitives/accordion/accordion.css +61 -12
  47. package/src/primitives/alert-dialog/alert-dialog.html +14 -14
  48. package/src/primitives/badge/badge.css +33 -9
  49. package/src/primitives/button/button.css +57 -16
  50. package/src/primitives/callout/callout.css +2 -0
  51. package/src/primitives/card/card-article.html +115 -0
  52. package/src/primitives/card/card-horizontal.html +83 -0
  53. package/src/primitives/card/card-login.html +56 -0
  54. package/src/primitives/card/card-product.html +78 -0
  55. package/src/primitives/card/card-subgrid.html +96 -295
  56. package/src/primitives/card/card.css +189 -9
  57. package/src/primitives/card/card.html +110 -147
  58. package/src/primitives/carousel/carousel.html +4 -4
  59. package/src/primitives/checkbox/checkbox.css +11 -0
  60. package/src/primitives/combobox/combobox.css +47 -5
  61. package/src/primitives/command/command-dialog.html +109 -107
  62. package/src/primitives/command/command.css +16 -8
  63. package/src/primitives/debug/audit-core.d.ts.map +1 -1
  64. package/src/primitives/debug/audit-core.js +17 -0
  65. package/src/primitives/debug/audit-core.ts +16 -0
  66. package/src/primitives/dialog/dialog.css +94 -40
  67. package/src/primitives/fields/fields.css +2 -0
  68. package/src/primitives/input/input.css +27 -3
  69. package/src/primitives/input-group/input-group.css +15 -5
  70. package/src/primitives/layout/layout.css +2 -0
  71. package/src/primitives/layout/layout.html +8 -11
  72. package/src/primitives/lightbox/lightbox.css +4 -4
  73. package/src/primitives/mobile-menu/mobile-menu.css +17 -16
  74. package/src/primitives/mobile-menu/mobile-menu.html +4 -4
  75. package/src/primitives/navigation-menu/navigation-menu.css +3 -3
  76. package/src/primitives/otp/otp.css +15 -2
  77. package/src/primitives/password-group/password-group.css +18 -5
  78. package/src/primitives/popover/popover.css +23 -10
  79. package/src/primitives/radio/radio.css +14 -2
  80. package/src/primitives/reveal/reveal.html +3 -3
  81. package/src/primitives/scroll-fade/scroll-fade.css +1 -1
  82. package/src/primitives/scroll-fade/scroll-fade.html +8 -12
  83. package/src/primitives/select/select.css +54 -17
  84. package/src/primitives/slider/slider.css +95 -42
  85. package/src/primitives/switch/switch.css +14 -2
  86. package/src/primitives/tabs/tabs.css +11 -2
  87. package/src/primitives/textarea/textarea.css +8 -4
  88. package/src/primitives/toggle/toggle.css +50 -4
  89. package/src/primitives/tooltip/tooltip.css +40 -25
@@ -4,8 +4,15 @@
4
4
  * @layer variables, reset
5
5
  * @requires _layers.css, _variables.css
6
6
  * @uses appearance: none — redraws track + thumb from theme tokens
7
+ * @uses --_touch-min (touch screens): the transparent input grows to the touch floor
8
+ * and so does the thumb's box, through a transparent border, while the visible
9
+ * thumb keeps its size. A thumb can't have an ::after, so on touch screens its
10
+ * border and ring draw inset, it loses its drop shadow, and the visible thumb
11
+ * stops a border's width short of each track end.
12
+ * @uses sign(): switches the ring inset once the thumb has a hit border
7
13
  * @uses corner-shape — round by default, so circles stay circles; a hook takes any shape
8
- * @tokens --ui-slider-* (@layer variables, on :root so subtree hooks work)
14
+ * @tokens --ui-slider-* (@layer variables, on :root so subtree hooks work); the thumb
15
+ * and track sizes floor at --spacing-control-min
9
16
  *
10
17
  * Note: The active region is NOT filled (parity across engines); add a paint
11
18
  * via JS if a filled track is needed. The thumb is centered on the track with a
@@ -16,45 +23,83 @@
16
23
  :root {
17
24
  --ui-slider-ring-color: var(--color-ring);
18
25
 
19
- --ui-slider-track-h: calc(var(--spacing) * 1.5);
26
+ --ui-slider-track-h: max(calc(var(--spacing) * 1.5), calc(var(--spacing-control-min) * 0.375));
20
27
  --ui-slider-track-bg: var(--color-muted);
21
- --ui-slider-track-border: 1px solid var(--color-muted);
28
+ --ui-slider-track-border-width: 1px;
29
+ --ui-slider-track-border-color: var(--color-muted);
22
30
  --ui-slider-track-radius: var(--radius-full);
23
31
  --ui-slider-track-corner-shape: round;
24
- --ui-slider-thumb-size: calc(var(--spacing) * 4);
32
+ --ui-slider-thumb-size: max(calc(var(--spacing) * 4), var(--spacing-control-min));
25
33
  --ui-slider-thumb-bg: var(--color-background);
26
34
 
35
+ /* composes into the thumb's box-shadow list with its border and ring: use a
36
+ transparent shadow, never `none` */
27
37
  --ui-slider-thumb-shadow: var(--shadow-xs);
28
- --ui-slider-thumb-border: 1px solid var(--color-border);
38
+ --ui-slider-thumb-border-width: 1px;
39
+ --ui-slider-thumb-border-color: var(--color-border);
29
40
  --ui-slider-thumb-radius: var(--radius-full);
30
41
  --ui-slider-thumb-corner-shape: round;
31
42
  }
32
43
  }
33
44
 
45
+ /* Thumb plumbing, set on the input and inherited by the thumb pseudo-elements */
46
+ @property --_slider-thumb-hit {
47
+ syntax: "*";
48
+ inherits: true;
49
+ }
50
+ @property --_slider-thumb-in {
51
+ syntax: "*";
52
+ inherits: true;
53
+ }
54
+ @property --_slider-thumb-drop {
55
+ syntax: "*";
56
+ inherits: true;
57
+ }
58
+
34
59
  @layer reset {
35
60
  :where(input[type="range"]) {
36
- /* derived on the element so a subtree --ui-slider-track-h keeps the thumb centered */
37
- --ui-slider-thumb-offset: calc(var(--ui-slider-track-h) * -1);
61
+ /* the transparent border that grows the thumb's box to the touch floor; 0 on a mouse */
62
+ --_slider-thumb-hit: max(0px, (var(--_touch-min) - var(--ui-slider-thumb-size)) / 2);
63
+ /* 1 once the thumb has a hit border: the ring then draws inside the visible thumb */
64
+ --_slider-thumb-in: sign(var(--_slider-thumb-hit));
65
+ --_slider-thumb-drop: var(--ui-slider-thumb-shadow);
66
+ /* derived on the element so a subtree hook keeps the thumb centered on the track */
67
+ --ui-slider-thumb-offset: calc(
68
+ (var(--ui-slider-track-h) - var(--ui-slider-thumb-size)) / 2 - var(--_slider-thumb-hit) -
69
+ var(--ui-slider-track-border-width)
70
+ );
71
+
72
+ /* the ring widths grow from 0 on focus and press, so the ring eases in */
73
+ --_ring-offset-width: 0px;
74
+ --_ring-width: 0px;
75
+ --_ring-fill: color-mix(in oklch, var(--ui-slider-ring-color) var(--ring-opacity), transparent);
38
76
 
39
77
  -webkit-appearance: none;
40
78
  appearance: none;
41
79
  inline-size: 100%;
80
+ min-block-size: var(--_touch-min);
42
81
  background: transparent;
43
82
  cursor: grab;
44
83
  border-radius: var(--ui-slider-track-radius);
45
84
  corner-shape: var(--ui-slider-track-corner-shape);
46
85
 
47
86
  /* transparent outline keeps focus visible in forced-colors / high-contrast
48
- modes; the visible focus ring lives on the thumb via --shadow-ring */
87
+ modes; the visible focus ring lives on the thumb */
49
88
  outline: var(--outline-width) var(--outline-style) transparent;
50
89
  outline-offset: var(--outline-offset);
51
90
  }
52
91
 
92
+ /* An outer shadow would paint at the edge of the grown thumb box, not the visible thumb */
93
+ @media (not (hover: hover)) {
94
+ :where(input[type="range"]) {
95
+ --_slider-thumb-drop: 0 0 transparent;
96
+ }
97
+ }
53
98
  :where(input[type="range"])::-webkit-slider-runnable-track {
54
99
  block-size: var(--ui-slider-track-h);
55
100
  inline-size: 100%;
56
101
  background: var(--ui-slider-track-bg);
57
- border: var(--ui-slider-track-border);
102
+ border: var(--ui-slider-track-border-width) solid var(--ui-slider-track-border-color);
58
103
  border-radius: var(--ui-slider-track-radius);
59
104
  corner-shape: var(--ui-slider-track-corner-shape);
60
105
  }
@@ -63,74 +108,82 @@
63
108
  block-size: var(--ui-slider-track-h);
64
109
  inline-size: 100%;
65
110
  background: var(--ui-slider-track-bg);
66
- border: var(--ui-slider-track-border);
111
+ border: var(--ui-slider-track-border-width) solid var(--ui-slider-track-border-color);
67
112
  border-radius: var(--ui-slider-track-radius);
68
113
  corner-shape: var(--ui-slider-track-corner-shape);
69
114
  }
70
115
 
71
116
  :where(input[type="range"])::-webkit-slider-thumb {
72
- /* the ring is a box-shadow so it composes with --ui-slider-thumb-shadow;
73
- widths animate from 0 so it grows in on focus */
74
- --_ring-offset-width: 0px;
75
- --_ring-width: 0px;
76
- --_ring-fill: color-mix(in oklch, var(--ui-slider-ring-color) var(--ring-opacity), transparent);
77
- box-shadow:
78
- 0 0 0 var(--_ring-offset-width) var(--ring-offset-shadow-color),
79
- 0 0 0 calc(var(--_ring-offset-width) + var(--_ring-width))
80
- var(--_ring-fill, var(--ring-shadow-color)),
81
- var(--ui-slider-thumb-shadow);
82
-
83
117
  -webkit-appearance: none;
84
118
  appearance: none;
85
119
  margin-block-start: var(--ui-slider-thumb-offset);
120
+ box-sizing: content-box;
86
121
  inline-size: var(--ui-slider-thumb-size);
87
122
  block-size: var(--ui-slider-thumb-size);
123
+ /* the padding box is the visible thumb; the transparent border is the extra hit area */
124
+ border: var(--_slider-thumb-hit) solid transparent;
88
125
  background-color: var(--ui-slider-thumb-bg);
89
- border: var(--ui-slider-thumb-border);
90
- border-radius: var(--ui-slider-thumb-radius);
126
+ background-clip: padding-box;
127
+ border-radius: calc(var(--ui-slider-thumb-radius) + var(--_slider-thumb-hit));
91
128
  corner-shape: var(--ui-slider-thumb-corner-shape);
129
+ /* the visible border, then the ring outside the thumb (or inside it once the box has
130
+ grown), then the drop shadow */
131
+ box-shadow:
132
+ inset 0 0 0 var(--ui-slider-thumb-border-width) var(--ui-slider-thumb-border-color),
133
+ 0 0 0 calc(var(--_ring-offset-width) * (1 - var(--_slider-thumb-in)))
134
+ var(--ring-offset-shadow-color),
135
+ 0 0 0 calc((var(--_ring-offset-width) + var(--_ring-width)) * (1 - var(--_slider-thumb-in)))
136
+ var(--_ring-fill, var(--ring-shadow-color)),
137
+ inset 0 0 0 calc(var(--_ring-offset-width) * var(--_slider-thumb-in))
138
+ var(--ring-offset-shadow-color),
139
+ inset 0 0 0 calc((var(--_ring-offset-width) + var(--_ring-width)) * var(--_slider-thumb-in))
140
+ var(--_ring-fill, var(--ring-shadow-color)),
141
+ var(--_slider-thumb-drop);
92
142
 
93
143
  transition: var(--default-transition);
94
144
  }
95
145
 
96
146
  :where(input[type="range"])::-moz-range-thumb {
97
- /* the ring is a box-shadow so it composes with --ui-slider-thumb-shadow;
98
- widths animate from 0 so it grows in on focus */
99
- --_ring-offset-width: 0px;
100
- --_ring-width: 0px;
101
- --_ring-fill: color-mix(in oklch, var(--ui-slider-ring-color) var(--ring-opacity), transparent);
102
-
103
147
  appearance: none;
148
+ box-sizing: content-box;
104
149
  inline-size: var(--ui-slider-thumb-size);
105
150
  block-size: var(--ui-slider-thumb-size);
151
+ /* the padding box is the visible thumb; the transparent border is the extra hit area */
152
+ border: var(--_slider-thumb-hit) solid transparent;
106
153
  background-color: var(--ui-slider-thumb-bg);
107
- border: var(--ui-slider-thumb-border);
108
- border-radius: var(--ui-slider-thumb-radius);
154
+ background-clip: padding-box;
155
+ border-radius: calc(var(--ui-slider-thumb-radius) + var(--_slider-thumb-hit));
109
156
  corner-shape: var(--ui-slider-thumb-corner-shape);
110
-
157
+ /* the visible border, then the ring outside the thumb (or inside it once the box has
158
+ grown), then the drop shadow */
111
159
  box-shadow:
112
- 0 0 0 var(--_ring-offset-width) var(--ring-offset-shadow-color),
113
- 0 0 0 calc(var(--_ring-offset-width) + var(--_ring-width))
160
+ inset 0 0 0 var(--ui-slider-thumb-border-width) var(--ui-slider-thumb-border-color),
161
+ 0 0 0 calc(var(--_ring-offset-width) * (1 - var(--_slider-thumb-in)))
162
+ var(--ring-offset-shadow-color),
163
+ 0 0 0 calc((var(--_ring-offset-width) + var(--_ring-width)) * (1 - var(--_slider-thumb-in)))
164
+ var(--_ring-fill, var(--ring-shadow-color)),
165
+ inset 0 0 0 calc(var(--_ring-offset-width) * var(--_slider-thumb-in))
166
+ var(--ring-offset-shadow-color),
167
+ inset 0 0 0 calc((var(--_ring-offset-width) + var(--_ring-width)) * var(--_slider-thumb-in))
114
168
  var(--_ring-fill, var(--ring-shadow-color)),
115
- var(--ui-slider-thumb-shadow);
169
+ var(--_slider-thumb-drop);
116
170
 
117
171
  transition: var(--default-transition);
118
172
  }
119
173
 
120
174
  @media (hover: hover) {
121
175
  :where(input[type="range"]:hover) {
122
- --ui-slider-thumb-border: 1px solid var(--color-primary);
176
+ --ui-slider-thumb-border-color: var(--color-primary);
123
177
  }
124
178
  }
125
179
 
126
- :where(input[type="range"]:active) {
127
- --ui-slider-thumb-shadow: var(--shadow-xs), var(--shadow-ring);
128
-
129
- cursor: grabbing;
180
+ :where(input[type="range"]:is(:active, :focus-visible)) {
181
+ --_ring-offset-width: var(--ring-offset-width);
182
+ --_ring-width: var(--ring-width);
130
183
  }
131
184
 
132
- :where(input[type="range"]:focus-visible) {
133
- --ui-slider-thumb-shadow: var(--shadow-xs), var(--shadow-ring);
185
+ :where(input[type="range"]:active) {
186
+ cursor: grabbing;
134
187
  }
135
188
 
136
189
  :where(input[type="range"]:disabled) {
@@ -4,6 +4,8 @@
4
4
  * @layer variables, reset
5
5
  * @requires _layers.css, _variables.css, _properties.css (--_*-resolved, --_focus-shadow), fields.css (--ui-field-* border/ring)
6
6
  * @uses appearance: none on input[role="switch"]
7
+ * @uses --_touch-min (touch screens) — the track keeps its size; an invisible ::after
8
+ * on the input, centred on it, is at least the touch floor square
7
9
  * @uses label:has(> input[role="switch"])::after — thumb drawn on label (no JS)
8
10
  * @uses oklch(from …) — checked/hover track tints
9
11
  * @uses corner-shape — round by default, so circles stay circles; a hook takes any shape
@@ -13,8 +15,9 @@
13
15
 
14
16
  @layer variables {
15
17
  :root {
16
- --ui-switch-track-w: calc(var(--spacing) * 7);
17
- --ui-switch-track-p: calc(var(--spacing) * 0.5);
18
+ /* floored so the track stays at least --spacing-control-min tall */
19
+ --ui-switch-track-w: max(calc(var(--spacing) * 7), calc(var(--spacing-control-min) * 1.75));
20
+ --ui-switch-track-p: max(calc(var(--spacing) * 0.5), calc(var(--spacing-control-min) * 0.125));
18
21
  --ui-switch-track-h: calc(var(--ui-switch-track-w) / 2 + var(--ui-switch-track-p));
19
22
 
20
23
  --ui-switch-thumb-bg: var(--color-card);
@@ -107,8 +110,17 @@
107
110
  }
108
111
 
109
112
  :where(input[role="switch"]) {
113
+ position: relative;
110
114
  appearance: none;
111
115
  flex-shrink: 0;
116
+
117
+ /* touch: the hit area, --_touch-min square at least; collapses to the track on a mouse
118
+ (the thumb is the label's ::after, so the input's own is free) */
119
+ &::after {
120
+ content: "";
121
+ position: absolute;
122
+ inset: min(0px, calc((100% - var(--_touch-min)) / 2));
123
+ }
112
124
  --_w-len: var(--_w-resolved, var(--ui-switch-track-w));
113
125
  --_w-num: var(--_w-resolved, var(--ui-switch-track-w));
114
126
  inline-size: calc(var(--_w-len) + var(--_w-num) * var(--spacing));
@@ -8,6 +8,8 @@
8
8
  * (@supports gated; checked-label fallback paints card fill without pill)
9
9
  * @uses anchor-scope — isolates --active-tab inside nested menus
10
10
  * @uses text-box, color-mix() — label trim and focus ring
11
+ * @uses --_touch-min (touch screens) — labels grow to the touch floor,
12
+ * and each inline side gains half of what the height grew
11
13
  * @uses corner-shape — superellipse corners; unsupported browsers keep plain
12
14
  * rounded corners
13
15
  * @tokens --ui-tabs-* (@layer variables)
@@ -50,6 +52,9 @@
50
52
  --ui-tabs-label-text--active: var(--color-foreground);
51
53
 
52
54
  --ui-tabs-label-px: var(--ui-field-px);
55
+ /* half the field value: labels sit inside the track's padding, and in a browser
56
+ without text-box trim the full line plus this still fits the default height */
57
+ --ui-tabs-label-py: calc(var(--ui-field-py) / 2);
53
58
  --ui-tabs-label-min-h: calc(var(--spacing) * 7);
54
59
  --ui-tabs-label-ring-color: var(--ui-field-ring-color);
55
60
  }
@@ -122,8 +127,12 @@
122
127
  font-weight: var(--ui-tabs-label-font-weight);
123
128
  line-height: var(--ui-tabs-label-leading);
124
129
 
125
- min-block-size: var(--ui-tabs-label-min-h);
126
- padding-inline: var(--ui-tabs-label-px);
130
+ min-block-size: max(var(--ui-tabs-label-min-h), var(--_touch-min));
131
+ padding-block: var(--ui-tabs-label-py);
132
+ /* each side gains half of what the touch floor added to the height */
133
+ padding-inline: calc(
134
+ var(--ui-tabs-label-px) + max(0px, (var(--_touch-min) - var(--ui-tabs-label-min-h)) / 2)
135
+ );
127
136
 
128
137
  color: var(--ui-tabs-label-text);
129
138
  background-color: var(--ui-tabs-label-bg);
@@ -19,7 +19,8 @@
19
19
  --ui-textarea-min-w: 0;
20
20
  --ui-textarea-min-h: 5lh;
21
21
  --ui-textarea-max-h: 12lh;
22
- --ui-textarea-p: var(--ui-field-px);
22
+ --ui-textarea-px: var(--ui-field-px);
23
+ --ui-textarea-py: var(--ui-field-py);
23
24
  --ui-textarea-font-size: var(--ui-field-font-size);
24
25
  --ui-textarea-leading: var(--leading-sm);
25
26
  --ui-textarea-border-width: var(--ui-field-border-width);
@@ -47,9 +48,12 @@
47
48
  --_max-h-len: var(--_max-h-resolved, var(--ui-textarea-max-h));
48
49
  --_max-h-num: var(--_max-h-resolved, var(--ui-textarea-max-h));
49
50
  max-block-size: calc(var(--_max-h-len) + var(--_max-h-num) * var(--spacing));
50
- --_p-len: var(--_p-resolved, var(--ui-textarea-p));
51
- --_p-num: var(--_p-resolved, var(--ui-textarea-p));
52
- padding: calc(var(--_p-len) + var(--_p-num) * var(--spacing));
51
+ --_px-len: var(--_px-resolved, var(--ui-textarea-px));
52
+ --_px-num: var(--_px-resolved, var(--ui-textarea-px));
53
+ padding-inline: calc(var(--_px-len) + var(--_px-num) * var(--spacing));
54
+ --_py-len: var(--_py-resolved, var(--ui-textarea-py));
55
+ --_py-num: var(--_py-resolved, var(--ui-textarea-py));
56
+ padding-block: calc(var(--_py-len) + var(--_py-num) * var(--spacing));
53
57
 
54
58
  font-size: var(--_font-size-resolved, var(--ui-textarea-font-size));
55
59
  line-height: var(--_leading-resolved, var(--ui-textarea-leading));
@@ -15,6 +15,9 @@
15
15
  * @uses text-box: vertical trim (patchy browser support)
16
16
  * @uses corner-shape — superellipse corners; unsupported browsers keep plain
17
17
  * rounded corners
18
+ * @uses --_touch-min (touch screens) — the default and icon sizes grow to the touch
19
+ * floor, and each inline side gains half of what the height grew; sm and
20
+ * icon-sm keep their box and extend an invisible ::after hit area
18
21
  * @tokens --ui-toggle-* (@layer variables;
19
22
  * default to the --ui-button-* family)
20
23
  * @consumedby toggle-group.css
@@ -57,6 +60,7 @@
57
60
 
58
61
  /* dual-mode hooks: a scale number or a length */
59
62
  --ui-toggle-gap: var(--ui-button-gap);
63
+ --ui-toggle-py: var(--ui-button-py);
60
64
  --ui-toggle-px: var(--ui-button-px);
61
65
  --ui-toggle-min-h: var(--ui-button-min-h);
62
66
  --ui-toggle-radius: var(--ui-button-radius);
@@ -175,6 +179,12 @@
175
179
  syntax: "*";
176
180
  inherits: false;
177
181
  }
182
+
183
+ @property --_toggle-py {
184
+ syntax: "*";
185
+ inherits: false;
186
+ }
187
+
178
188
  @property --_toggle-px {
179
189
  syntax: "*";
180
190
  inherits: false;
@@ -220,12 +230,29 @@
220
230
 
221
231
  --_min-h-len: var(--_min-h-resolved, var(--_toggle-min-h, var(--ui-toggle-min-h)));
222
232
  --_min-h-num: var(--_min-h-resolved, var(--_toggle-min-h, var(--ui-toggle-min-h)));
223
- min-block-size: calc(var(--_min-h-len) + var(--_min-h-num) * var(--spacing));
233
+ /* the touch floor: 0 on a mouse; a size that must stay small sets it to 0px */
234
+ --_touch-floor: var(--_touch-min);
235
+ min-block-size: max(
236
+ calc(var(--_min-h-len) + var(--_min-h-num) * var(--spacing)),
237
+ var(--_touch-floor)
238
+ );
224
239
  min-inline-size: max-content;
225
240
 
241
+ --_py-len: var(--_py-resolved, var(--_toggle-py, var(--ui-toggle-py)));
242
+ --_py-num: var(--_py-resolved, var(--_toggle-py, var(--ui-toggle-py)));
243
+ padding-block: calc(var(--_py-len) + var(--_py-num) * var(--spacing));
244
+
226
245
  --_px-len: var(--_px-resolved, var(--_toggle-px, var(--ui-toggle-px)));
227
246
  --_px-num: var(--_px-resolved, var(--_toggle-px, var(--ui-toggle-px)));
228
- padding-inline: calc(var(--_px-len) + var(--_px-num) * var(--spacing));
247
+ /* each inline side gains half of what the touch floor added to the height, so the
248
+ label's margins grow evenly */
249
+ padding-inline: calc(
250
+ var(--_px-len) + var(--_px-num) * var(--spacing) +
251
+ max(
252
+ 0px,
253
+ (var(--_touch-floor) - calc(var(--_min-h-len) + var(--_min-h-num) * var(--spacing))) / 2
254
+ )
255
+ );
229
256
 
230
257
  border-width: var(
231
258
  --_border-width-resolved,
@@ -502,13 +529,23 @@
502
529
 
503
530
  :where([data-ui~="toggle"][data-toggle-size="sm"]) {
504
531
  --_toggle-min-h: calc(var(--spacing) * 6);
532
+ /* a 16px icon, this, and the border fit the 24px box */
533
+ --_toggle-py: calc(var(--spacing) * 0.75);
505
534
  --_toggle-px: calc(var(--spacing) * 2);
506
535
  --_toggle-radius: var(--radius-sm);
536
+ /* dense by choice: the box stays small and ::after takes the touch floor */
537
+ --_touch-floor: 0px;
507
538
  }
508
539
 
509
540
  :where([data-ui~="toggle"][data-toggle-size="icon"]) {
510
- block-size: calc(var(--_min-h-len) + var(--_min-h-num) * var(--spacing));
511
- inline-size: calc(var(--_min-h-len) + var(--_min-h-num) * var(--spacing));
541
+ block-size: max(
542
+ calc(var(--_min-h-len) + var(--_min-h-num) * var(--spacing)),
543
+ var(--_touch-floor)
544
+ );
545
+ inline-size: max(
546
+ calc(var(--_min-h-len) + var(--_min-h-num) * var(--spacing)),
547
+ var(--_touch-floor)
548
+ );
512
549
  padding: 0;
513
550
  aspect-ratio: 1 / 1;
514
551
  }
@@ -519,10 +556,19 @@
519
556
  --_toggle-radius: var(--radius-sm);
520
557
  /* the hook, not a private: it must inherit to reach the icon */
521
558
  --ui-toggle-icon-size: calc(var(--spacing) * 3.5);
559
+ --_touch-floor: 0px;
522
560
 
523
561
  block-size: calc(var(--_min-h-len) + var(--_min-h-num) * var(--spacing));
524
562
  inline-size: calc(var(--_min-h-len) + var(--_min-h-num) * var(--spacing));
525
563
  padding: 0;
526
564
  aspect-ratio: 1 / 1;
527
565
  }
566
+
567
+ /* touch: sm and icon-sm keep their box; a transparent ::after centred on the toggle
568
+ (already position: relative) is at least --_touch-min square */
569
+ :where([data-ui~="toggle"]:is([data-toggle-size="sm"], [data-toggle-size="icon-sm"]))::after {
570
+ content: "";
571
+ position: absolute;
572
+ inset: min(0px, calc((100% - var(--_touch-min)) / 2));
573
+ }
528
574
  }
@@ -9,6 +9,9 @@
9
9
  * explicit anchors for polyfill; data-popover-side maps to --ui-popover-position-*
10
10
  * @uses corner-shape — superellipse corners; unsupported browsers keep plain
11
11
  * rounded corners
12
+ * @uses :dir(rtl): inline-side origins and slide-in mirror; the arrow uses logical insets
13
+ * @uses @media not (hover: hover) — hidden on touch screens (no hover to show it, and a
14
+ * tap would cover the trigger's own action); keep essential text visible
12
15
  * @tokens --ui-tooltip-* (@layer variables; read on the content slot)
13
16
  */
14
17
 
@@ -211,7 +214,7 @@
211
214
  [data-tooltip-slot~="content"][data-popover-side="left"][data-popover-align="center"] {
212
215
  --ui-tooltip-translate--start: 0.25em, 0, 0;
213
216
  --ui-popover-position-area: inline-start span-all;
214
- --ui-popover-origin: center right;
217
+ --ui-popover-origin: center var(--_origin-inline-end);
215
218
  --ui-tooltip-mx: var(--spacing);
216
219
  --ui-tooltip-my: 0;
217
220
  }
@@ -222,19 +225,34 @@
222
225
  [data-tooltip-slot~="content"][data-popover-side="right"][data-popover-align="center"] {
223
226
  --ui-tooltip-translate--start: 0.25em, 0, 0;
224
227
  --ui-popover-position-area: inline-end span-all;
225
- --ui-popover-origin: center left;
228
+ --ui-popover-origin: center var(--_origin-inline-start);
226
229
  --ui-tooltip-mx: var(--spacing);
227
230
  --ui-tooltip-my: 0;
228
231
  }
229
232
 
230
- /* Tooltip arrow */
233
+ /* translate3d is physical: mirror the inline sides' slide-in for RTL */
234
+ :where(ui-tooltip, [data-ui~="tooltip"])
235
+ [data-tooltip-slot~="content"]:is([data-popover-side="left"], [data-popover-side="right"]):is(
236
+ :not([data-popover-align]),
237
+ [data-popover-align="center"]
238
+ ):dir(rtl) {
239
+ --ui-tooltip-translate--start: -0.25em, 0, 0;
240
+ }
241
+
242
+ /* Tooltip arrow: logical insets throughout, so the inline sides mirror in RTL
243
+ (data-popover-side="left | right" place on the inline-start | inline-end
244
+ side). Fixed size + auto margins center it along its edge in any direction.
245
+ It stays on the declared side when a position-try fallback flips the tooltip:
246
+ container-type: anchored + @container anchored(fallback: …) would move it
247
+ (Chromium 143+), but Lightning CSS 1.33 (vp pack, Vite 8's CSS minifier)
248
+ cannot parse anchored(). Add it once it can. */
231
249
  :where(ui-tooltip, [data-ui~="tooltip"]) [data-tooltip-slot~="arrow"] {
250
+ --_arrow-offset: calc(var(--ui-tooltip-arrow-size) / -2);
232
251
  position: absolute;
233
- /* physical top/left/right/bottom throughout the arrow rules: they pair with
234
- the physical [data-popover-side] placement semantics from anchor positioning */
235
- top: calc(100% - var(--ui-tooltip-arrow-size) / 2);
236
- left: 50%;
237
- transform: translate(-50%, 0%) rotate(45deg);
252
+ inset-block: auto var(--_arrow-offset);
253
+ inset-inline: 0;
254
+ margin: 0 auto;
255
+ transform: rotate(45deg);
238
256
  inline-size: var(--ui-tooltip-arrow-size);
239
257
  block-size: var(--ui-tooltip-arrow-size);
240
258
  background-color: var(--ui-tooltip-arrow-color);
@@ -242,35 +260,32 @@
242
260
  pointer-events: none;
243
261
  }
244
262
 
245
- /* Tooltip arrow position */
246
- :where(ui-tooltip, [data-ui~="tooltip"])
247
- [data-tooltip-slot~="content"][data-popover-side="top"]
248
- [data-tooltip-slot~="arrow"] {
249
- bottom: calc((var(--ui-tooltip-arrow-size) / 2) * -1);
250
- left: 50%;
251
- }
252
-
263
+ /* Tooltip arrow position (the base rule above is the top side) */
253
264
  :where(ui-tooltip, [data-ui~="tooltip"])
254
265
  [data-tooltip-slot~="content"][data-popover-side="bottom"]
255
266
  [data-tooltip-slot~="arrow"] {
256
- top: calc((var(--ui-tooltip-arrow-size) / 2) * -1);
257
- left: 50%;
267
+ inset-block: var(--_arrow-offset) auto;
258
268
  }
259
269
 
260
270
  :where(ui-tooltip, [data-ui~="tooltip"])
261
271
  [data-tooltip-slot~="content"][data-popover-side="left"]
262
272
  [data-tooltip-slot~="arrow"] {
263
- left: calc(100% - var(--ui-tooltip-arrow-size) / 2);
264
- top: 50%;
265
- transform: translate(0%, -50%) rotate(45deg);
273
+ inset-block: 0;
274
+ inset-inline: auto var(--_arrow-offset);
275
+ margin: auto 0;
266
276
  }
267
277
 
268
278
  :where(ui-tooltip, [data-ui~="tooltip"])
269
279
  [data-tooltip-slot~="content"][data-popover-side="right"]
270
280
  [data-tooltip-slot~="arrow"] {
271
- right: calc(100% - var(--ui-tooltip-arrow-size) / 2);
272
- left: auto;
273
- top: 50%;
274
- transform: translate(0%, -50%) rotate(45deg);
281
+ inset-block: 0;
282
+ inset-inline: var(--_arrow-offset) auto;
283
+ margin: auto 0;
284
+ }
285
+
286
+ @media not (hover: hover) {
287
+ :where(ui-tooltip, [data-ui~="tooltip"]) {
288
+ display: none !important;
289
+ }
275
290
  }
276
291
  }