@eluan/core 0.5.1 → 0.6.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 (322) hide show
  1. package/README.md +33 -1
  2. package/dist/{action-popover-D6K9aVFk.cjs → action-popover-DrHKPGqw.cjs} +1 -1
  3. package/dist/{action-popover-BVJQBuky.js → action-popover-NkXDAHJT.js} +1 -1
  4. package/dist/action-popover.cjs +1 -1
  5. package/dist/action-popover.js +1 -1
  6. package/dist/{avatar-Co-k8KqV.cjs → avatar-B-t3ctR4.cjs} +1 -1
  7. package/dist/{avatar-CS5f1irF.js → avatar-kDEa0rjF.js} +1 -1
  8. package/dist/avatar.cjs +1 -1
  9. package/dist/avatar.js +1 -1
  10. package/dist/{badge-D9NYZFWH.js → badge-BLZ8V-KC.js} +10 -10
  11. package/dist/{badge-DXKWztL-.cjs → badge-D1A0Tc79.cjs} +1 -1
  12. package/dist/badge.cjs +1 -1
  13. package/dist/badge.js +1 -1
  14. package/dist/{banner-COlEFRuK.cjs → banner-CNdwDPqA.cjs} +1 -1
  15. package/dist/{banner-CyYFLZXw.js → banner-DzSp5WfQ.js} +9 -9
  16. package/dist/banner.cjs +1 -1
  17. package/dist/banner.js +1 -1
  18. package/dist/box-DG-tkaYi.cjs +1 -0
  19. package/dist/box-DKbNgGGG.js +17 -0
  20. package/dist/box.cjs +1 -0
  21. package/dist/box.d.ts +1 -0
  22. package/dist/box.js +5 -0
  23. package/dist/{breadcrumb-NWXeCH5q.cjs → breadcrumb-BuxXkm6O.cjs} +1 -1
  24. package/dist/{breadcrumb-Cm1nb9Xj.js → breadcrumb-C6qj-tDx.js} +1 -1
  25. package/dist/breadcrumb.cjs +1 -1
  26. package/dist/breadcrumb.js +1 -1
  27. package/dist/button--_WI-fM6.cjs +1 -0
  28. package/dist/{button-ANAPDrvs.js → button-DNSNShUc.js} +28 -26
  29. package/dist/button.cjs +1 -1
  30. package/dist/button.js +1 -1
  31. package/dist/{calendar-BpBsomy5.js → calendar-BA2tSwZD.js} +6 -6
  32. package/dist/{calendar-7LX5YGGT.cjs → calendar-DS5821-k.cjs} +3 -3
  33. package/dist/calendar.cjs +1 -1
  34. package/dist/calendar.js +1 -1
  35. package/dist/{card-C88--zB4.cjs → card-BNdR5aDa.cjs} +1 -1
  36. package/dist/{card-BC_4C3ns.js → card-BSgN7WSe.js} +1 -1
  37. package/dist/card.cjs +1 -1
  38. package/dist/card.js +1 -1
  39. package/dist/{carousel-BfL7oy_q.cjs → carousel-4AERgboz.cjs} +1 -1
  40. package/dist/{carousel-DuP0hvF-.js → carousel-Bb7jpzep.js} +1 -1
  41. package/dist/carousel.cjs +1 -1
  42. package/dist/carousel.js +1 -1
  43. package/dist/{checkbox-Bi0Kmuut.js → checkbox-CGUTGery.js} +1 -1
  44. package/dist/{checkbox-M8DmWKiC.cjs → checkbox-Cq9sHU_S.cjs} +1 -1
  45. package/dist/{checkbox-group-KBwPhjmW.cjs → checkbox-group-DGXZ4o2-.cjs} +1 -1
  46. package/dist/{checkbox-group-CQMEJnhD.js → checkbox-group-Tkio3IhK.js} +1 -1
  47. package/dist/checkbox-group.cjs +1 -1
  48. package/dist/checkbox-group.js +1 -1
  49. package/dist/checkbox.cjs +1 -1
  50. package/dist/checkbox.js +1 -1
  51. package/dist/{command-BCl0seLL.cjs → command-D02vvta9.cjs} +1 -1
  52. package/dist/{command-Chs5VlBL.js → command-sUMAxm8S.js} +1 -1
  53. package/dist/command.cjs +1 -1
  54. package/dist/command.js +1 -1
  55. package/dist/components/box.d.ts +12 -0
  56. package/dist/components/grid.d.ts +35 -0
  57. package/dist/components/icon.d.ts +26 -0
  58. package/dist/components/layout-shared.d.ts +307 -0
  59. package/dist/components/navigation-drawer.d.ts +25 -5
  60. package/dist/components/row.d.ts +18 -0
  61. package/dist/components/stack.d.ts +14 -0
  62. package/dist/components/tone-shared.d.ts +39 -0
  63. package/dist/components/typography.d.ts +22 -2
  64. package/dist/components/visually-hidden.d.ts +11 -0
  65. package/dist/{credit-card-input-DN-8vaFj.js → credit-card-input-9VPlzvDm.js} +1 -1
  66. package/dist/{credit-card-input-CUqA9CX3.cjs → credit-card-input-DppPJBne.cjs} +1 -1
  67. package/dist/credit-card-input.cjs +1 -1
  68. package/dist/credit-card-input.js +1 -1
  69. package/dist/{date-picker-ni8td8Ru.js → date-picker-M5hLx_1s.js} +2 -2
  70. package/dist/{date-picker-DGBsfZXx.cjs → date-picker-hE7cDg2B.cjs} +1 -1
  71. package/dist/date-picker.cjs +1 -1
  72. package/dist/date-picker.js +1 -1
  73. package/dist/{datetime-picker-C1d63MaA.cjs → datetime-picker-BeRUPJ7s.cjs} +1 -1
  74. package/dist/{datetime-picker-DsnHYRK-.js → datetime-picker-CIqBZYMH.js} +3 -3
  75. package/dist/datetime-picker.cjs +1 -1
  76. package/dist/datetime-picker.js +1 -1
  77. package/dist/{decimal-input-yTk35W_5.js → decimal-input-Bg2BPKIr.js} +38 -38
  78. package/dist/decimal-input-CkTEjo2J.cjs +1 -0
  79. package/dist/decimal-input.cjs +1 -1
  80. package/dist/decimal-input.js +1 -1
  81. package/dist/{dialog-B8eWKqzS.js → dialog-Bsfviqvy.js} +2 -2
  82. package/dist/dialog-DRAoumvB.cjs +1 -0
  83. package/dist/dialog.cjs +1 -1
  84. package/dist/dialog.js +1 -1
  85. package/dist/{email-input-DFI4h_KN.cjs → email-input-CehmtNUq.cjs} +1 -1
  86. package/dist/{email-input-pX0hlYV3.js → email-input-DIiY9Q3S.js} +1 -1
  87. package/dist/email-input.cjs +1 -1
  88. package/dist/email-input.js +1 -1
  89. package/dist/{footer-DB0_-IwN.cjs → footer-fovIsy-0.cjs} +1 -1
  90. package/dist/{footer-B3KUIwXW.js → footer-jWaFq3qk.js} +9 -9
  91. package/dist/footer.cjs +1 -1
  92. package/dist/footer.js +1 -1
  93. package/dist/grid-BDz4Xs6M.cjs +1 -0
  94. package/dist/grid-BX5vZjDo.js +612 -0
  95. package/dist/grid.cjs +1 -0
  96. package/dist/grid.d.ts +1 -0
  97. package/dist/grid.js +5 -0
  98. package/dist/{header-CDOWlOAR.js → header-Dnf8AnIx.js} +2 -2
  99. package/dist/{header-CiZQY_7S.cjs → header-DzItWqW4.cjs} +1 -1
  100. package/dist/header.cjs +1 -1
  101. package/dist/header.js +1 -1
  102. package/dist/icon-BmLOodCQ.cjs +1 -0
  103. package/dist/icon-BwDfkIdR.js +153 -0
  104. package/dist/icon.cjs +1 -0
  105. package/dist/icon.d.ts +1 -0
  106. package/dist/icon.js +5 -0
  107. package/dist/index.cjs +10 -5
  108. package/dist/index.d.ts +6 -0
  109. package/dist/index.js +612 -541
  110. package/dist/{input-BrGJn-D9.cjs → input-BcjL2oxv.cjs} +1 -1
  111. package/dist/{input-Cccufiqn.js → input-CPb9yVU5.js} +8 -8
  112. package/dist/input-otp-BhJ3ERrY.cjs +1 -0
  113. package/dist/{input-otp-DmEGB1nu.js → input-otp-CTvJztkH.js} +32 -32
  114. package/dist/input-otp.cjs +1 -1
  115. package/dist/input-otp.js +1 -1
  116. package/dist/input.cjs +1 -1
  117. package/dist/input.js +1 -1
  118. package/dist/layout-shared-B_1iX4Hj.js +319 -0
  119. package/dist/layout-shared-CsBZcT4V.cjs +1 -0
  120. package/dist/{multi-select-B6NBbDCW.js → multi-select-CVxkWW29.js} +30 -30
  121. package/dist/multi-select-DBFINH3F.cjs +1 -0
  122. package/dist/multi-select.cjs +1 -1
  123. package/dist/multi-select.js +1 -1
  124. package/dist/navigation-drawer-BCBFtLEq.cjs +1 -0
  125. package/dist/navigation-drawer-BMyHXhhX.js +198 -0
  126. package/dist/navigation-drawer.cjs +1 -1
  127. package/dist/navigation-drawer.js +1 -1
  128. package/dist/{number-input-vICbRc2y.js → number-input-Cm9YPBOX.js} +1 -1
  129. package/dist/{number-input-Bc7jUsu-.cjs → number-input-Dr9MbuRV.cjs} +1 -1
  130. package/dist/number-input.cjs +1 -1
  131. package/dist/number-input.js +1 -1
  132. package/dist/{pagination-DTWRjiOm.js → pagination-D2tjMpVU.js} +2 -2
  133. package/dist/{pagination-4IuE_APs.cjs → pagination-yKmFlFMR.cjs} +1 -1
  134. package/dist/pagination.cjs +1 -1
  135. package/dist/pagination.js +1 -1
  136. package/dist/{password-input-BwnlHPbX.cjs → password-input-CmHubHuU.cjs} +1 -1
  137. package/dist/{password-input-B9V45d3Q.js → password-input-ljwdGCO6.js} +2 -2
  138. package/dist/password-input.cjs +1 -1
  139. package/dist/password-input.js +1 -1
  140. package/dist/{phone-input-BQjZj5jI.cjs → phone-input-B8VksCer.cjs} +1 -1
  141. package/dist/{phone-input-CSBpGHvI.js → phone-input-qTL6K8rT.js} +2 -2
  142. package/dist/phone-input.cjs +1 -1
  143. package/dist/phone-input.js +1 -1
  144. package/dist/progress-BpdmBGaX.cjs +1 -0
  145. package/dist/{progress-Dz_it5I-.js → progress-ChFf9bIq.js} +1 -1
  146. package/dist/progress.cjs +1 -1
  147. package/dist/progress.js +1 -1
  148. package/dist/providers/create-theme.d.ts +10 -1
  149. package/dist/{radio-group-C--1neiq.cjs → radio-group-9gozRouT.cjs} +1 -1
  150. package/dist/{radio-group-CNMPZx_2.js → radio-group-Bs9933bk.js} +6 -6
  151. package/dist/radio-group.cjs +1 -1
  152. package/dist/radio-group.js +1 -1
  153. package/dist/{rich-text-BZSyuYSo.js → rich-text-DImwK9hN.js} +1 -1
  154. package/dist/{rich-text-DerWxzdn.cjs → rich-text-DzHLeG7W.cjs} +1 -1
  155. package/dist/rich-text.cjs +1 -1
  156. package/dist/rich-text.js +1 -1
  157. package/dist/row-BYAk7G5d.js +37 -0
  158. package/dist/row-Bjn-GQAC.cjs +1 -0
  159. package/dist/row.cjs +1 -0
  160. package/dist/row.d.ts +1 -0
  161. package/dist/row.js +5 -0
  162. package/dist/{search-input-Dmmo-BEL.cjs → search-input-BKTjebg7.cjs} +1 -1
  163. package/dist/{search-input-bFNW6oiE.js → search-input-Dgr9kT1a.js} +1 -1
  164. package/dist/search-input.cjs +1 -1
  165. package/dist/search-input.js +1 -1
  166. package/dist/select-Cdh991T-.cjs +1 -0
  167. package/dist/{select-DDSYjKtj.js → select-Dp5AJ6I-.js} +15 -15
  168. package/dist/select.cjs +1 -1
  169. package/dist/select.js +1 -1
  170. package/dist/sheet-CkXjinUG.cjs +1 -0
  171. package/dist/{sheet-D5HWF66e.js → sheet-uiyHNKEw.js} +6 -6
  172. package/dist/sheet.cjs +1 -1
  173. package/dist/sheet.js +1 -1
  174. package/dist/{slider-CZQBAXup.js → slider-BQmbh0Nl.js} +1 -1
  175. package/dist/{slider-DdEOapYP.cjs → slider-DK2yk-YK.cjs} +1 -1
  176. package/dist/slider.cjs +1 -1
  177. package/dist/slider.js +1 -1
  178. package/dist/stack-Ck1w2iJu.cjs +1 -0
  179. package/dist/stack-D2btWM1t.js +27 -0
  180. package/dist/stack.cjs +1 -0
  181. package/dist/stack.d.ts +1 -0
  182. package/dist/stack.js +5 -0
  183. package/dist/{stepper-D5nDwJUz.cjs → stepper-ByYKX7qw.cjs} +1 -1
  184. package/dist/{stepper-BtlKiHtd.js → stepper-Copsj87A.js} +4 -4
  185. package/dist/stepper.cjs +1 -1
  186. package/dist/stepper.js +1 -1
  187. package/dist/styles.css +935 -59
  188. package/dist/{switch-KzBijHMJ.cjs → switch-C2OPCq5Z.cjs} +1 -1
  189. package/dist/{switch-C7EBLT5H.js → switch-CXBWUZcq.js} +3 -3
  190. package/dist/switch.cjs +1 -1
  191. package/dist/switch.js +1 -1
  192. package/dist/{tabs-DztJ2iVc.cjs → tabs-D8p6Tr5i.cjs} +1 -1
  193. package/dist/{tabs-C9NKBmH0.js → tabs-TV4_2wi1.js} +9 -9
  194. package/dist/tabs.cjs +1 -1
  195. package/dist/tabs.js +1 -1
  196. package/dist/{textarea-Dl-daLHR.cjs → textarea-BnpQmE74.cjs} +1 -1
  197. package/dist/{textarea-DXUk1b_-.js → textarea-CJRmnazN.js} +1 -1
  198. package/dist/textarea.cjs +1 -1
  199. package/dist/textarea.js +1 -1
  200. package/dist/{time-input-BPoFvoeM.js → time-input-A603mEFQ.js} +38 -38
  201. package/dist/time-input-qxljhdEb.cjs +1 -0
  202. package/dist/time-input.cjs +1 -1
  203. package/dist/time-input.js +1 -1
  204. package/dist/{toggle-Dv1VZ5Le.js → toggle-Bx3q15Pu.js} +6 -6
  205. package/dist/{toggle-Bvh1v32T.cjs → toggle-Z3t4jPdv.cjs} +1 -1
  206. package/dist/{toggle-group-SyHMwO90.cjs → toggle-group-BZIW4wJp.cjs} +1 -1
  207. package/dist/{toggle-group-DE8BPZih.js → toggle-group-LaZmOMx_.js} +7 -7
  208. package/dist/toggle-group.cjs +1 -1
  209. package/dist/toggle-group.js +1 -1
  210. package/dist/toggle.cjs +1 -1
  211. package/dist/toggle.js +1 -1
  212. package/dist/{tree-view-CyeJR7cW.js → tree-view-DRmm6oL6.js} +23 -23
  213. package/dist/tree-view-DVQyRQDg.cjs +1 -0
  214. package/dist/tree-view.cjs +1 -1
  215. package/dist/tree-view.js +1 -1
  216. package/dist/visually-hidden-BQMRYGxP.js +14 -0
  217. package/dist/visually-hidden-DzxxOswl.cjs +1 -0
  218. package/dist/visually-hidden.cjs +1 -0
  219. package/dist/visually-hidden.d.ts +1 -0
  220. package/dist/visually-hidden.js +5 -0
  221. package/package.json +8 -8
  222. package/skills/eluan/DESIGN.md +409 -0
  223. package/skills/eluan/SKILL.md +166 -0
  224. package/skills/eluan/components/accordion.md +212 -0
  225. package/skills/eluan/components/action-popover.md +266 -0
  226. package/skills/eluan/components/aspect-ratio.md +169 -0
  227. package/skills/eluan/components/avatar.md +277 -0
  228. package/skills/eluan/components/badge.md +190 -0
  229. package/skills/eluan/components/banner.md +247 -0
  230. package/skills/eluan/components/box.md +166 -0
  231. package/skills/eluan/components/breadcrumb.md +240 -0
  232. package/skills/eluan/components/button.md +214 -0
  233. package/skills/eluan/components/calendar.md +192 -0
  234. package/skills/eluan/components/card.md +270 -0
  235. package/skills/eluan/components/carousel.md +274 -0
  236. package/skills/eluan/components/checkbox-group.md +228 -0
  237. package/skills/eluan/components/checkbox.md +226 -0
  238. package/skills/eluan/components/code-block.md +193 -0
  239. package/skills/eluan/components/collapsible.md +240 -0
  240. package/skills/eluan/components/command.md +359 -0
  241. package/skills/eluan/components/context-menu.md +296 -0
  242. package/skills/eluan/components/credit-card-input.md +217 -0
  243. package/skills/eluan/components/date-picker.md +255 -0
  244. package/skills/eluan/components/date-time-picker.md +196 -0
  245. package/skills/eluan/components/decimal-input.md +232 -0
  246. package/skills/eluan/components/dialog.md +322 -0
  247. package/skills/eluan/components/drawer.md +292 -0
  248. package/skills/eluan/components/dropdown-menu.md +450 -0
  249. package/skills/eluan/components/email-input.md +200 -0
  250. package/skills/eluan/components/fieldset.md +219 -0
  251. package/skills/eluan/components/file-input.md +249 -0
  252. package/skills/eluan/components/footer.md +290 -0
  253. package/skills/eluan/components/form-label.md +254 -0
  254. package/skills/eluan/components/grid.md +192 -0
  255. package/skills/eluan/components/header.md +242 -0
  256. package/skills/eluan/components/hover-card.md +215 -0
  257. package/skills/eluan/components/icon.md +161 -0
  258. package/skills/eluan/components/input-otp.md +227 -0
  259. package/skills/eluan/components/input.md +249 -0
  260. package/skills/eluan/components/kbd.md +216 -0
  261. package/skills/eluan/components/media.md +244 -0
  262. package/skills/eluan/components/menubar.md +300 -0
  263. package/skills/eluan/components/multi-select.md +221 -0
  264. package/skills/eluan/components/navigation-drawer.md +297 -0
  265. package/skills/eluan/components/navigation-menu.md +291 -0
  266. package/skills/eluan/components/number-input.md +190 -0
  267. package/skills/eluan/components/pagination.md +262 -0
  268. package/skills/eluan/components/password-input.md +218 -0
  269. package/skills/eluan/components/phone-input.md +205 -0
  270. package/skills/eluan/components/popover.md +250 -0
  271. package/skills/eluan/components/progress.md +185 -0
  272. package/skills/eluan/components/radio-group.md +232 -0
  273. package/skills/eluan/components/rich-text.md +195 -0
  274. package/skills/eluan/components/row.md +174 -0
  275. package/skills/eluan/components/scroll-area.md +203 -0
  276. package/skills/eluan/components/search-input.md +281 -0
  277. package/skills/eluan/components/segmented-control.md +201 -0
  278. package/skills/eluan/components/select.md +296 -0
  279. package/skills/eluan/components/separator.md +179 -0
  280. package/skills/eluan/components/sheet.md +326 -0
  281. package/skills/eluan/components/skeleton.md +202 -0
  282. package/skills/eluan/components/slider.md +195 -0
  283. package/skills/eluan/components/spinner.md +187 -0
  284. package/skills/eluan/components/stack.md +158 -0
  285. package/skills/eluan/components/stepper.md +236 -0
  286. package/skills/eluan/components/switch.md +218 -0
  287. package/skills/eluan/components/table.md +348 -0
  288. package/skills/eluan/components/tabs.md +277 -0
  289. package/skills/eluan/components/textarea.md +202 -0
  290. package/skills/eluan/components/time-input.md +181 -0
  291. package/skills/eluan/components/toast.md +251 -0
  292. package/skills/eluan/components/toggle-group.md +241 -0
  293. package/skills/eluan/components/toggle.md +198 -0
  294. package/skills/eluan/components/tooltip.md +222 -0
  295. package/skills/eluan/components/tree-view.md +213 -0
  296. package/skills/eluan/components/typography.md +207 -0
  297. package/skills/eluan/components/visually-hidden.md +132 -0
  298. package/skills/eluan/foundations/colour.md +252 -0
  299. package/skills/eluan/foundations/elevation.md +57 -0
  300. package/skills/eluan/foundations/iconography.md +70 -0
  301. package/skills/eluan/foundations/motion.md +60 -0
  302. package/skills/eluan/foundations/radius.md +61 -0
  303. package/skills/eluan/foundations/spacing.md +98 -0
  304. package/skills/eluan/foundations/theming.md +197 -0
  305. package/skills/eluan/foundations/typography.md +163 -0
  306. package/skills/eluan/patterns/empty-states.md +84 -0
  307. package/skills/eluan/patterns/feedback.md +95 -0
  308. package/skills/eluan/patterns/forms.md +138 -0
  309. package/skills/eluan/patterns/navigation.md +95 -0
  310. package/skills/eluan/patterns/page-layout.md +101 -0
  311. package/dist/button-Ny6OF8Un.cjs +0 -1
  312. package/dist/decimal-input-BLmifKF2.cjs +0 -1
  313. package/dist/dialog-DWYtFhZl.cjs +0 -1
  314. package/dist/input-otp-DcZ7wyjs.cjs +0 -1
  315. package/dist/multi-select-kcoUbSwE.cjs +0 -1
  316. package/dist/navigation-drawer-BbeDYPhu.js +0 -171
  317. package/dist/navigation-drawer-DOOHfbY3.cjs +0 -1
  318. package/dist/progress-DpQjGEyn.cjs +0 -1
  319. package/dist/select-1Eb3NSrR.cjs +0 -1
  320. package/dist/sheet-7NP1LuHy.cjs +0 -1
  321. package/dist/time-input-DR2snTgB.cjs +0 -1
  322. package/dist/tree-view-CNvEc1TT.cjs +0 -1
@@ -0,0 +1,158 @@
1
+ ---
2
+ name: Stack
3
+ use_when: Children go one above the other with a token gap, such as page sections, form fields, or a heading over its text.
4
+ instead_of: Row for items side by side; Grid for columns; Fieldset for a labelled group of form fields; margins on the children.
5
+ source: packages/core/src/components/stack.tsx
6
+ ---
7
+
8
+ # Stack
9
+
10
+ ## 1. Overview
11
+
12
+ Stack is vertical flow: a flex column with a `--spacing-*` gap between its children. It draws nothing (no background, border or radius) and only places what's inside it, so a page can be laid out from tokens without a utility framework or hand-written CSS. It takes `Box`'s props (padding, `grow`, `shrink`, `height`, `minHeight`, `position`, `inset`, `overflow`), `as` and `asChild`, and drops `className` and `style`.
13
+
14
+ ## 2. When to use
15
+
16
+ - The outer flow of a page or panel: header, sections, footer.
17
+ - Form fields one under another, with the submit row last.
18
+ - A heading over its supporting text, or a label over a value.
19
+ - Any list of items you compose yourself.
20
+
21
+ ### When not to use
22
+
23
+ - Items side by side → [Row](./row.md).
24
+ - Items in columns, or a layout that changes columns with the viewport → [Grid](./grid.md).
25
+ - A group of form fields under a legend → [Fieldset](./fieldset.md), with a Stack inside if needed.
26
+ - A framed block with a surface → [Card](./card.md); a Stack goes inside its content.
27
+ - Padding alone, with no flow → [Box](./box.md).
28
+
29
+ ## 3. Anatomy
30
+
31
+ 1. **Container**: one element (`div` by default) laid out as a flex column with `min-width: 0`, so it can shrink inside a Row or Grid. Children sit directly inside it.
32
+
33
+ ## 4. Variants
34
+
35
+ Stack has no `variant`. `align` and `justify` change how children sit:
36
+
37
+ | Prop | Values | Default |
38
+ | --- | --- | --- |
39
+ | `align` (cross axis) | `start`, `center`, `end`, `stretch`, `baseline` | unset: children stretch to the Stack's width |
40
+ | `justify` (main axis) | `start`, `center`, `end`, `between` | unset: children pack at the top |
41
+
42
+ ## 5. Sizes
43
+
44
+ Stack has no size prop. `gap` sets the space between children and `pad`, `padX`, `padY` set padding, each a `--spacing-*` step from `"none"` to `"4xl"`. `gap` defaults to `"md"`.
45
+
46
+ ## 6. States
47
+
48
+ | State | Looks like | Notes |
49
+ | --- | --- | --- |
50
+ | Default | Children stacked with the gap | Static. Stack has no interactive states. |
51
+
52
+ ## 7. Content guidelines
53
+
54
+ - Pick the gap by relationship, not by pixel: tight (`xs`, `sm`) between a label and its value, `md` to `lg` between fields or list items, `2xl` to `3xl` between page sections.
55
+ - Nest Stacks to group: an outer Stack with a large gap between sections, an inner one with a small gap inside each.
56
+
57
+ ## 8. Rules
58
+
59
+ 1. Space children with `gap`. Never put margins on the children.
60
+ 2. Use `--spacing-*` steps only, through `gap` and `pad*`. Never write px.
61
+ 3. Use `as` for the element's meaning (`main`, `section`, `form`, `nav`), not a wrapper `div` around the Stack.
62
+ 4. For list semantics, prefer `role="list"` on the Stack and `role="listitem"` on each child over `as="ul"`: a `ul` keeps the browser's list margin, which no prop resets.
63
+ 5. Don't pass `className` or `style`; they're dropped. Position, height and overflow are props; fixed widths, hover effects and animation go on an element you own, with the Stack nested in it.
64
+ 6. Don't wrap a single child in a Stack to pad it. Use [Box](./box.md).
65
+
66
+ ## 9. Dos and don'ts
67
+
68
+ **Do:** stack fields with a gap.
69
+
70
+ ```tsx
71
+ <Stack as="form" gap="lg" onSubmit={save}>
72
+ <Input aria-label="Name" />
73
+ <Input type="email" aria-label="Email" />
74
+ <Button type="submit">Save</Button>
75
+ </Stack>
76
+ ```
77
+
78
+ **Don't:** space children with margins or a hand-written flex column.
79
+
80
+ ```tsx
81
+ <div style={{ display: "flex", flexDirection: "column" }}>
82
+ <Input aria-label="Name" style={{ marginBottom: 16 }} />
83
+ <Button type="submit">Save</Button>
84
+ </div>
85
+ ```
86
+
87
+ ## 10. Accessibility
88
+
89
+ - Role: none by default (a `div`). Use `as` for landmarks and forms (`main`, `nav`, `section` with a label, `form`), or `role="list"` for a list.
90
+ - Label: give a `section` an `aria-label` or `aria-labelledby` so it becomes a region landmark.
91
+ - Keyboard: none. Stack isn't focusable.
92
+ - Order: visual order is DOM order. `justify` and `align` don't reorder children, so reading order matches what's shown.
93
+
94
+ ## 11. Behaviour
95
+
96
+ - Responsive: Stack is one column at every width. For a layout that becomes several columns, use Grid.
97
+ - Density: `gap` and padding follow `data-spacing`, so a Stack re-flows with the components inside it.
98
+ - Shrinking: Stack has `min-width: 0`, so inside a Row or Grid it can shrink below its content's width, and `truncate` text inside it works.
99
+ - Motion: none.
100
+
101
+ ## 12. API
102
+
103
+ <!-- api:start -->
104
+ | Prop | Type | Default | Description |
105
+ | --- | --- | --- | --- |
106
+ | `gap` | `"none" \| "xxs" \| "xs" \| "sm" \| "md" \| "lg" \| "xl" \| "2xl" \| "3xl" \| "4xl"` | `"md"` | Space between children, as a `--spacing-*` step. |
107
+ | `align` | `"start" \| "center" \| "end" \| "stretch" \| "baseline"` | | Cross-axis alignment. Unset, children stretch to the Stack's width. |
108
+ | `justify` | `"start" \| "center" \| "end" \| "between"` | | Main-axis distribution. |
109
+ | `pad` | `"none" \| "xxs" \| "xs" \| "sm" \| "md" \| "lg" \| "xl" \| "2xl" \| "3xl" \| "4xl"` | | Padding on every side. `padX` / `padY` override it per axis. |
110
+ | `padX` | `"none" \| "xxs" \| "xs" \| "sm" \| "md" \| "lg" \| "xl" \| "2xl" \| "3xl" \| "4xl"` | | Inline padding (left and right in LTR). |
111
+ | `padY` | `"none" \| "xxs" \| "xs" \| "sm" \| "md" \| "lg" \| "xl" \| "2xl" \| "3xl" \| "4xl"` | | Block padding (top and bottom). |
112
+ | `grow` | `boolean` | | Take the remaining space in a flex parent: `flex: 1 1 0` with `min-width: 0`. |
113
+ | `shrink` | `boolean` | | `false` keeps the element at its content size in a flex parent (`flex-shrink: 0`). |
114
+ | `height` | `"full" \| "screen"` | | `full` fills the parent's height; `screen` fills the viewport (`100dvh`, so mobile browser bars don't cover the bottom). |
115
+ | `minHeight` | `"full" \| "screen"` | | At least the parent's height (`full`) or the viewport's (`screen`). |
116
+ | `position` | `"relative" \| "absolute"` | | `relative` makes this the anchor for `inset` children; `absolute` takes it out of flow. |
117
+ | `inset` | `"fill" \| "top" \| "bottom"` | | Pin to the nearest positioned ancestor: `fill` covers it, `top` and `bottom` run along that edge at full width. Sets `position: absolute`. |
118
+ | `overflow` | `"hidden" \| "auto"` | | `hidden` clips the content; `auto` scrolls it when it doesn't fit. |
119
+ | `as` | `"div" \| "span" \| "section" \| "article" \| "aside" \| "header" \| "footer" \| "main" \| "nav" \| "form" \| "fieldset" \| "label" \| "p" \| "ul" \| "ol" \| "li" \| "dl" \| "dt" \| "dd"` | | Element override. Defaults to `div`. |
120
+ | `asChild` | `boolean` | `false` | Render the child element instead (Radix Slot); the layout styles move onto it. |
121
+ | `...props` | `HTMLAttributes<HTMLElement>` without `className`, `style` | | Native attributes: `id`, `role`, `aria-*`, `data-*`, event handlers. |
122
+ <!-- api:end -->
123
+
124
+ ## 13. Examples
125
+
126
+ ```tsx
127
+ import { Button, Input, Stack, Typography } from "@eluan/core";
128
+
129
+ export function InviteForm() {
130
+ return (
131
+ <Stack as="section" gap="2xl" pad="xl" aria-labelledby="invite-heading">
132
+ <Stack gap="xs">
133
+ <Typography variant="heading" as="h2" id="invite-heading">
134
+ Invite a teammate
135
+ </Typography>
136
+ <Typography tone="muted">They get an email with a sign-up link.</Typography>
137
+ </Stack>
138
+
139
+ <Stack as="form" gap="lg" onSubmit={(event) => event.preventDefault()}>
140
+ <Input type="email" placeholder="name@company.com" aria-label="Email" />
141
+ <Button type="submit">Send invite</Button>
142
+ </Stack>
143
+ </Stack>
144
+ );
145
+ }
146
+ ```
147
+
148
+ ## 14. Related components
149
+
150
+ - [Row](./row.md): the horizontal counterpart, centred by default.
151
+ - [Grid](./grid.md): columns, including responsive ones.
152
+ - [Box](./box.md): padding, `grow`, height, position and overflow without flow.
153
+ - [Fieldset](./fieldset.md): a labelled group of form fields.
154
+ - [Card](./card.md): a framed surface; Stacks go inside its content.
155
+
156
+ ## 15. Common agent mistakes
157
+
158
+ _Filled from evals._
@@ -0,0 +1,236 @@
1
+ ---
2
+ name: Stepper
3
+ use_when: Showing where the user is in a fixed sequence of steps, such as a checkout or an onboarding wizard.
4
+ instead_of: Tabs for switching between independent views; Progress for a percentage; Breadcrumb for where a page sits in the site.
5
+ source: packages/core/src/components/stepper.tsx
6
+ ---
7
+
8
+ # Stepper
9
+
10
+ ## 1. Overview
11
+
12
+ Stepper shows a numbered sequence of steps, each completed, current or upcoming, joined by connector lines. You pass the steps as an array and the current step as a zero-based index. `StepperContent` renders the panel for the current step. Steps run horizontally (the default) or vertically, and can be clickable.
13
+
14
+ ## 2. When to use
15
+
16
+ - A multi-step form or wizard: checkout, onboarding, a data import.
17
+ - Showing progress through a fixed, ordered sequence where each step depends on the one before.
18
+ - Letting the user go back to a step they've completed, with `onStepClick`.
19
+
20
+ ### When not to use
21
+
22
+ - Switching between independent views of the same thing → use [Tabs](./tabs.md) or [SegmentedControl](./segmented-control.md).
23
+ - Showing a percentage → use [Progress](./progress.md).
24
+ - Showing where a page sits in the site → use [Breadcrumb](./breadcrumb.md).
25
+ - Moving through pages of results → use [Pagination](./pagination.md).
26
+ - The status of an item → use [Badge](./badge.md).
27
+
28
+ ## 3. Anatomy
29
+
30
+ 1. **Root**: the `Stepper` `<div>`; lays the steps out in a row or a column.
31
+ 2. **Indicator**: a circular `<button>` per step, `--size-lg` across. Shows the step number, the step's `icon`, or a check once completed.
32
+ 3. **Title**: `step.title`, under the indicator (horizontal) or beside it (vertical).
33
+ 4. **Description** (optional): `step.description`, in smaller muted text under the title.
34
+ 5. **Connector**: the line between two steps. It darkens once the step before it is complete.
35
+ 6. **StepperContent**: a separate component that renders its children only while its `step` equals `currentStep`.
36
+
37
+ ## 4. Variants
38
+
39
+ Stepper has no `variant` prop. `orientation` sets the layout:
40
+
41
+ | Orientation | Use for |
42
+ | --- | --- |
43
+ | `horizontal` | Default. A wizard header above the form, with short titles. |
44
+ | `vertical` | Sidebars and narrow layouts, or steps with longer descriptions. |
45
+
46
+ ## 5. Sizes
47
+
48
+ Stepper has no size prop. The indicator is `--size-lg`, titles are `--font-size-sm` and descriptions `--font-size-xs`; all of them follow density.
49
+
50
+ ## 6. States
51
+
52
+ Each step is in one of these states, set by its index against `currentStep`:
53
+
54
+ | State | Looks like | Notes |
55
+ | --- | --- | --- |
56
+ | Upcoming | Unfilled circle with a pale border, muted number and title | |
57
+ | Current | Unfilled circle with a dark border, full-strength number and title | `aria-current="step"`. |
58
+ | Completed | Filled dark circle with a check, dark title | The connector after it turns dark. |
59
+ | Hover | Clickable steps only: completed switches to `--action-primary-bg-hover`, current fills with `--interactive-bg-hover`, upcoming gets a dark border | |
60
+ | Focus | 1px ring in `--focus-ring` around the circle, edged with `--container-bg`, drawn with `box-shadow` | Never remove or restyle the focus ring. |
61
+ | Disabled | No hover, default cursor | Steps that aren't clickable are disabled buttons: every step when there's no `onStepClick`. |
62
+
63
+ Connectors are `--spacing-xxs` halved, which is 0 in compact density, so in compact the steps show as unconnected circles. Don't draw your own connectors; it's a source bug.
64
+
65
+ ## 7. Content guidelines
66
+
67
+ - Title each step with one or two words for its task: "Shipping", "Payment", "Review".
68
+ - Keep titles parallel: all nouns, or all verbs.
69
+ - Use a description only when the title needs help: "Where should we send it?"
70
+ - Make the last step the check before committing: "Review" or "Confirm".
71
+ - Use sentence case.
72
+
73
+ | Do | Don't |
74
+ | --- | --- |
75
+ | Shipping | Step 1 |
76
+ | Payment | Enter your payment details below |
77
+ | Review | Done! |
78
+
79
+ ## 8. Rules
80
+
81
+ 1. `currentStep` is a zero-based index. Set it to `steps.length` to show every step completed.
82
+ 2. Give every step a unique, stable `id`; it's the React key.
83
+ 3. To let users go back but not skip ahead, pass `onStepClick` with `allowClickOnCompleted={false}`. With the default `true`, every step, upcoming ones included, is clickable as soon as `onStepClick` is set.
84
+ 4. Leave `onStepClick` off for a display-only stepper. Every indicator is then a disabled button.
85
+ 5. Check the current step is valid before you advance. Stepper doesn't validate; your Continue button and `onStepClick` decide whether `currentStep` changes.
86
+ 6. Render one `StepperContent` per step with the same `currentStep`, and put Back and Continue [Buttons](./button.md) in your own footer.
87
+ 7. Keep form state above `StepperContent`. It unmounts every step except the current one, so state held inside a step is lost when the user moves on.
88
+ 8. Never pass `className` or `style`; they're dropped. Put width on a wrapper.
89
+
90
+ ## 9. Dos and don'ts
91
+
92
+ **Do:** allow going back to completed steps only.
93
+
94
+ ```tsx
95
+ <Stepper
96
+ steps={checkoutSteps}
97
+ currentStep={current}
98
+ onStepClick={setCurrent}
99
+ allowClickOnCompleted={false}
100
+ />
101
+ ```
102
+
103
+ **Don't:** let users jump ahead past steps they haven't finished.
104
+
105
+ ```tsx
106
+ <Stepper steps={checkoutSteps} currentStep={current} onStepClick={setCurrent} />
107
+ ```
108
+
109
+ **Do:** keep the wizard's data above the steps.
110
+
111
+ ```tsx
112
+ const [address, setAddress] = useState<Address | null>(null);
113
+
114
+ <StepperContent step={0} currentStep={current}>
115
+ <ShippingForm value={address} onChange={setAddress} />
116
+ </StepperContent>
117
+ ```
118
+
119
+ **Don't:** keep step data inside the step; it's lost when the step unmounts.
120
+
121
+ ```tsx
122
+ <StepperContent step={0} currentStep={current}>
123
+ <ShippingFormWithOwnState />
124
+ </StepperContent>
125
+ ```
126
+
127
+ ## 10. Accessibility
128
+
129
+ - Role: the root is a plain `<div>` with no list or group semantics. Each indicator is a native `<button>`; the current one has `aria-current="step"`.
130
+ - Label: each indicator is named from its title, plus "(completed)" or "(current step)"; upcoming steps get the title alone. Descriptions aren't part of the name. Wrap the Stepper in an element you own that names it, for example `<nav aria-label="Checkout steps">` when steps are clickable.
131
+ - Keyboard: Tab moves between clickable indicators; Enter and Space activate them. Disabled indicators are skipped.
132
+ - Focus: Stepper doesn't move focus when `currentStep` changes. After the user advances, move focus to the new step's heading so keyboard and screen reader users land on the new content.
133
+ - Contrast: handled by the theme. Don't override colours.
134
+
135
+ ## 11. Behaviour
136
+
137
+ - Responsive: horizontal steps sit in one row and don't wrap; connectors stretch to fill the space between them, down to `--size-sm`. Switch to `orientation="vertical"` in narrow containers.
138
+ - Overflow and truncation: titles and descriptions wrap; nothing truncates. Keep titles short.
139
+ - Vertical: the connector runs down from the centre of the indicator, at least `--spacing-xl` tall.
140
+ - Motion: indicator and connector colours transition over 150ms. Don't add your own.
141
+
142
+ ## 12. API
143
+
144
+ <!-- api:start -->
145
+ ### Stepper
146
+
147
+ | Prop | Type | Default | Description |
148
+ | --- | --- | --- | --- |
149
+ | `steps` | `Step[]` | required | The steps, in order. |
150
+ | `currentStep` | `number` | required | Zero-based index of the current step. Earlier steps show as completed. |
151
+ | `orientation` | `"horizontal" \| "vertical"` | `"horizontal"` | Layout direction. |
152
+ | `onStepClick` | `(step: number) => void` | | Makes steps clickable; receives the clicked index. |
153
+ | `allowClickOnCompleted` | `boolean` | `true` | With `onStepClick`: `true` makes every step clickable, `false` only completed steps. |
154
+ | `...props` | `HTMLAttributes<HTMLDivElement>` without `className`, `style` | | `id`, `aria-*`. The ref goes to the root `<div>`. |
155
+
156
+ ### Step
157
+
158
+ | Prop | Type | Default | Description |
159
+ | --- | --- | --- | --- |
160
+ | `id` | `string` | required | Unique, stable key. |
161
+ | `title` | `string` | required | Visible title and the indicator's accessible name. |
162
+ | `description` | `string` | | Muted text under the title. |
163
+ | `icon` | `ReactNode` | | Replaces the number in the indicator until the step is completed. |
164
+
165
+ ### StepperContent
166
+
167
+ | Prop | Type | Default | Description |
168
+ | --- | --- | --- | --- |
169
+ | `step` | `number` | required | The step index this panel belongs to. |
170
+ | `currentStep` | `number` | required | The Stepper's current step. The panel renders only when they match. |
171
+ | `...props` | `HTMLAttributes<HTMLDivElement>` without `className`, `style` | | `children`, `id`, `aria-*`. The ref goes to the panel `<div>`. |
172
+ <!-- api:end -->
173
+
174
+ ## 13. Examples
175
+
176
+ ```tsx
177
+ import { useState } from "react";
178
+ import { Button, Stepper, StepperContent, Typography } from "@eluan/core";
179
+
180
+ const checkoutSteps = [
181
+ { id: "shipping", title: "Shipping", description: "Where should we send it?" },
182
+ { id: "payment", title: "Payment" },
183
+ { id: "review", title: "Review" },
184
+ ];
185
+
186
+ export function CheckoutWizard({ onPlaceOrder }: { onPlaceOrder: () => void }) {
187
+ const [current, setCurrent] = useState(0);
188
+ const isLast = current === checkoutSteps.length - 1;
189
+
190
+ return (
191
+ <div style={{ display: "flex", flexDirection: "column", gap: "var(--spacing-xl)", width: "100%" }}>
192
+ <nav aria-label="Checkout steps">
193
+ <Stepper
194
+ steps={checkoutSteps}
195
+ currentStep={current}
196
+ onStepClick={setCurrent}
197
+ allowClickOnCompleted={false}
198
+ />
199
+ </nav>
200
+
201
+ <StepperContent step={0} currentStep={current}>
202
+ <Typography variant="heading">Shipping address</Typography>
203
+ </StepperContent>
204
+ <StepperContent step={1} currentStep={current}>
205
+ <Typography variant="heading">Payment method</Typography>
206
+ </StepperContent>
207
+ <StepperContent step={2} currentStep={current}>
208
+ <Typography variant="heading">Review your order</Typography>
209
+ </StepperContent>
210
+
211
+ <div style={{ display: "flex", justifyContent: "flex-end", gap: "var(--spacing-sm)" }}>
212
+ {current > 0 && (
213
+ <Button type="button" variant="outline" onClick={() => setCurrent(current - 1)}>
214
+ Back
215
+ </Button>
216
+ )}
217
+ <Button type="button" onClick={() => (isLast ? onPlaceOrder() : setCurrent(current + 1))}>
218
+ {isLast ? "Place order" : "Continue"}
219
+ </Button>
220
+ </div>
221
+ </div>
222
+ );
223
+ }
224
+ ```
225
+
226
+ ## 14. Related components
227
+
228
+ - [Tabs](./tabs.md): independent views with no order.
229
+ - [Progress](./progress.md): a percentage instead of named steps.
230
+ - [Button](./button.md): Back and Continue in the wizard footer.
231
+ - [Fieldset](./fieldset.md): group the fields inside each step.
232
+ - See [patterns/forms.md](../patterns/forms.md) for the fields inside each step.
233
+
234
+ ## 15. Common agent mistakes
235
+
236
+ _Filled from evals._
@@ -0,0 +1,218 @@
1
+ ---
2
+ name: Switch
3
+ use_when: Turning a setting on or off where the change takes effect immediately, such as notifications or a feature flag.
4
+ instead_of: Checkbox for choices the user submits with a form; Toggle for a pressed toolbar button; RadioGroup or SegmentedControl for more than two options.
5
+ source: packages/core/src/components/switch.tsx
6
+ ---
7
+
8
+ # Switch
9
+
10
+ ## 1. Overview
11
+
12
+ Switch is an on/off control built on Radix Switch, meant for boolean settings that apply immediately. It renders a `<button role="switch">` with a sliding thumb. It has no label of its own: pair it with a Label.
13
+
14
+ ## 2. When to use
15
+
16
+ - A setting that applies the moment it's flipped: "Marketing emails", "Security emails", "Airplane mode".
17
+ - A list of independent settings, one per row, each with a label and a short description.
18
+
19
+ ### When not to use
20
+
21
+ - A choice the user confirms later with a submit button → use [Checkbox](./checkbox.md).
22
+ - A pressed/unpressed button in a toolbar → use [Toggle](./toggle.md).
23
+ - More than two options → use [RadioGroup](./radio-group.md) or [SegmentedControl](./segmented-control.md).
24
+ - A one-off action → use [Button](./button.md).
25
+
26
+ ## 3. Anatomy
27
+
28
+ 1. **Track**: the `<button role="switch">`. `--size-lg` wide, `--size-xs` tall, fully rounded, with a 2px border in the track colour.
29
+ 2. **Thumb**: a `--size-xxs` tall pill in `--interactive-bg` that slides to the end when on.
30
+ 3. **Hidden input**: inside a `<form>`, Radix adds a hidden native checkbox so `name` and `value` submit with the form.
31
+ 4. **Label** (yours): a Label with `htmlFor` matching the Switch `id`, and an optional description.
32
+
33
+ ## 4. Variants
34
+
35
+ Switch has no variants.
36
+
37
+ ## 5. Sizes
38
+
39
+ Switch has no `size` prop. The track is `--size-lg` by `--size-xs` and follows density.
40
+
41
+ ## 6. States
42
+
43
+ | State | Looks like | Notes |
44
+ | --- | --- | --- |
45
+ | Off | Track and border in `--interactive-border-alt`, thumb at the start | |
46
+ | On | Track and border in `--interactive-bg-selected`, thumb at the end | |
47
+ | Focus | 1px outline in `--focus-ring`, 1px offset | Never remove or restyle the focus ring. |
48
+ | Disabled | Track fill switches to `--interactive-bg-disabled`, not-allowed cursor; the thumb stays on its side | Disable its Label too. |
49
+ | Loading | No built-in loading state | While a save is in flight, keep the new position, set `aria-busy` and `aria-disabled`, and ignore further toggles until it settles. Don't set `disabled`: it drops keyboard focus from the switch the user just pressed. Revert if the save fails. |
50
+
51
+ There's no hover style.
52
+
53
+ ## 7. Content guidelines
54
+
55
+ - Label the setting, not the action: "Marketing emails", not "Turn on marketing emails".
56
+ - Don't add "On" or "Off" text beside the switch; the thumb position shows the state.
57
+ - Use a description for one sentence on the effect: "Receive emails about new products."
58
+
59
+ | Do | Don't |
60
+ | --- | --- |
61
+ | Marketing emails | Enable marketing emails? |
62
+ | Receive emails about account activity. | When this is on, we will send you emails about account activity. |
63
+ | Two-factor authentication | 2FA ON |
64
+
65
+ ## 8. Rules
66
+
67
+ 1. Pair every Switch with a Label whose `htmlFor` matches its `id`, or give it `aria-label`.
68
+ 2. Apply the change in `onCheckedChange` straight away. Don't wait for a submit button; if the change needs confirming, use a Checkbox in the form instead.
69
+ 3. `onCheckedChange` receives a `boolean`. Switch has no `onChange` or `onValueChange`.
70
+ 4. Control it with `checked` and `onCheckedChange` together, or leave it uncontrolled with `defaultChecked`.
71
+ 5. In a settings list, put the label and description first and the Switch at the end of the row. For a single compact toggle, the Switch can come first with the Label after it.
72
+ 6. Never pass `className` or `style`; they're dropped.
73
+
74
+ ## 9. Dos and don'ts
75
+
76
+ **Do:** label the setting and save on change.
77
+
78
+ ```tsx
79
+ <div style={{ display: "flex", alignItems: "center", justifyContent: "space-between", gap: "var(--spacing-lg)" }}>
80
+ <Label htmlFor="marketing-emails">Marketing emails</Label>
81
+ <Switch id="marketing-emails" checked={marketing} onCheckedChange={saveMarketing} />
82
+ </div>
83
+ ```
84
+
85
+ **Don't:** use a Switch that only takes effect after a Save button.
86
+
87
+ ```tsx
88
+ <form onSubmit={save}>
89
+ <Switch id="marketing-emails" name="marketing" />
90
+ <Label htmlFor="marketing-emails">Marketing emails</Label>
91
+ <Button type="submit">Save</Button>
92
+ </form>
93
+ ```
94
+
95
+ **Do:** let the thumb show the state.
96
+
97
+ ```tsx
98
+ <Switch id="two-factor" checked={enabled} onCheckedChange={setEnabled} />
99
+ <Label htmlFor="two-factor">Two-factor authentication</Label>
100
+ ```
101
+
102
+ **Don't:** add state text or an unlabelled switch.
103
+
104
+ ```tsx
105
+ <Switch checked={enabled} onCheckedChange={setEnabled} />
106
+ <span>{enabled ? "ON" : "OFF"}</span>
107
+ ```
108
+
109
+ ## 10. Accessibility
110
+
111
+ - Role: `switch` (Radix renders a `<button>`), with `aria-checked`.
112
+ - Label: a Label with `htmlFor` matching the Switch `id`, or `aria-label`. Link a description with `aria-describedby`.
113
+ - Keyboard: Space and Enter toggle (native button behaviour). Tab moves between switches.
114
+ - Focus: visible outline on `:focus-visible`. Disabled switches use the native `disabled` attribute and are skipped by Tab.
115
+ - Contrast: handled by the theme. Don't override colours.
116
+
117
+ ## 11. Behaviour
118
+
119
+ - Responsive: fixed size; it doesn't shrink beside long labels. In settings rows, spread the label and switch with `justifyContent: "space-between"` and a `--spacing-lg` gap, as the settings story does.
120
+ - Motion: the thumb slides and the track changes colour over 150ms. Don't add your own.
121
+ - Forms: inside a `<form>`, a hidden input submits `value` (default `"on"`) under `name` when on.
122
+
123
+ ## 12. API
124
+
125
+ <!-- api:start -->
126
+ | Prop | Type | Default | Description |
127
+ | --- | --- | --- | --- |
128
+ | `checked` | `boolean` | | Controlled state. Pair with `onCheckedChange`. |
129
+ | `defaultChecked` | `boolean` | | Uncontrolled starting state. |
130
+ | `onCheckedChange` | `(checked: boolean) => void` | | Called when the user flips it. |
131
+ | `disabled` | `boolean` | `false` | Prevents interaction. |
132
+ | `required` | `boolean` | `false` | Marks it required for form validation. |
133
+ | `name` | `string` | | Field name for form submission. |
134
+ | `value` | `string` | `"on"` | Value submitted when on. |
135
+ | `id` | `string` | | Match it with the Label's `htmlFor`. |
136
+ | `...props` | Radix `Switch.Root` props without `className`, `style` | | Button attributes and `aria-*`. `ref` goes to the `<button>`. |
137
+ <!-- api:end -->
138
+
139
+ ## 13. Examples
140
+
141
+ ```tsx
142
+ import { Label, Switch, Typography } from "@eluan/core";
143
+ import * as React from "react";
144
+
145
+ type Setting = { id: string; label: string; description: string };
146
+
147
+ const settings: Setting[] = [
148
+ { id: "marketing-emails", label: "Marketing emails", description: "Receive emails about new products." },
149
+ { id: "security-emails", label: "Security emails", description: "Receive emails about account activity." },
150
+ ];
151
+
152
+ const row = {
153
+ display: "flex",
154
+ alignItems: "center",
155
+ justifyContent: "space-between",
156
+ gap: "var(--spacing-lg)",
157
+ } as const;
158
+ const copy = { display: "flex", flexDirection: "column", gap: "var(--spacing-xxs)" } as const;
159
+
160
+ export function EmailSettings({
161
+ initial,
162
+ onSave,
163
+ }: {
164
+ initial: Record<string, boolean>;
165
+ onSave: (id: string, enabled: boolean) => Promise<void>;
166
+ }) {
167
+ const [values, setValues] = React.useState(initial);
168
+ const [saving, setSaving] = React.useState<string | null>(null);
169
+
170
+ async function handleChange(id: string, enabled: boolean) {
171
+ if (saving === id) return;
172
+ setValues((current) => ({ ...current, [id]: enabled }));
173
+ setSaving(id);
174
+ try {
175
+ await onSave(id, enabled);
176
+ } catch {
177
+ setValues((current) => ({ ...current, [id]: !enabled }));
178
+ } finally {
179
+ setSaving(null);
180
+ }
181
+ }
182
+
183
+ return (
184
+ <div style={{ display: "flex", flexDirection: "column", gap: "var(--spacing-lg)" }}>
185
+ {settings.map((setting) => (
186
+ <div key={setting.id} style={row}>
187
+ <div style={copy}>
188
+ <Label htmlFor={setting.id}>{setting.label}</Label>
189
+ <Typography id={`${setting.id}-description`} variant="caption" tone="muted">
190
+ {setting.description}
191
+ </Typography>
192
+ </div>
193
+ <Switch
194
+ id={setting.id}
195
+ checked={values[setting.id] ?? false}
196
+ onCheckedChange={(enabled) => handleChange(setting.id, enabled)}
197
+ aria-busy={saving === setting.id || undefined}
198
+ aria-disabled={saving === setting.id || undefined}
199
+ aria-describedby={`${setting.id}-description`}
200
+ />
201
+ </div>
202
+ ))}
203
+ </div>
204
+ );
205
+ }
206
+ ```
207
+
208
+ ## 14. Related components
209
+
210
+ - [Checkbox](./checkbox.md): an on/off choice submitted with a form.
211
+ - [Toggle](./toggle.md): a button that stays pressed.
212
+ - [Label](./form-label.md): the Label beside each switch.
213
+ - [Toast](./toast.md): tells the user a setting failed to save.
214
+ - See [../patterns/forms.md](../patterns/forms.md) for when to use Switch or Checkbox.
215
+
216
+ ## 15. Common agent mistakes
217
+
218
+ - Setting `disabled` on a switch while its change saves. Focus leaves the switch the user just toggled, so a keyboard user loses their place. Set `aria-busy` and `aria-disabled` and ignore toggles until the save settles.