@funstack/ui 0.1.0-alpha.15 → 0.1.0-alpha.16

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 (558) hide show
  1. package/README.md +22 -1
  2. package/dist/accordion/accordion-item.d.mts +19 -0
  3. package/dist/accordion/accordion-item.d.mts.map +1 -1
  4. package/dist/accordion/accordion-item.mjs +2 -0
  5. package/dist/accordion/accordion-item.mjs.map +1 -1
  6. package/dist/accordion/accordion-panel.d.mts +16 -0
  7. package/dist/accordion/accordion-panel.d.mts.map +1 -1
  8. package/dist/accordion/accordion-panel.mjs +2 -0
  9. package/dist/accordion/accordion-panel.mjs.map +1 -1
  10. package/dist/accordion/accordion-root.d.mts +36 -2
  11. package/dist/accordion/accordion-root.d.mts.map +1 -1
  12. package/dist/accordion/accordion-root.mjs +2 -0
  13. package/dist/accordion/accordion-root.mjs.map +1 -1
  14. package/dist/accordion/accordion-trigger.d.mts +9 -0
  15. package/dist/accordion/accordion-trigger.d.mts.map +1 -1
  16. package/dist/accordion/accordion-trigger.mjs +2 -0
  17. package/dist/accordion/accordion-trigger.mjs.map +1 -1
  18. package/dist/accordion/index.d.mts +2 -0
  19. package/dist/accordion/index.d.mts.map +1 -1
  20. package/dist/accordion/index.mjs +2 -0
  21. package/dist/accordion/index.mjs.map +1 -1
  22. package/dist/bin/skill-installer.d.mts +1 -0
  23. package/dist/bin/skill-installer.mjs +12 -0
  24. package/dist/bin/skill-installer.mjs.map +1 -0
  25. package/dist/button/button.d.mts +25 -7
  26. package/dist/button/button.d.mts.map +1 -1
  27. package/dist/button/button.mjs +2 -0
  28. package/dist/button/button.mjs.map +1 -1
  29. package/dist/checkbox/checkbox.d.mts +25 -3
  30. package/dist/checkbox/checkbox.d.mts.map +1 -1
  31. package/dist/checkbox/checkbox.mjs +2 -0
  32. package/dist/checkbox/checkbox.mjs.map +1 -1
  33. package/dist/checkbox-group/checkbox-group-item.d.mts +15 -0
  34. package/dist/checkbox-group/checkbox-group-item.d.mts.map +1 -1
  35. package/dist/checkbox-group/checkbox-group-item.mjs +2 -0
  36. package/dist/checkbox-group/checkbox-group-item.mjs.map +1 -1
  37. package/dist/checkbox-group/checkbox-group-label.d.mts +10 -0
  38. package/dist/checkbox-group/checkbox-group-label.d.mts.map +1 -1
  39. package/dist/checkbox-group/checkbox-group-label.mjs +2 -0
  40. package/dist/checkbox-group/checkbox-group-label.mjs.map +1 -1
  41. package/dist/checkbox-group/checkbox-group-parent.d.mts +19 -1
  42. package/dist/checkbox-group/checkbox-group-parent.d.mts.map +1 -1
  43. package/dist/checkbox-group/checkbox-group-parent.mjs +2 -0
  44. package/dist/checkbox-group/checkbox-group-parent.mjs.map +1 -1
  45. package/dist/checkbox-group/checkbox-group-root.d.mts +31 -4
  46. package/dist/checkbox-group/checkbox-group-root.d.mts.map +1 -1
  47. package/dist/checkbox-group/checkbox-group-root.mjs +2 -0
  48. package/dist/checkbox-group/checkbox-group-root.mjs.map +1 -1
  49. package/dist/checkbox-group/index.d.mts +2 -0
  50. package/dist/checkbox-group/index.d.mts.map +1 -1
  51. package/dist/checkbox-group/index.mjs +2 -0
  52. package/dist/checkbox-group/index.mjs.map +1 -1
  53. package/dist/combobox/combobox-clear.d.mts +18 -0
  54. package/dist/combobox/combobox-clear.d.mts.map +1 -1
  55. package/dist/combobox/combobox-clear.mjs +2 -0
  56. package/dist/combobox/combobox-clear.mjs.map +1 -1
  57. package/dist/combobox/combobox-group.d.mts +49 -1
  58. package/dist/combobox/combobox-group.d.mts.map +1 -1
  59. package/dist/combobox/combobox-group.mjs +11 -1
  60. package/dist/combobox/combobox-group.mjs.map +1 -1
  61. package/dist/combobox/combobox-input.d.mts +11 -0
  62. package/dist/combobox/combobox-input.d.mts.map +1 -1
  63. package/dist/combobox/combobox-input.mjs +2 -0
  64. package/dist/combobox/combobox-input.mjs.map +1 -1
  65. package/dist/combobox/combobox-label.d.mts +16 -0
  66. package/dist/combobox/combobox-label.d.mts.map +1 -1
  67. package/dist/combobox/combobox-label.mjs +2 -0
  68. package/dist/combobox/combobox-label.mjs.map +1 -1
  69. package/dist/combobox/combobox-list.d.mts +14 -0
  70. package/dist/combobox/combobox-list.d.mts.map +1 -1
  71. package/dist/combobox/combobox-list.mjs +2 -0
  72. package/dist/combobox/combobox-list.mjs.map +1 -1
  73. package/dist/combobox/combobox-option.d.mts +25 -3
  74. package/dist/combobox/combobox-option.d.mts.map +1 -1
  75. package/dist/combobox/combobox-option.mjs +2 -0
  76. package/dist/combobox/combobox-option.mjs.map +1 -1
  77. package/dist/combobox/combobox-popup.d.mts +16 -0
  78. package/dist/combobox/combobox-popup.d.mts.map +1 -1
  79. package/dist/combobox/combobox-popup.mjs +2 -0
  80. package/dist/combobox/combobox-popup.mjs.map +1 -1
  81. package/dist/combobox/combobox-root.d.mts +49 -12
  82. package/dist/combobox/combobox-root.d.mts.map +1 -1
  83. package/dist/combobox/combobox-root.mjs +2 -0
  84. package/dist/combobox/combobox-root.mjs.map +1 -1
  85. package/dist/combobox/combobox-trigger.d.mts +16 -0
  86. package/dist/combobox/combobox-trigger.d.mts.map +1 -1
  87. package/dist/combobox/combobox-trigger.mjs +2 -0
  88. package/dist/combobox/combobox-trigger.mjs.map +1 -1
  89. package/dist/combobox/index.d.mts +2 -0
  90. package/dist/combobox/index.d.mts.map +1 -1
  91. package/dist/combobox/index.mjs +2 -0
  92. package/dist/combobox/index.mjs.map +1 -1
  93. package/dist/csp/csp-provider.d.mts +8 -0
  94. package/dist/csp/csp-provider.d.mts.map +1 -1
  95. package/dist/csp/csp-provider.mjs +2 -0
  96. package/dist/csp/csp-provider.mjs.map +1 -1
  97. package/dist/csp/style-hashes.d.mts +2 -0
  98. package/dist/csp/style-hashes.d.mts.map +1 -1
  99. package/dist/csp/style-hashes.mjs +2 -0
  100. package/dist/csp/style-hashes.mjs.map +1 -1
  101. package/dist/dialog/dialog-close.d.mts +18 -0
  102. package/dist/dialog/dialog-close.d.mts.map +1 -1
  103. package/dist/dialog/dialog-close.mjs +2 -0
  104. package/dist/dialog/dialog-close.mjs.map +1 -1
  105. package/dist/dialog/dialog-description.d.mts +12 -0
  106. package/dist/dialog/dialog-description.d.mts.map +1 -1
  107. package/dist/dialog/dialog-description.mjs +2 -0
  108. package/dist/dialog/dialog-description.mjs.map +1 -1
  109. package/dist/dialog/dialog-form.d.mts +18 -1
  110. package/dist/dialog/dialog-form.d.mts.map +1 -1
  111. package/dist/dialog/dialog-form.mjs +2 -0
  112. package/dist/dialog/dialog-form.mjs.map +1 -1
  113. package/dist/dialog/dialog-popup.d.mts +25 -4
  114. package/dist/dialog/dialog-popup.d.mts.map +1 -1
  115. package/dist/dialog/dialog-popup.mjs +2 -0
  116. package/dist/dialog/dialog-popup.mjs.map +1 -1
  117. package/dist/dialog/dialog-root.d.mts +15 -1
  118. package/dist/dialog/dialog-root.d.mts.map +1 -1
  119. package/dist/dialog/dialog-root.mjs +2 -0
  120. package/dist/dialog/dialog-root.mjs.map +1 -1
  121. package/dist/dialog/dialog-title.d.mts +11 -0
  122. package/dist/dialog/dialog-title.d.mts.map +1 -1
  123. package/dist/dialog/dialog-title.mjs +2 -0
  124. package/dist/dialog/dialog-title.mjs.map +1 -1
  125. package/dist/dialog/dialog-trigger.d.mts +16 -0
  126. package/dist/dialog/dialog-trigger.d.mts.map +1 -1
  127. package/dist/dialog/dialog-trigger.mjs +2 -0
  128. package/dist/dialog/dialog-trigger.mjs.map +1 -1
  129. package/dist/dialog/index.d.mts +2 -0
  130. package/dist/dialog/index.d.mts.map +1 -1
  131. package/dist/dialog/index.mjs +2 -0
  132. package/dist/dialog/index.mjs.map +1 -1
  133. package/dist/docs/components/accordion.md +426 -0
  134. package/dist/docs/components/button.md +464 -0
  135. package/dist/docs/components/checkbox-group.md +474 -0
  136. package/dist/docs/components/checkbox.md +373 -0
  137. package/dist/docs/components/combobox.md +635 -0
  138. package/dist/docs/components/context-menu.md +524 -0
  139. package/dist/docs/components/dialog.md +686 -0
  140. package/dist/docs/components/field.md +587 -0
  141. package/dist/docs/components/menu.md +589 -0
  142. package/dist/docs/components/meter.md +313 -0
  143. package/dist/docs/components/number-field.md +528 -0
  144. package/dist/docs/components/popover.md +591 -0
  145. package/dist/docs/components/progress.md +450 -0
  146. package/dist/docs/components/radio-group.md +457 -0
  147. package/dist/docs/components/select.md +662 -0
  148. package/dist/docs/components/slider.md +558 -0
  149. package/dist/docs/components/switch.md +311 -0
  150. package/dist/docs/components/tabs.md +473 -0
  151. package/dist/docs/components/toast.md +576 -0
  152. package/dist/docs/components/toggle-group.md +341 -0
  153. package/dist/docs/components/toggle.md +245 -0
  154. package/dist/docs/components/toolbar.md +389 -0
  155. package/dist/docs/components/tooltip.md +494 -0
  156. package/dist/docs/concepts/action-props.md +251 -0
  157. package/dist/docs/concepts/ai-agents.md +56 -0
  158. package/dist/docs/concepts/browser-owned-state.md +118 -0
  159. package/dist/docs/concepts/content-security-policy.md +69 -0
  160. package/dist/docs/concepts/experimental.md +36 -0
  161. package/dist/docs/concepts/pending-and-optimistic.md +250 -0
  162. package/dist/docs/concepts/server-components.md +118 -0
  163. package/dist/docs/concepts/suspense.md +124 -0
  164. package/dist/docs/concepts/transitions.md +118 -0
  165. package/dist/docs/getting-started.md +115 -0
  166. package/dist/docs/index.md +181 -0
  167. package/dist/docs/roadmap.md +74 -0
  168. package/dist/docs/why.md +100 -0
  169. package/dist/field/field-control.d.mts +26 -3
  170. package/dist/field/field-control.d.mts.map +1 -1
  171. package/dist/field/field-control.mjs +2 -0
  172. package/dist/field/field-control.mjs.map +1 -1
  173. package/dist/field/field-description.d.mts +11 -0
  174. package/dist/field/field-description.d.mts.map +1 -1
  175. package/dist/field/field-description.mjs +2 -0
  176. package/dist/field/field-description.mjs.map +1 -1
  177. package/dist/field/field-error.d.mts +14 -2
  178. package/dist/field/field-error.d.mts.map +1 -1
  179. package/dist/field/field-error.mjs +2 -0
  180. package/dist/field/field-error.mjs.map +1 -1
  181. package/dist/field/field-label.d.mts +10 -0
  182. package/dist/field/field-label.d.mts.map +1 -1
  183. package/dist/field/field-label.mjs +2 -0
  184. package/dist/field/field-label.mjs.map +1 -1
  185. package/dist/field/field-root.d.mts +21 -2
  186. package/dist/field/field-root.d.mts.map +1 -1
  187. package/dist/field/field-root.mjs +2 -0
  188. package/dist/field/field-root.mjs.map +1 -1
  189. package/dist/field/index.d.mts +9 -0
  190. package/dist/field/index.d.mts.map +1 -1
  191. package/dist/field/index.mjs +9 -0
  192. package/dist/field/index.mjs.map +1 -1
  193. package/dist/form/form-root.d.mts +17 -1
  194. package/dist/form/form-root.d.mts.map +1 -1
  195. package/dist/form/form-root.mjs +2 -0
  196. package/dist/form/form-root.mjs.map +1 -1
  197. package/dist/form/form-submit.d.mts +18 -0
  198. package/dist/form/form-submit.d.mts.map +1 -1
  199. package/dist/form/form-submit.mjs +2 -0
  200. package/dist/form/form-submit.mjs.map +1 -1
  201. package/dist/form/index.d.mts +7 -0
  202. package/dist/form/index.d.mts.map +1 -1
  203. package/dist/form/index.mjs +7 -0
  204. package/dist/form/index.mjs.map +1 -1
  205. package/dist/index.d.mts +2 -1
  206. package/dist/internal/types.d.mts +3 -0
  207. package/dist/internal/types.d.mts.map +1 -1
  208. package/dist/internal/use-popover-trigger.d.mts +1 -0
  209. package/dist/internal/use-popover-trigger.d.mts.map +1 -1
  210. package/dist/internal/use-popover-trigger.mjs.map +1 -1
  211. package/dist/internal/validity.d.mts +11 -0
  212. package/dist/internal/validity.d.mts.map +1 -1
  213. package/dist/internal/validity.mjs.map +1 -1
  214. package/dist/menu/index.d.mts +2 -0
  215. package/dist/menu/index.d.mts.map +1 -1
  216. package/dist/menu/index.mjs +2 -0
  217. package/dist/menu/index.mjs.map +1 -1
  218. package/dist/menu/menu-checkbox-item.d.mts +26 -2
  219. package/dist/menu/menu-checkbox-item.d.mts.map +1 -1
  220. package/dist/menu/menu-checkbox-item.mjs +2 -0
  221. package/dist/menu/menu-checkbox-item.mjs.map +1 -1
  222. package/dist/menu/menu-context-trigger.d.mts +24 -2
  223. package/dist/menu/menu-context-trigger.d.mts.map +1 -1
  224. package/dist/menu/menu-context-trigger.mjs +2 -0
  225. package/dist/menu/menu-context-trigger.mjs.map +1 -1
  226. package/dist/menu/menu-group.d.mts +36 -1
  227. package/dist/menu/menu-group.d.mts.map +1 -1
  228. package/dist/menu/menu-group.mjs +9 -1
  229. package/dist/menu/menu-group.mjs.map +1 -1
  230. package/dist/menu/menu-item.d.mts +23 -1
  231. package/dist/menu/menu-item.d.mts.map +1 -1
  232. package/dist/menu/menu-item.mjs +2 -0
  233. package/dist/menu/menu-item.mjs.map +1 -1
  234. package/dist/menu/menu-popup.d.mts +33 -8
  235. package/dist/menu/menu-popup.d.mts.map +1 -1
  236. package/dist/menu/menu-popup.mjs +2 -0
  237. package/dist/menu/menu-popup.mjs.map +1 -1
  238. package/dist/menu/menu-radio-group.d.mts +20 -1
  239. package/dist/menu/menu-radio-group.d.mts.map +1 -1
  240. package/dist/menu/menu-radio-group.mjs +2 -0
  241. package/dist/menu/menu-radio-group.mjs.map +1 -1
  242. package/dist/menu/menu-radio-item.d.mts +16 -0
  243. package/dist/menu/menu-radio-item.d.mts.map +1 -1
  244. package/dist/menu/menu-radio-item.mjs +2 -0
  245. package/dist/menu/menu-radio-item.mjs.map +1 -1
  246. package/dist/menu/menu-root.d.mts +22 -3
  247. package/dist/menu/menu-root.d.mts.map +1 -1
  248. package/dist/menu/menu-root.mjs +2 -0
  249. package/dist/menu/menu-root.mjs.map +1 -1
  250. package/dist/menu/menu-submenu-trigger.d.mts +13 -0
  251. package/dist/menu/menu-submenu-trigger.d.mts.map +1 -1
  252. package/dist/menu/menu-submenu-trigger.mjs +2 -0
  253. package/dist/menu/menu-submenu-trigger.mjs.map +1 -1
  254. package/dist/menu/menu-trigger.d.mts +15 -0
  255. package/dist/menu/menu-trigger.d.mts.map +1 -1
  256. package/dist/menu/menu-trigger.mjs +2 -0
  257. package/dist/menu/menu-trigger.mjs.map +1 -1
  258. package/dist/meter/index.d.mts +2 -0
  259. package/dist/meter/index.d.mts.map +1 -1
  260. package/dist/meter/index.mjs +2 -0
  261. package/dist/meter/index.mjs.map +1 -1
  262. package/dist/meter/meter-indicator.d.mts +11 -0
  263. package/dist/meter/meter-indicator.d.mts.map +1 -1
  264. package/dist/meter/meter-indicator.mjs +2 -0
  265. package/dist/meter/meter-indicator.mjs.map +1 -1
  266. package/dist/meter/meter-label.d.mts +11 -0
  267. package/dist/meter/meter-label.d.mts.map +1 -1
  268. package/dist/meter/meter-label.mjs +2 -0
  269. package/dist/meter/meter-label.mjs.map +1 -1
  270. package/dist/meter/meter-region.d.mts +5 -0
  271. package/dist/meter/meter-region.d.mts.map +1 -1
  272. package/dist/meter/meter-region.mjs.map +1 -1
  273. package/dist/meter/meter-root.d.mts +52 -10
  274. package/dist/meter/meter-root.d.mts.map +1 -1
  275. package/dist/meter/meter-root.mjs +2 -0
  276. package/dist/meter/meter-root.mjs.map +1 -1
  277. package/dist/meter/meter-track.d.mts +11 -0
  278. package/dist/meter/meter-track.d.mts.map +1 -1
  279. package/dist/meter/meter-track.mjs +2 -0
  280. package/dist/meter/meter-track.mjs.map +1 -1
  281. package/dist/meter/meter-value.d.mts +15 -1
  282. package/dist/meter/meter-value.d.mts.map +1 -1
  283. package/dist/meter/meter-value.mjs +2 -0
  284. package/dist/meter/meter-value.mjs.map +1 -1
  285. package/dist/number-field/index.d.mts +2 -0
  286. package/dist/number-field/index.d.mts.map +1 -1
  287. package/dist/number-field/index.mjs +2 -0
  288. package/dist/number-field/index.mjs.map +1 -1
  289. package/dist/number-field/number-field-decrement.d.mts +2 -0
  290. package/dist/number-field/number-field-decrement.d.mts.map +1 -1
  291. package/dist/number-field/number-field-decrement.mjs +2 -0
  292. package/dist/number-field/number-field-decrement.mjs.map +1 -1
  293. package/dist/number-field/number-field-increment.d.mts +2 -0
  294. package/dist/number-field/number-field-increment.d.mts.map +1 -1
  295. package/dist/number-field/number-field-increment.mjs +2 -0
  296. package/dist/number-field/number-field-increment.mjs.map +1 -1
  297. package/dist/number-field/number-field-input.d.mts +9 -0
  298. package/dist/number-field/number-field-input.d.mts.map +1 -1
  299. package/dist/number-field/number-field-input.mjs +2 -0
  300. package/dist/number-field/number-field-input.mjs.map +1 -1
  301. package/dist/number-field/number-field-label.d.mts +10 -0
  302. package/dist/number-field/number-field-label.d.mts.map +1 -1
  303. package/dist/number-field/number-field-label.mjs +2 -0
  304. package/dist/number-field/number-field-label.mjs.map +1 -1
  305. package/dist/number-field/number-field-root.d.mts +62 -14
  306. package/dist/number-field/number-field-root.d.mts.map +1 -1
  307. package/dist/number-field/number-field-root.mjs +2 -0
  308. package/dist/number-field/number-field-root.mjs.map +1 -1
  309. package/dist/number-field/use-step-button.d.mts +20 -0
  310. package/dist/number-field/use-step-button.d.mts.map +1 -1
  311. package/dist/number-field/use-step-button.mjs.map +1 -1
  312. package/dist/popover/index.d.mts +2 -0
  313. package/dist/popover/index.d.mts.map +1 -1
  314. package/dist/popover/index.mjs +2 -0
  315. package/dist/popover/index.mjs.map +1 -1
  316. package/dist/popover/popover-close.d.mts +18 -0
  317. package/dist/popover/popover-close.d.mts.map +1 -1
  318. package/dist/popover/popover-close.mjs +2 -0
  319. package/dist/popover/popover-close.mjs.map +1 -1
  320. package/dist/popover/popover-description.d.mts +12 -0
  321. package/dist/popover/popover-description.d.mts.map +1 -1
  322. package/dist/popover/popover-description.mjs +2 -0
  323. package/dist/popover/popover-description.mjs.map +1 -1
  324. package/dist/popover/popover-popup.d.mts +30 -4
  325. package/dist/popover/popover-popup.d.mts.map +1 -1
  326. package/dist/popover/popover-popup.mjs +2 -0
  327. package/dist/popover/popover-popup.mjs.map +1 -1
  328. package/dist/popover/popover-root.d.mts +9 -0
  329. package/dist/popover/popover-root.d.mts.map +1 -1
  330. package/dist/popover/popover-root.mjs +2 -0
  331. package/dist/popover/popover-root.mjs.map +1 -1
  332. package/dist/popover/popover-title.d.mts +11 -0
  333. package/dist/popover/popover-title.d.mts.map +1 -1
  334. package/dist/popover/popover-title.mjs +2 -0
  335. package/dist/popover/popover-title.mjs.map +1 -1
  336. package/dist/popover/popover-trigger.d.mts +15 -0
  337. package/dist/popover/popover-trigger.d.mts.map +1 -1
  338. package/dist/popover/popover-trigger.mjs +2 -0
  339. package/dist/popover/popover-trigger.mjs.map +1 -1
  340. package/dist/progress/index.d.mts +2 -0
  341. package/dist/progress/index.d.mts.map +1 -1
  342. package/dist/progress/index.mjs +2 -0
  343. package/dist/progress/index.mjs.map +1 -1
  344. package/dist/progress/progress-indicator.d.mts +11 -0
  345. package/dist/progress/progress-indicator.d.mts.map +1 -1
  346. package/dist/progress/progress-indicator.mjs +2 -0
  347. package/dist/progress/progress-indicator.mjs.map +1 -1
  348. package/dist/progress/progress-label.d.mts +11 -0
  349. package/dist/progress/progress-label.d.mts.map +1 -1
  350. package/dist/progress/progress-label.mjs +2 -0
  351. package/dist/progress/progress-label.mjs.map +1 -1
  352. package/dist/progress/progress-root.d.mts +36 -8
  353. package/dist/progress/progress-root.d.mts.map +1 -1
  354. package/dist/progress/progress-root.mjs +2 -0
  355. package/dist/progress/progress-root.mjs.map +1 -1
  356. package/dist/progress/progress-track.d.mts +11 -0
  357. package/dist/progress/progress-track.d.mts.map +1 -1
  358. package/dist/progress/progress-track.mjs +2 -0
  359. package/dist/progress/progress-track.mjs.map +1 -1
  360. package/dist/progress/progress-value.d.mts +15 -1
  361. package/dist/progress/progress-value.d.mts.map +1 -1
  362. package/dist/progress/progress-value.mjs +2 -0
  363. package/dist/progress/progress-value.mjs.map +1 -1
  364. package/dist/radio-group/index.d.mts +2 -0
  365. package/dist/radio-group/index.d.mts.map +1 -1
  366. package/dist/radio-group/index.mjs +2 -0
  367. package/dist/radio-group/index.mjs.map +1 -1
  368. package/dist/radio-group/radio-group-item.d.mts +18 -1
  369. package/dist/radio-group/radio-group-item.d.mts.map +1 -1
  370. package/dist/radio-group/radio-group-item.mjs +2 -0
  371. package/dist/radio-group/radio-group-item.mjs.map +1 -1
  372. package/dist/radio-group/radio-group-label.d.mts +10 -0
  373. package/dist/radio-group/radio-group-label.d.mts.map +1 -1
  374. package/dist/radio-group/radio-group-label.mjs +2 -0
  375. package/dist/radio-group/radio-group-label.mjs.map +1 -1
  376. package/dist/radio-group/radio-group-root.d.mts +29 -5
  377. package/dist/radio-group/radio-group-root.d.mts.map +1 -1
  378. package/dist/radio-group/radio-group-root.mjs +2 -0
  379. package/dist/radio-group/radio-group-root.mjs.map +1 -1
  380. package/dist/select/index.d.mts +2 -0
  381. package/dist/select/index.d.mts.map +1 -1
  382. package/dist/select/index.mjs +2 -0
  383. package/dist/select/index.mjs.map +1 -1
  384. package/dist/select/select-group-label.d.mts +10 -0
  385. package/dist/select/select-group-label.d.mts.map +1 -1
  386. package/dist/select/select-group-label.mjs +2 -0
  387. package/dist/select/select-group-label.mjs.map +1 -1
  388. package/dist/select/select-group.d.mts +15 -1
  389. package/dist/select/select-group.d.mts.map +1 -1
  390. package/dist/select/select-group.mjs +2 -0
  391. package/dist/select/select-group.mjs.map +1 -1
  392. package/dist/select/select-option.d.mts +19 -1
  393. package/dist/select/select-option.d.mts.map +1 -1
  394. package/dist/select/select-option.mjs +2 -0
  395. package/dist/select/select-option.mjs.map +1 -1
  396. package/dist/select/select-root.d.mts +24 -1
  397. package/dist/select/select-root.d.mts.map +1 -1
  398. package/dist/select/select-root.mjs +2 -0
  399. package/dist/select/select-root.mjs.map +1 -1
  400. package/dist/select/select-separator.d.mts +9 -0
  401. package/dist/select/select-separator.d.mts.map +1 -1
  402. package/dist/select/select-separator.mjs +2 -0
  403. package/dist/select/select-separator.mjs.map +1 -1
  404. package/dist/select/select-trigger.d.mts +9 -0
  405. package/dist/select/select-trigger.d.mts.map +1 -1
  406. package/dist/select/select-trigger.mjs +2 -0
  407. package/dist/select/select-trigger.mjs.map +1 -1
  408. package/dist/select/select-value.d.mts +9 -0
  409. package/dist/select/select-value.d.mts.map +1 -1
  410. package/dist/select/select-value.mjs +2 -0
  411. package/dist/select/select-value.mjs.map +1 -1
  412. package/dist/slider/index.d.mts +2 -0
  413. package/dist/slider/index.d.mts.map +1 -1
  414. package/dist/slider/index.mjs +2 -0
  415. package/dist/slider/index.mjs.map +1 -1
  416. package/dist/slider/slider-indicator.d.mts +12 -0
  417. package/dist/slider/slider-indicator.d.mts.map +1 -1
  418. package/dist/slider/slider-indicator.mjs +2 -0
  419. package/dist/slider/slider-indicator.mjs.map +1 -1
  420. package/dist/slider/slider-label.d.mts +11 -1
  421. package/dist/slider/slider-label.d.mts.map +1 -1
  422. package/dist/slider/slider-label.mjs +2 -0
  423. package/dist/slider/slider-label.mjs.map +1 -1
  424. package/dist/slider/slider-root.d.mts +53 -9
  425. package/dist/slider/slider-root.d.mts.map +1 -1
  426. package/dist/slider/slider-root.mjs +2 -0
  427. package/dist/slider/slider-root.mjs.map +1 -1
  428. package/dist/slider/slider-thumb.d.mts +32 -3
  429. package/dist/slider/slider-thumb.d.mts.map +1 -1
  430. package/dist/slider/slider-thumb.mjs +2 -0
  431. package/dist/slider/slider-thumb.mjs.map +1 -1
  432. package/dist/slider/slider-track.d.mts +17 -0
  433. package/dist/slider/slider-track.d.mts.map +1 -1
  434. package/dist/slider/slider-track.mjs +2 -0
  435. package/dist/slider/slider-track.mjs.map +1 -1
  436. package/dist/slider/slider-value.d.mts +11 -0
  437. package/dist/slider/slider-value.d.mts.map +1 -1
  438. package/dist/slider/slider-value.mjs +2 -0
  439. package/dist/slider/slider-value.mjs.map +1 -1
  440. package/dist/switch/switch.d.mts +23 -3
  441. package/dist/switch/switch.d.mts.map +1 -1
  442. package/dist/switch/switch.mjs +2 -0
  443. package/dist/switch/switch.mjs.map +1 -1
  444. package/dist/tabs/index.d.mts +2 -0
  445. package/dist/tabs/index.d.mts.map +1 -1
  446. package/dist/tabs/index.mjs +2 -0
  447. package/dist/tabs/index.mjs.map +1 -1
  448. package/dist/tabs/tabs-context.d.mts +5 -0
  449. package/dist/tabs/tabs-context.d.mts.map +1 -1
  450. package/dist/tabs/tabs-context.mjs.map +1 -1
  451. package/dist/tabs/tabs-indicator.d.mts +17 -0
  452. package/dist/tabs/tabs-indicator.d.mts.map +1 -1
  453. package/dist/tabs/tabs-indicator.mjs +2 -0
  454. package/dist/tabs/tabs-indicator.mjs.map +1 -1
  455. package/dist/tabs/tabs-list.d.mts +19 -1
  456. package/dist/tabs/tabs-list.d.mts.map +1 -1
  457. package/dist/tabs/tabs-list.mjs +2 -0
  458. package/dist/tabs/tabs-list.mjs.map +1 -1
  459. package/dist/tabs/tabs-panel.d.mts +19 -0
  460. package/dist/tabs/tabs-panel.d.mts.map +1 -1
  461. package/dist/tabs/tabs-panel.mjs +2 -0
  462. package/dist/tabs/tabs-panel.mjs.map +1 -1
  463. package/dist/tabs/tabs-root.d.mts +39 -5
  464. package/dist/tabs/tabs-root.d.mts.map +1 -1
  465. package/dist/tabs/tabs-root.mjs +2 -0
  466. package/dist/tabs/tabs-root.mjs.map +1 -1
  467. package/dist/tabs/tabs-tab.d.mts +22 -1
  468. package/dist/tabs/tabs-tab.d.mts.map +1 -1
  469. package/dist/tabs/tabs-tab.mjs +2 -0
  470. package/dist/tabs/tabs-tab.mjs.map +1 -1
  471. package/dist/toast/index.d.mts +2 -0
  472. package/dist/toast/index.d.mts.map +1 -1
  473. package/dist/toast/index.mjs +2 -0
  474. package/dist/toast/index.mjs.map +1 -1
  475. package/dist/toast/toast-action.d.mts +28 -3
  476. package/dist/toast/toast-action.d.mts.map +1 -1
  477. package/dist/toast/toast-action.mjs +2 -0
  478. package/dist/toast/toast-action.mjs.map +1 -1
  479. package/dist/toast/toast-close.d.mts +16 -0
  480. package/dist/toast/toast-close.d.mts.map +1 -1
  481. package/dist/toast/toast-close.mjs +2 -0
  482. package/dist/toast/toast-close.mjs.map +1 -1
  483. package/dist/toast/toast-description.d.mts +16 -1
  484. package/dist/toast/toast-description.d.mts.map +1 -1
  485. package/dist/toast/toast-description.mjs +2 -0
  486. package/dist/toast/toast-description.mjs.map +1 -1
  487. package/dist/toast/toast-root.d.mts +20 -0
  488. package/dist/toast/toast-root.d.mts.map +1 -1
  489. package/dist/toast/toast-root.mjs +2 -0
  490. package/dist/toast/toast-root.mjs.map +1 -1
  491. package/dist/toast/toast-title.d.mts +15 -1
  492. package/dist/toast/toast-title.d.mts.map +1 -1
  493. package/dist/toast/toast-title.mjs +2 -0
  494. package/dist/toast/toast-title.mjs.map +1 -1
  495. package/dist/toast/toast-viewport.d.mts +34 -5
  496. package/dist/toast/toast-viewport.d.mts.map +1 -1
  497. package/dist/toast/toast-viewport.mjs +2 -0
  498. package/dist/toast/toast-viewport.mjs.map +1 -1
  499. package/dist/toast/toast.d.mts +46 -6
  500. package/dist/toast/toast.d.mts.map +1 -1
  501. package/dist/toast/toast.mjs +4 -0
  502. package/dist/toast/toast.mjs.map +1 -1
  503. package/dist/toggle/toggle.d.mts +20 -2
  504. package/dist/toggle/toggle.d.mts.map +1 -1
  505. package/dist/toggle/toggle.mjs +2 -0
  506. package/dist/toggle/toggle.mjs.map +1 -1
  507. package/dist/toggle-group/index.d.mts +2 -0
  508. package/dist/toggle-group/index.d.mts.map +1 -1
  509. package/dist/toggle-group/index.mjs +2 -0
  510. package/dist/toggle-group/index.mjs.map +1 -1
  511. package/dist/toggle-group/toggle-group-context.d.mts +1 -0
  512. package/dist/toggle-group/toggle-group-context.d.mts.map +1 -1
  513. package/dist/toggle-group/toggle-group-context.mjs.map +1 -1
  514. package/dist/toggle-group/toggle-group-item.d.mts +16 -0
  515. package/dist/toggle-group/toggle-group-item.d.mts.map +1 -1
  516. package/dist/toggle-group/toggle-group-item.mjs +2 -0
  517. package/dist/toggle-group/toggle-group-item.mjs.map +1 -1
  518. package/dist/toggle-group/toggle-group-root.d.mts +73 -12
  519. package/dist/toggle-group/toggle-group-root.d.mts.map +1 -1
  520. package/dist/toggle-group/toggle-group-root.mjs +2 -0
  521. package/dist/toggle-group/toggle-group-root.mjs.map +1 -1
  522. package/dist/toolbar/index.d.mts +2 -0
  523. package/dist/toolbar/index.d.mts.map +1 -1
  524. package/dist/toolbar/index.mjs +2 -0
  525. package/dist/toolbar/index.mjs.map +1 -1
  526. package/dist/toolbar/toolbar-root.d.mts +30 -3
  527. package/dist/toolbar/toolbar-root.d.mts.map +1 -1
  528. package/dist/toolbar/toolbar-root.mjs +2 -0
  529. package/dist/toolbar/toolbar-root.mjs.map +1 -1
  530. package/dist/toolbar/toolbar-separator.d.mts +13 -0
  531. package/dist/toolbar/toolbar-separator.d.mts.map +1 -1
  532. package/dist/toolbar/toolbar-separator.mjs +2 -0
  533. package/dist/toolbar/toolbar-separator.mjs.map +1 -1
  534. package/dist/tooltip/index.d.mts +2 -0
  535. package/dist/tooltip/index.d.mts.map +1 -1
  536. package/dist/tooltip/index.mjs +2 -0
  537. package/dist/tooltip/index.mjs.map +1 -1
  538. package/dist/tooltip/tooltip-arrow.d.mts +16 -0
  539. package/dist/tooltip/tooltip-arrow.d.mts.map +1 -1
  540. package/dist/tooltip/tooltip-arrow.mjs +2 -0
  541. package/dist/tooltip/tooltip-arrow.mjs.map +1 -1
  542. package/dist/tooltip/tooltip-context.d.mts +4 -0
  543. package/dist/tooltip/tooltip-context.d.mts.map +1 -1
  544. package/dist/tooltip/tooltip-context.mjs.map +1 -1
  545. package/dist/tooltip/tooltip-popup.d.mts +24 -3
  546. package/dist/tooltip/tooltip-popup.d.mts.map +1 -1
  547. package/dist/tooltip/tooltip-popup.mjs +2 -0
  548. package/dist/tooltip/tooltip-popup.mjs.map +1 -1
  549. package/dist/tooltip/tooltip-root.d.mts +24 -2
  550. package/dist/tooltip/tooltip-root.d.mts.map +1 -1
  551. package/dist/tooltip/tooltip-root.mjs +2 -0
  552. package/dist/tooltip/tooltip-root.mjs.map +1 -1
  553. package/dist/tooltip/tooltip-trigger.d.mts +18 -1
  554. package/dist/tooltip/tooltip-trigger.d.mts.map +1 -1
  555. package/dist/tooltip/tooltip-trigger.mjs +2 -0
  556. package/dist/tooltip/tooltip-trigger.mjs.map +1 -1
  557. package/package.json +9 -1
  558. package/skills/funstack-ui-knowledge/SKILL.md +75 -0
@@ -0,0 +1,341 @@
1
+ # ToggleGroup
2
+
3
+ A set of toggle buttons that share one value: any number pressed by default, at most one with `exclusive`. Every Item is the [Toggle](toggle.md) element (`<button aria-pressed>`); the group is one Tab stop with arrow keys between the Items, and inside a [Toolbar](toolbar.md) its Items join the toolbar's sequence.
4
+
5
+ ```tsx title="ToggleGroupStyles.tsx"
6
+ "use client";
7
+ import { useState } from "react";
8
+ import { ToggleGroup } from "@funstack/ui/toggle-group";
9
+ import { DemoErrorBoundary } from "./DemoErrorBoundary.js";
10
+ import { fakeSave } from "./fake-api.js";
11
+
12
+ // Multiple mode, uncontrolled, with an async save. Each Item flips at once and shows a spinner
13
+ // (data-pending) until its save settles. With "fail" on, the save rejects: the Item flips back
14
+ // and the error reaches the boundary.
15
+ export function ToggleGroupStyles() {
16
+ const [fail, setFail] = useState(false);
17
+ return (
18
+ <div className="demo-stack">
19
+ <label>
20
+ <input type="checkbox" checked={fail} onChange={(e) => setFail(e.target.checked)} /> Make
21
+ the save fail
22
+ </label>
23
+ <DemoErrorBoundary>
24
+ <ToggleGroup.Root
25
+ aria-label="Text style"
26
+ className="demo-toggle-group"
27
+ defaultValue={["bold"]}
28
+ valueChangeAction={(next, { added, removed }) =>
29
+ fakeSave(`styles (added ${added}, removed ${removed}) → ${next}`, { fail })
30
+ }
31
+ >
32
+ {["Bold", "Italic", "Underline"].map((label) => (
33
+ <ToggleGroup.Item key={label} value={label.toLowerCase()} className="demo-toggle-item">
34
+ {({ pending }) => (
35
+ <>
36
+ {pending && <span className="demo-spinner" aria-hidden />}
37
+ {label}
38
+ </>
39
+ )}
40
+ </ToggleGroup.Item>
41
+ ))}
42
+ </ToggleGroup.Root>
43
+ </DemoErrorBoundary>
44
+ </div>
45
+ );
46
+ }
47
+ ```
48
+
49
+ ```css title="toggle-group.css"
50
+ /* ToggleGroup: data attributes carry library state; :focus-visible comes from the platform. */
51
+ .demo-toggle-group {
52
+ display: inline-flex;
53
+ gap: 2px;
54
+ padding: 2px;
55
+ border: 1px solid var(--color-border);
56
+ border-radius: 8px;
57
+ }
58
+
59
+ .demo-toggle-group[data-orientation="vertical"] {
60
+ flex-direction: column;
61
+ }
62
+
63
+ .demo-toggle-group[data-pending] {
64
+ cursor: progress;
65
+ }
66
+
67
+ .demo-toggle-item {
68
+ display: inline-flex;
69
+ align-items: center;
70
+ gap: 0.4em;
71
+ padding: 0.3em 0.8em;
72
+ border: 0;
73
+ border-radius: 6px;
74
+ background: transparent;
75
+ color: var(--color-text);
76
+ font: inherit;
77
+ cursor: pointer;
78
+ /* The optimistic flip is a sync commit: a plain CSS transition animates it. */
79
+ transition:
80
+ background-color 120ms,
81
+ color 120ms;
82
+ }
83
+
84
+ .demo-toggle-item[data-pressed] {
85
+ background: var(--color-primary);
86
+ color: var(--color-on-primary);
87
+ }
88
+
89
+ .demo-toggle-item[data-pending] {
90
+ cursor: progress;
91
+ }
92
+
93
+ .demo-toggle-item[data-disabled] {
94
+ opacity: 0.5;
95
+ cursor: not-allowed;
96
+ }
97
+
98
+ .demo-toggle-item:focus-visible {
99
+ outline: 2px solid var(--color-primary);
100
+ outline-offset: 2px;
101
+ }
102
+
103
+ @media (prefers-reduced-motion: reduce) {
104
+ .demo-toggle-item {
105
+ transition: none;
106
+ }
107
+ }
108
+ ```
109
+
110
+ Each Item flips the moment it is clicked and carries `data-pending` until its save settles; the group carries it too. A rejected save flips the Item back and reaches the Error Boundary around the group. Name the group with `aria-label` or `aria-labelledby`: it is what tells screen-reader users the buttons belong together.
111
+
112
+ ## Anatomy
113
+
114
+ ```tsx
115
+ import { ToggleGroup } from "@funstack/ui/toggle-group";
116
+
117
+ <ToggleGroup.Root aria-label="Text style" defaultValue={["bold"]} valueChangeAction={save}>
118
+ <ToggleGroup.Item value="bold">Bold</ToggleGroup.Item>
119
+ <ToggleGroup.Item value="italic">Italic</ToggleGroup.Item>
120
+ </ToggleGroup.Root>
121
+ ```
122
+
123
+ | Part | Element | Role |
124
+ | - | - | - |
125
+ | `ToggleGroup.Root` | `<div role="group">` | Owns the value, the transition and the roving focus. |
126
+ | `ToggleGroup.Item` | `<button type="button" aria-pressed>` | One toggle; its pressed state is the Root's. |
127
+
128
+ ## How it works
129
+
130
+ ### Exclusive mode
131
+
132
+ ```tsx title="ToggleGroupAlignment.tsx"
133
+ "use client";
134
+ import { startTransition, useState } from "react";
135
+ import { ToggleGroup } from "@funstack/ui/toggle-group";
136
+ import { fakeSave } from "./fake-api.js";
137
+
138
+ // Exclusive mode. The first group allows "nothing pressed" (press Left again to release it);
139
+ // the second is a view switcher with deselectable={false}: pressing the pressed Item does
140
+ // nothing. Controlled, "update on success": the setState after the await is a transition.
141
+ export function ToggleGroupAlignment() {
142
+ const [align, setAlign] = useState<string | null>("left");
143
+ const [layout, setLayout] = useState<string | null>("grid");
144
+ return (
145
+ <div className="demo-stack">
146
+ <ToggleGroup.Root
147
+ exclusive
148
+ aria-label="Text alignment"
149
+ className="demo-toggle-group"
150
+ value={align}
151
+ valueChangeAction={async (next) => {
152
+ await fakeSave(`alignment=${next}`);
153
+ startTransition(() => setAlign(next));
154
+ }}
155
+ >
156
+ <ToggleGroup.Item value="left" className="demo-toggle-item">
157
+ Left
158
+ </ToggleGroup.Item>
159
+ <ToggleGroup.Item value="center" className="demo-toggle-item">
160
+ Center
161
+ </ToggleGroup.Item>
162
+ <ToggleGroup.Item value="right" className="demo-toggle-item">
163
+ Right
164
+ </ToggleGroup.Item>
165
+ </ToggleGroup.Root>
166
+ <p>
167
+ Alignment: <output>{align ?? "none"}</output>
168
+ </p>
169
+ <ToggleGroup.Root
170
+ exclusive
171
+ deselectable={false}
172
+ aria-label="Layout"
173
+ className="demo-toggle-group"
174
+ value={layout}
175
+ valueChangeAction={(next) => {
176
+ setLayout(next);
177
+ }}
178
+ >
179
+ <ToggleGroup.Item value="grid" className="demo-toggle-item">
180
+ Grid
181
+ </ToggleGroup.Item>
182
+ <ToggleGroup.Item value="list" className="demo-toggle-item">
183
+ List
184
+ </ToggleGroup.Item>
185
+ </ToggleGroup.Root>
186
+ <p>
187
+ Layout: <output>{layout}</output>
188
+ </p>
189
+ </div>
190
+ );
191
+ }
192
+ ```
193
+
194
+ With `exclusive`, `value` is `string | null`. Pressing the pressed Item releases it (`next === null`); a view switcher that must always show one value passes `deselectable={false}`, and pressing the pressed Item then dispatches nothing.
195
+
196
+ > **When to use RadioGroup instead**
197
+ >
198
+ > The Items stay `aria-pressed` buttons in both modes, so a screen reader does not announce "1 of 3" or mutual exclusivity. If the choice is a form value, must always have a value, or should be announced as one choice among several, use a [RadioGroup](radio-group.md) styled as a segmented control: native radios, arrows that select, `name` and `required`.
199
+
200
+ ## Props
201
+
202
+ ### ToggleGroup.Root
203
+
204
+ The props are discriminated on `exclusive`: without it (or with `exclusive={false}`) the value is a `string[]`; with `exclusive` it is `string | null`, and `deselectable` becomes available. The mode is fixed when the group mounts.
205
+
206
+ | Prop | Type | Default | Description |
207
+ | - | - | - | - |
208
+ | `exclusive` | `boolean` | `false` | At most one Item pressed; `value` becomes `string \| null`. |
209
+ | `value` | `string[] \| (exclusive) string \| null` | – | Controlled pressed values. `[]` / `null` presses nothing; `undefined` means uncontrolled. Order is not significant. |
210
+ | `defaultValue` | `string[] \| (exclusive) string \| null` | `[] / null` | Initial pressed values in uncontrolled mode. |
211
+ | `valueChangeAction` | `ChangeAction<string[] \| (exclusive) string \| null, ToggleGroupValueChangeDetails>` | – | Runs inside the Root's transition on every change. `next` is a fresh array in document order (exclusive: the value or `null`); `details` is `{ added, removed }` plus the virtual `event`. Rejections roll the change back and reach the nearest Error Boundary. |
212
+ | `deselectable` | `boolean` | `true` | Exclusive only. `false`: pressing the pressed Item does nothing, so the action never receives `null`. |
213
+ | `orientation` | `"horizontal" \| "vertical"` | `"horizontal"` | Axis of the arrow keys and `data-orientation`. Ignored inside a Toolbar (development warning). |
214
+ | `loop` | `boolean` | `true` | Arrows wrap from the last Item to the first. Ignored inside a Toolbar. |
215
+ | `disabled` | `boolean` | `false` | Disables every Item (native `disabled`; `aria-disabled="true"` on an Item with a link or component `render`). |
216
+ | `experimental_focusgroup` | `boolean` | `false` | Renders `focusgroup="toolbar … nomemory"` and `focusgroupstart` on the first pressed Item; where the browser implements it (Chromium 150+) the browser moves focus, and Tab enters on the pressed Item. Ignored inside a Toolbar, with a development warning: a nested focusgroup would add Tab stops. See [Experimental features](../concepts/experimental.md). |
217
+ | `className` | `string \| ((state: ToggleGroupRootState) => string \| undefined)` | – | A class name, or a function of the part's state. |
218
+ | `style` | `CSSProperties \| ((state: ToggleGroupRootState) => CSSProperties \| undefined)` | – | Inline style, or a function of the part's state. |
219
+ | `children` | `ReactNode \| ((state: ToggleGroupRootState) => ReactNode)` | – | Content, or a function of the part's state. |
220
+ | `render` | `ReactElement \| ((props, state: ToggleGroupRootState) => ReactNode)` | – | Replace the default \<div> (element form) or take over rendering (function form). |
221
+
222
+ - **State**: `ToggleGroupRootState` is `{ value, pending, disabled, orientation }`; `value` is the optimistic set as an array in document order (exclusive mode: `[value]` or `[]`).
223
+ - **Owned**: `role` (`"group"`), `data-orientation`, `data-pending`, `data-disabled`; standalone (outside a Toolbar) also the roving-focus handlers `onKeyDown`, `onFocus`, `onBlur`, `onPointerDown` and, with the flag, `focusgroup`.
224
+
225
+ Every other `<div>` prop passes through.
226
+
227
+ ### ToggleGroup.Item
228
+
229
+ | Prop | Type | Default | Description |
230
+ | - | - | - | - |
231
+ | `value` | `string` | – | The value this Item presses. Unique within the group. |
232
+ | `disabled` | `boolean` | `false` | Never dispatches. Native `disabled` on a `<button>`, skipped by the arrow keys. With a link or component `render`, `aria-disabled="true"` instead: the element stays focusable and the arrow keys reach it (the APG Toolbar behaviour). |
233
+ | `transition` | `ViewTransitionClass` | – | Forwarded to the Item's `<ViewTransition default>`. Animates the commit that ends the group's action, not the optimistic flip. |
234
+ | `className` | `string \| ((state: ToggleGroupItemState) => string \| undefined)` | – | A class name, or a function of the part's state. |
235
+ | `style` | `CSSProperties \| ((state: ToggleGroupItemState) => CSSProperties \| undefined)` | – | Inline style, or a function of the part's state. |
236
+ | `children` | `ReactNode \| ((state: ToggleGroupItemState) => ReactNode)` | – | Rendered from optimistic state; must not suspend. |
237
+ | `render` | `ReactElement \| ((props, state: ToggleGroupItemState) => ReactNode)` | – | Replace the default \<button> (element form) or take over rendering (function form). |
238
+
239
+ - **State**: `ToggleGroupItemState` is `{ value, pressed, pending, disabled, orientation }`; `value` is the Item's own `value` prop.
240
+ - **Owned**: `aria-pressed`, `disabled`, `aria-disabled` (link or component `render`), `onClick`, `tabIndex` (the roving focus writes it), `data-pressed`, `data-pending`, `data-disabled`, `data-orientation`, and `focusgroupstart` while the Root renders `focusgroup`. `type` defaults to `"button"`; a `render` element's own wins.
241
+
242
+ ## Data attributes
243
+
244
+ | Hook | On | Meaning |
245
+ | - | - | - |
246
+ | `data-orientation` | Root, Item | The effective orientation (the Toolbar's inside one). |
247
+ | `data-pending` | Root | An action dispatched through the group is in flight. |
248
+ | `data-pending` | Item | In flight and this Item's optimistic state differs from its committed one. |
249
+ | `data-pressed` | Item | Optimistically pressed (agrees with `aria-pressed`). |
250
+ | `data-disabled` | Root, Item | Disabled (the Item's own or the Root's). |
251
+
252
+ ## Keyboard and ARIA
253
+
254
+ | Key | Horizontal | Vertical | Effect |
255
+ | - | - | - | - |
256
+ | ArrowRight / ArrowLeft | Next / previous enabled Item (swapped under `direction: rtl`) | Ignored | Moves focus only; wraps if `loop`. Never presses. |
257
+ | ArrowDown / ArrowUp | Ignored | Next / previous enabled Item | Same. |
258
+ | Home / End | First / last enabled Item | Same | Same. |
259
+ | Space / Enter | | | Toggles the focused Item (native button activation). |
260
+ | Tab / Shift+Tab | | | Enters on the first pressed enabled Item, else the first enabled one; leaves with the next press. |
261
+
262
+ - The Root is `role="group"` with no `aria-orientation` (ARIA does not allow it on a group); orientation is `data-orientation` only.
263
+ - `aria-pressed` is always `"true"` or `"false"` and follows the optimistic state. Focus never changes it.
264
+ - Disabled Items are natively disabled and leave the arrow-key sequence. An Item rendered as a link or a component is `aria-disabled` instead, and the arrow keys still reach it (it never dispatches). A rejected action rolls the pressed state back; focus stays where it is.
265
+ - Before hydration every Item is a Tab stop; the single Tab stop is set up by the first effect. The server HTML carries no `tabindex`.
266
+
267
+ ## Transition types
268
+
269
+ Concept: [Transitions & ViewTransition](../concepts/transitions.md#transition-types)
270
+
271
+ `fsui-toggle-group`, plus `fsui-toggle-group-press` and / or `fsui-toggle-group-release`.
272
+
273
+ ## Optimistic and pending
274
+
275
+ Concept: [Pending & optimistic state](../concepts/pending-and-optimistic.md)
276
+
277
+ Items show the optimistic set (`aria-pressed`, `data-pressed`). `data-pending` is on the Root while an action is in flight, and on each Item whose optimistic state differs from its committed one. An Item's `transition` animates the commit that ends the action, not the flip.
278
+
279
+ ## Suspense
280
+
281
+ Concept: [Suspense](../concepts/suspense.md)
282
+
283
+ No content region. Item content renders optimistic state and must not suspend.
284
+
285
+ ## Browser-owned state
286
+
287
+ Concept: [Browser-owned state](../concepts/browser-owned-state.md)
288
+
289
+ None: the pressed set is library-owned.
290
+
291
+ ## Before hydration
292
+
293
+ Concept: [Server Components](../concepts/server-components.md#before-hydration)
294
+
295
+ Markup and ARIA; every Item is its own Tab stop until the first effect sets up the single Tab stop. Pressing needs JavaScript.
296
+
297
+ ## Styling
298
+
299
+ ```css
300
+ .group[data-pending] { cursor: progress; }
301
+ .item[data-pressed] { background: var(--accent); color: white; }
302
+ .item[data-pending]::after { content: ""; /* spinner */ }
303
+
304
+ @media (prefers-reduced-motion: reduce) {
305
+ ::view-transition-group(*),
306
+ ::view-transition-old(*),
307
+ ::view-transition-new(*) {
308
+ animation: none !important;
309
+ }
310
+ }
311
+ ```
312
+
313
+ The optimistic flip is a synchronous commit: animate it with a CSS transition on `[data-pressed]`. View transition types are `fsui-toggle-group`, plus `fsui-toggle-group-press` and / or `fsui-toggle-group-release`.
314
+
315
+ ## Recipes
316
+
317
+ ### Controlled, saved on the server
318
+
319
+ `next` is the whole set; `details.added` and `details.removed` say what changed. When you update after your own `await`, apply the diff with a functional update: two overlapping saves that settle out of order then cannot lose a change.
320
+
321
+ ```tsx
322
+ const [styles, setStyles] = useState<string[]>(doc.styles);
323
+
324
+ <ToggleGroup.Root
325
+ aria-label="Text style"
326
+ value={styles}
327
+ valueChangeAction={async (_next, { added, removed }) => {
328
+ await api.patchStyles(doc.id, { added, removed });
329
+ startTransition(() =>
330
+ setStyles((prev) => [
331
+ ...prev.filter((v) => !removed.includes(v)),
332
+ ...added.filter((v) => !prev.includes(v)),
333
+ ]),
334
+ );
335
+ }}
336
+ >
337
+ …
338
+ </ToggleGroup.Root>
339
+ ```
340
+
341
+ A slow awaited `valueChangeAction` holds every other transition in the app until it settles ([Await only what the UI must wait for](../concepts/action-props.md#await-only)); for a fire-and-forget save, call `void save(next)` without awaiting it.
@@ -0,0 +1,245 @@
1
+ # Toggle
2
+
3
+ A two-state button (WAI-ARIA Button pattern, toggle variant). The pressed state flips optimistically and the button carries `data-pending` while `pressedChangeAction` runs.
4
+
5
+ ```tsx title="ToggleFavorite.tsx"
6
+ "use client";
7
+ import { Toggle } from "@funstack/ui/toggle";
8
+ import { fakeSave } from "./fake-api.js";
9
+
10
+ // Uncontrolled Toggle with an async action. The star flips at once (optimistic), the button
11
+ // carries data-pending for the 800 ms the save takes, and a second click while pending wins.
12
+ export function ToggleFavorite() {
13
+ return (
14
+ <Toggle className="demo-toggle" pressedChangeAction={(next) => fakeSave(`favorite=${next}`)}>
15
+ {({ pressed, pending }) => (
16
+ <>
17
+ {pending ? (
18
+ <span className="demo-spinner" aria-hidden />
19
+ ) : (
20
+ <span aria-hidden>{pressed ? "★" : "☆"}</span>
21
+ )}
22
+ Favorite
23
+ </>
24
+ )}
25
+ </Toggle>
26
+ );
27
+ }
28
+ ```
29
+
30
+ ```css title="toggle.css"
31
+ /* Toggle: data attributes carry library state; :hover / :focus-visible come from the platform. */
32
+ .demo-toggle {
33
+ display: inline-flex;
34
+ align-items: center;
35
+ gap: 0.4em;
36
+ padding: 0.4em 0.9em;
37
+ border: 1px solid var(--color-border);
38
+ border-radius: 999px;
39
+ background: var(--color-bg);
40
+ color: var(--color-text);
41
+ font: inherit;
42
+ cursor: pointer;
43
+ /* The optimistic flip is a sync commit, so it animates with a plain CSS transition. */
44
+ transition:
45
+ background-color 120ms,
46
+ color 120ms,
47
+ border-color 120ms;
48
+ }
49
+
50
+ .demo-toggle[data-pressed] {
51
+ background: var(--color-primary);
52
+ border-color: var(--color-primary);
53
+ color: var(--color-on-primary);
54
+ }
55
+
56
+ .demo-toggle[data-pending] {
57
+ cursor: progress;
58
+ }
59
+
60
+ .demo-toggle[data-disabled] {
61
+ opacity: 0.5;
62
+ cursor: not-allowed;
63
+ }
64
+
65
+ .demo-toggle:focus-visible {
66
+ outline: 2px solid var(--color-primary);
67
+ outline-offset: 2px;
68
+ }
69
+
70
+ @media (prefers-reduced-motion: reduce) {
71
+ .demo-toggle {
72
+ transition: none;
73
+ }
74
+ }
75
+ ```
76
+
77
+ ## Anatomy
78
+
79
+ ```tsx
80
+ import { Toggle } from "@funstack/ui/toggle";
81
+
82
+ <Toggle pressedChangeAction={setFavorite}>Favorite</Toggle>
83
+ ```
84
+
85
+ One plain component, no parts. It renders `<button type="button" aria-pressed>`.
86
+
87
+ ## Props
88
+
89
+ | Prop | Type | Default | Description |
90
+ | - | - | - | - |
91
+ | `pressed` | `boolean` | – | Controlled pressed state. undefined means uncontrolled. |
92
+ | `defaultPressed` | `boolean` | `false` | Initial pressed state in uncontrolled mode. |
93
+ | `pressedChangeAction` | `ChangeAction<boolean, TogglePressedChangeDetails>` | – | Called with the next pressed state on every user-initiated change. Runs inside the Toggle's transition; may be sync or async. Rejections reach the nearest Error Boundary. `details` carries only `event` (the native click event; keyboard activation also arrives as a click). |
94
+ | `disabled` | `boolean` | `false` | Never dispatches. Native `disabled` on a `<button>`; with a link or component `render`, `aria-disabled="true"` instead (the element stays focusable). |
95
+ | `transition` | `ViewTransitionClass` | – | Forwarded to the Toggle's `<ViewTransition default>`. Animates the commit that ends an action (and rollbacks), not the optimistic flip. |
96
+ | `className` | `string \| ((state: ToggleState) => string \| undefined)` | – | A class name, or a function of the part's state. |
97
+ | `style` | `CSSProperties \| ((state: ToggleState) => CSSProperties \| undefined)` | – | Inline style, or a function of the part's state. |
98
+ | `children` | `ReactNode \| ((state: ToggleState) => ReactNode)` | – | Rendered from optimistic state; must not suspend. |
99
+ | `render` | `ReactElement \| ((props, state: ToggleState) => ReactNode)` | – | Replace the default \<button> (element form) or take over rendering (function form). |
100
+
101
+ - **State**: `ToggleState` is `{ pressed, pending, disabled }`; `pressed` is optimistic.
102
+ - **Owned**: `aria-pressed`, `disabled`, `aria-disabled` (link or component `render`), `onClick`, `data-pressed`, `data-pending`, `data-disabled`.
103
+
104
+ Every other `<button>` prop passes through; `type` defaults to `"button"` and a `render` element's own `type` wins.
105
+
106
+ ## Data attributes
107
+
108
+ | Hook | Meaning |
109
+ | - | - |
110
+ | `data-pressed` | Optimistically pressed. |
111
+ | `aria-pressed` | `"true"` or `"false"`, optimistic. |
112
+ | `data-pending` | `pressedChangeAction` is in flight. |
113
+ | `data-disabled` | The `disabled` prop (also matches `:disabled`). |
114
+
115
+ ## Keyboard and ARIA
116
+
117
+ | Interaction | Behaviour |
118
+ | - | - |
119
+ | Space, Enter, click | Toggles (native button activation). |
120
+ | Tab | Focusable unless disabled. |
121
+
122
+ - `aria-pressed` is always `"true"` or `"false"`, never `"mixed"`, and follows the optimistic state.
123
+ - Keep the accessible name stable: the label should not change with the pressed state (swap an icon, not the text).
124
+ - The button is not disabled while pending. A second click while pending reverses the first, and the latest click wins.
125
+
126
+ ## Transition types
127
+
128
+ Concept: [Transitions & ViewTransition](../concepts/transitions.md#transition-types)
129
+
130
+ `fsui-toggle` plus `fsui-toggle-press` or `fsui-toggle-release`.
131
+
132
+ ## Optimistic and pending
133
+
134
+ Concept: [Pending & optimistic state](../concepts/pending-and-optimistic.md)
135
+
136
+ `aria-pressed` and `data-pressed` follow the optimistic state; `data-pending` is on the Toggle while `pressedChangeAction` is in flight. The `transition` prop animates the commit that ends the action (for example a spinner turning back into an icon), not the pressed flip: animate that with a CSS transition on `[data-pressed]`.
137
+
138
+ ### Walkthrough
139
+
140
+ 1. Click: `aria-pressed` and `data-pressed` flip at once, `data-pending` appears, `pressedChangeAction(true, details)` runs.
141
+ 2. Resolve: in uncontrolled mode the value is committed; `data-pending` goes. In controlled mode the parent's `pressed` decides.
142
+ 3. Reject: the pressed state rolls back and the error reaches the nearest Error Boundary.
143
+ 4. Click again while pending: the next value is the opposite of the _optimistic_ value, so the second click undoes the first. Only the latest dispatch commits.
144
+
145
+ ```tsx title="ToggleErrors.tsx"
146
+ "use client";
147
+ import { startTransition, useRef, useState } from "react";
148
+ import { Toggle } from "@funstack/ui/toggle";
149
+ import { DemoErrorBoundary } from "./DemoErrorBoundary.js";
150
+ import { fakeSave } from "./fake-api.js";
151
+
152
+ // Two ways to handle a failing action.
153
+ export function ToggleErrors() {
154
+ return (
155
+ <div className="demo-row">
156
+ <ControlledWithInlineError />
157
+ <DemoErrorBoundary>
158
+ <Toggle
159
+ className="demo-toggle"
160
+ pressedChangeAction={(next) => fakeSave(`notify=${next}`, { fail: true })}
161
+ >
162
+ {({ pending }) => (
163
+ <>{pending && <span className="demo-spinner" aria-hidden />}Notify me</>
164
+ )}
165
+ </Toggle>
166
+ </DemoErrorBoundary>
167
+ </div>
168
+ );
169
+ }
170
+
171
+ // Controlled, "update on success": the parent adopts the value only after the save succeeds.
172
+ // Every second save fails; the error is caught inside the action, so the Toggle snaps back.
173
+ function ControlledWithInlineError() {
174
+ const [pinned, setPinned] = useState(false);
175
+ const [error, setError] = useState<string | null>(null);
176
+ const saves = useRef(0);
177
+ return (
178
+ <span>
179
+ <Toggle
180
+ className="demo-toggle"
181
+ pressed={pinned}
182
+ pressedChangeAction={async (next) => {
183
+ setError(null); // sync prefix: already a Transition update
184
+ try {
185
+ await fakeSave(`pinned=${next}`, { fail: ++saves.current % 2 === 0 });
186
+ // After an await, wrap state updates in startTransition yourself.
187
+ startTransition(() => setPinned(next));
188
+ } catch (e) {
189
+ startTransition(() => setError(e instanceof Error ? e.message : String(e)));
190
+ }
191
+ }}
192
+ >
193
+ {({ pending }) => <>{pending && <span className="demo-spinner" aria-hidden />}Pin</>}
194
+ </Toggle>
195
+ {error && <span className="demo-inline-error"> {error}</span>}
196
+ </span>
197
+ );
198
+ }
199
+ ```
200
+
201
+ The left Toggle catches its errors inline; the right one lets them reach a boundary.
202
+
203
+ ## Suspense
204
+
205
+ Concept: [Suspense](../concepts/suspense.md)
206
+
207
+ No content region. The `children` function renders optimistic state and must not suspend.
208
+
209
+ ## Browser-owned state
210
+
211
+ Concept: [Browser-owned state](../concepts/browser-owned-state.md)
212
+
213
+ None: the pressed state is library-owned.
214
+
215
+ ## Before hydration
216
+
217
+ Concept: [Server Components](../concepts/server-components.md#before-hydration)
218
+
219
+ Markup and ARIA. Pressing needs JavaScript.
220
+
221
+ ## Recipes
222
+
223
+ Several toggles that share one value (text styles, an alignment choice) are a [ToggleGroup](toggle-group.md): one Tab stop, arrow keys between the items, and a set value with `added` / `removed` in the action's details.
224
+
225
+ ### Controlled, local state
226
+
227
+ ```tsx
228
+ const [muted, setMuted] = useState(false);
229
+
230
+ <Toggle pressed={muted} pressedChangeAction={(next) => { setMuted(next); }}>
231
+ Mute
232
+ </Toggle>
233
+ ```
234
+
235
+ ### A Server Function, from a Server Component
236
+
237
+ ```tsx
238
+ <Toggle defaultPressed={post.favorited} pressedChangeAction={setFavorite.bind(null, post.id)}>
239
+ Favorite
240
+ </Toggle>
241
+ ```
242
+
243
+ > **Disabling while pending**
244
+ >
245
+ > The library does not do it (native `disabled` would drop keyboard focus). Use `.toggle[data-pending] { pointer-events: none }`, or add `aria-busy` yourself.