@primecoderin/fast-ui-react 0.0.0-stage → 1.0.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 (354) hide show
  1. package/CHANGELOG.md +106 -0
  2. package/LICENSE +21 -0
  3. package/README.md +180 -3
  4. package/dist/_virtual/_rolldown/runtime.js +12 -0
  5. package/dist/charts.d.ts +7 -0
  6. package/dist/charts.js +7 -0
  7. package/dist/components/Avatar/Avatar.d.ts +12 -0
  8. package/dist/components/Avatar/Avatar.js +92 -0
  9. package/dist/components/Button/Button.d.ts +44 -0
  10. package/dist/components/Button/Button.js +221 -0
  11. package/dist/components/Checkbox/CheckboxBox.d.ts +33 -0
  12. package/dist/components/Checkbox/CheckboxBox.js +148 -0
  13. package/dist/components/CodeSnippet/CodeSnippet.d.ts +26 -0
  14. package/dist/components/CodeSnippet/CodeSnippet.js +153 -0
  15. package/dist/components/Collapsible/Collapsible.d.ts +20 -0
  16. package/dist/components/Collapsible/Collapsible.js +97 -0
  17. package/dist/components/Container/Container.d.ts +301 -0
  18. package/dist/components/Container/Container.js +20 -0
  19. package/dist/components/FloatingActionButton/FloatingActionButton.d.ts +22 -0
  20. package/dist/components/FloatingActionButton/FloatingActionButton.js +141 -0
  21. package/dist/components/Grid/Grid.d.ts +311 -0
  22. package/dist/components/Grid/Grid.js +30 -0
  23. package/dist/components/IconTile/IconTile.d.ts +12 -0
  24. package/dist/components/IconTile/IconTile.js +70 -0
  25. package/dist/components/InlineError/InlineError.d.ts +9 -0
  26. package/dist/components/InlineError/InlineError.js +62 -0
  27. package/dist/components/Kbd/Kbd.d.ts +11 -0
  28. package/dist/components/Kbd/Kbd.js +31 -0
  29. package/dist/components/Link/Link.d.ts +18 -0
  30. package/dist/components/Link/Link.js +68 -0
  31. package/dist/components/Menu/ContextMenu.d.ts +18 -0
  32. package/dist/components/Menu/ContextMenu.js +68 -0
  33. package/dist/components/Menu/Menu.d.ts +86 -0
  34. package/dist/components/Menu/Menu.js +394 -0
  35. package/dist/components/OtpInput/OtpInput.d.ts +32 -0
  36. package/dist/components/OtpInput/OtpInput.js +177 -0
  37. package/dist/components/Popover/HoverPopover.d.ts +22 -0
  38. package/dist/components/Popover/HoverPopover.js +74 -0
  39. package/dist/components/Popover/Popover.d.ts +21 -0
  40. package/dist/components/Popover/Popover.js +64 -0
  41. package/dist/components/ProgressBar/ProgressBar.d.ts +17 -0
  42. package/dist/components/ProgressBar/ProgressBar.js +44 -0
  43. package/dist/components/Rating/Rating.d.ts +49 -0
  44. package/dist/components/Rating/Rating.js +241 -0
  45. package/dist/components/ScrollArea/ScrollArea.d.ts +23 -0
  46. package/dist/components/ScrollArea/ScrollArea.js +90 -0
  47. package/dist/components/SegmentedControl/SegmentedControl.d.ts +29 -0
  48. package/dist/components/SegmentedControl/SegmentedControl.js +99 -0
  49. package/dist/components/Separator/Separator.d.ts +9 -0
  50. package/dist/components/Separator/Separator.js +34 -0
  51. package/dist/components/Skeleton/Skeleton.d.ts +31 -0
  52. package/dist/components/Skeleton/Skeleton.js +152 -0
  53. package/dist/components/Slider/Slider.d.ts +54 -0
  54. package/dist/components/Slider/Slider.js +178 -0
  55. package/dist/components/Spinner/Spinner.d.ts +17 -0
  56. package/dist/components/Spinner/Spinner.js +118 -0
  57. package/dist/components/Stack/Stack.d.ts +302 -0
  58. package/dist/components/Stack/Stack.js +14 -0
  59. package/dist/components/StateIcon/StateIcon.d.ts +11 -0
  60. package/dist/components/StateIcon/StateIcon.js +65 -0
  61. package/dist/components/StatusBadge/StatusBadge.d.ts +19 -0
  62. package/dist/components/StatusBadge/StatusBadge.js +82 -0
  63. package/dist/components/Tabs/Tabs.d.ts +28 -0
  64. package/dist/components/Tabs/Tabs.js +109 -0
  65. package/dist/components/Tag/Tag.d.ts +11 -0
  66. package/dist/components/Tag/Tag.js +66 -0
  67. package/dist/components/Toast/AppToaster.d.ts +8 -0
  68. package/dist/components/Toast/AppToaster.js +135 -0
  69. package/dist/components/Toast/toast-manager.d.ts +28 -0
  70. package/dist/components/Toast/toast-manager.js +47 -0
  71. package/dist/components/ToggleButton/ToggleButton.d.ts +26 -0
  72. package/dist/components/ToggleButton/ToggleButton.js +106 -0
  73. package/dist/components/ToggleGroup/ToggleGroup.d.ts +32 -0
  74. package/dist/components/ToggleGroup/ToggleGroup.js +79 -0
  75. package/dist/components/Tooltip/Tooltip.d.ts +16 -0
  76. package/dist/components/Tooltip/Tooltip.js +58 -0
  77. package/dist/components/Tooltip/TooltipGroup.d.ts +22 -0
  78. package/dist/components/Tooltip/TooltipGroup.js +65 -0
  79. package/dist/components/Typography/Typography.d.ts +17 -0
  80. package/dist/components/Typography/Typography.js +100 -0
  81. package/dist/editor-forms.d.ts +1 -0
  82. package/dist/editor-forms.js +1 -0
  83. package/dist/editor.d.ts +1 -0
  84. package/dist/editor.js +1 -0
  85. package/dist/fonts/LICENSE +93 -0
  86. package/dist/fonts/inter-cyrillic-ext-wght-normal.woff2 +0 -0
  87. package/dist/fonts/inter-cyrillic-wght-normal.woff2 +0 -0
  88. package/dist/fonts/inter-greek-ext-wght-normal.woff2 +0 -0
  89. package/dist/fonts/inter-greek-wght-normal.woff2 +0 -0
  90. package/dist/fonts/inter-latin-ext-wght-normal.woff2 +0 -0
  91. package/dist/fonts/inter-latin-wght-normal.woff2 +0 -0
  92. package/dist/fonts/inter-vietnamese-wght-normal.woff2 +0 -0
  93. package/dist/fonts.css +69 -0
  94. package/dist/forms.d.ts +22 -0
  95. package/dist/forms.js +23 -0
  96. package/dist/foundation.css +23 -0
  97. package/dist/global.css +116 -0
  98. package/dist/hooks/useAppToast.d.ts +12 -0
  99. package/dist/hooks/useAppToast.js +29 -0
  100. package/dist/icons/icons.d.ts +43 -0
  101. package/dist/icons/icons.js +44 -0
  102. package/dist/index.d.ts +106 -0
  103. package/dist/index.js +101 -0
  104. package/dist/patterns/Accordion/Accordion.d.ts +35 -0
  105. package/dist/patterns/Accordion/Accordion.js +139 -0
  106. package/dist/patterns/Alert/Alert.d.ts +38 -0
  107. package/dist/patterns/Alert/Alert.js +151 -0
  108. package/dist/patterns/AppShell/AppShell.d.ts +39 -0
  109. package/dist/patterns/AppShell/AppShell.js +218 -0
  110. package/dist/patterns/Breadcrumbs/Breadcrumbs.d.ts +21 -0
  111. package/dist/patterns/Breadcrumbs/Breadcrumbs.js +73 -0
  112. package/dist/patterns/Calendar/Calendar.d.ts +59 -0
  113. package/dist/patterns/Calendar/Calendar.js +283 -0
  114. package/dist/patterns/Calendar/DateRangePicker.d.ts +53 -0
  115. package/dist/patterns/Calendar/DateRangePicker.js +266 -0
  116. package/dist/patterns/Calendar/FormDateRangeField.d.ts +24 -0
  117. package/dist/patterns/Calendar/FormDateRangeField.js +138 -0
  118. package/dist/patterns/Card/Card.d.ts +26 -0
  119. package/dist/patterns/Card/Card.js +125 -0
  120. package/dist/patterns/Carousel/Carousel.d.ts +33 -0
  121. package/dist/patterns/Carousel/Carousel.js +127 -0
  122. package/dist/patterns/Cascader/Cascader.d.ts +53 -0
  123. package/dist/patterns/Cascader/Cascader.js +371 -0
  124. package/dist/patterns/Cascader/FormCascaderField.d.ts +21 -0
  125. package/dist/patterns/Cascader/FormCascaderField.js +130 -0
  126. package/dist/patterns/Charts/AreaChart.d.ts +13 -0
  127. package/dist/patterns/Charts/AreaChart.js +220 -0
  128. package/dist/patterns/Charts/BarChart.d.ts +11 -0
  129. package/dist/patterns/Charts/BarChart.js +220 -0
  130. package/dist/patterns/Charts/DonutChart.d.ts +37 -0
  131. package/dist/patterns/Charts/DonutChart.js +215 -0
  132. package/dist/patterns/Charts/GaugeChart.d.ts +44 -0
  133. package/dist/patterns/Charts/GaugeChart.js +210 -0
  134. package/dist/patterns/Charts/LineChart.d.ts +14 -0
  135. package/dist/patterns/Charts/LineChart.js +222 -0
  136. package/dist/patterns/Charts/Sparkline.d.ts +24 -0
  137. package/dist/patterns/Charts/Sparkline.js +81 -0
  138. package/dist/patterns/Charts/chart-parts.d.ts +139 -0
  139. package/dist/patterns/Charts/chart-parts.js +385 -0
  140. package/dist/patterns/Charts/gauge-math.d.ts +20 -0
  141. package/dist/patterns/Charts/gauge-math.js +21 -0
  142. package/dist/patterns/Charts/sparkline-path.d.ts +11 -0
  143. package/dist/patterns/Charts/sparkline-path.js +24 -0
  144. package/dist/patterns/ColorPicker/ColorPicker.d.ts +50 -0
  145. package/dist/patterns/ColorPicker/ColorPicker.js +590 -0
  146. package/dist/patterns/ColorPicker/FormColorField.d.ts +21 -0
  147. package/dist/patterns/ColorPicker/FormColorField.js +130 -0
  148. package/dist/patterns/ColorPicker/color-value.d.ts +19 -0
  149. package/dist/patterns/ColorPicker/color-value.js +72 -0
  150. package/dist/patterns/Combobox/Autocomplete.d.ts +48 -0
  151. package/dist/patterns/Combobox/Autocomplete.js +158 -0
  152. package/dist/patterns/Combobox/Combobox.d.ts +52 -0
  153. package/dist/patterns/Combobox/Combobox.js +195 -0
  154. package/dist/patterns/Combobox/ComboboxPopup.d.ts +24 -0
  155. package/dist/patterns/Combobox/ComboboxPopup.js +107 -0
  156. package/dist/patterns/Combobox/FormAutocompleteField.d.ts +17 -0
  157. package/dist/patterns/Combobox/FormAutocompleteField.js +119 -0
  158. package/dist/patterns/Combobox/FormComboboxField.d.ts +18 -0
  159. package/dist/patterns/Combobox/FormComboboxField.js +119 -0
  160. package/dist/patterns/Combobox/FormMultiSelectField.d.ts +18 -0
  161. package/dist/patterns/Combobox/FormMultiSelectField.js +119 -0
  162. package/dist/patterns/Combobox/MultiSelect.d.ts +54 -0
  163. package/dist/patterns/Combobox/MultiSelect.js +175 -0
  164. package/dist/patterns/CommandPalette/CommandPalette.d.ts +50 -0
  165. package/dist/patterns/CommandPalette/CommandPalette.js +193 -0
  166. package/dist/patterns/DataTable/DataTable.d.ts +107 -0
  167. package/dist/patterns/DataTable/DataTable.js +364 -0
  168. package/dist/patterns/DateTimePicker/DateTimePanel.d.ts +28 -0
  169. package/dist/patterns/DateTimePicker/DateTimePanel.js +444 -0
  170. package/dist/patterns/DateTimePicker/DateTimePicker.d.ts +75 -0
  171. package/dist/patterns/DateTimePicker/DateTimePicker.js +271 -0
  172. package/dist/patterns/DateTimePicker/FormDateTimeField.d.ts +32 -0
  173. package/dist/patterns/DateTimePicker/FormDateTimeField.js +148 -0
  174. package/dist/patterns/DateTimePicker/TimeSliders.d.ts +14 -0
  175. package/dist/patterns/DateTimePicker/TimeSliders.js +206 -0
  176. package/dist/patterns/DateTimePicker/picker-labels.d.ts +30 -0
  177. package/dist/patterns/DateTimePicker/picker-labels.js +23 -0
  178. package/dist/patterns/DateTimePicker/picker-values.d.ts +98 -0
  179. package/dist/patterns/DateTimePicker/picker-values.js +194 -0
  180. package/dist/patterns/DescriptionList/DescriptionList.d.ts +20 -0
  181. package/dist/patterns/DescriptionList/DescriptionList.js +57 -0
  182. package/dist/patterns/Dialog/Dialog.d.ts +26 -0
  183. package/dist/patterns/Dialog/Dialog.js +212 -0
  184. package/dist/patterns/Drawer/Drawer.d.ts +33 -0
  185. package/dist/patterns/Drawer/Drawer.js +153 -0
  186. package/dist/patterns/EmptyState/EmptyState.d.ts +35 -0
  187. package/dist/patterns/EmptyState/EmptyState.js +44 -0
  188. package/dist/patterns/FileUpload/FileUpload.d.ts +87 -0
  189. package/dist/patterns/FileUpload/FileUpload.js +417 -0
  190. package/dist/patterns/FileUpload/FormFileUploadField.d.ts +19 -0
  191. package/dist/patterns/FileUpload/FormFileUploadField.js +117 -0
  192. package/dist/patterns/FileUpload/add-files.d.ts +26 -0
  193. package/dist/patterns/FileUpload/add-files.js +35 -0
  194. package/dist/patterns/FileUpload/file-size.d.ts +14 -0
  195. package/dist/patterns/FileUpload/file-size.js +44 -0
  196. package/dist/patterns/FormField/CheckboxField.d.ts +26 -0
  197. package/dist/patterns/FormField/CheckboxField.js +97 -0
  198. package/dist/patterns/FormField/FieldFrame.d.ts +85 -0
  199. package/dist/patterns/FormField/FieldFrame.js +257 -0
  200. package/dist/patterns/FormField/FormCheckboxField.d.ts +17 -0
  201. package/dist/patterns/FormField/FormCheckboxField.js +92 -0
  202. package/dist/patterns/FormField/FormRadioGroupField.d.ts +16 -0
  203. package/dist/patterns/FormField/FormRadioGroupField.js +97 -0
  204. package/dist/patterns/FormField/FormRatingField.d.ts +19 -0
  205. package/dist/patterns/FormField/FormRatingField.js +119 -0
  206. package/dist/patterns/FormField/FormSelectField.d.ts +16 -0
  207. package/dist/patterns/FormField/FormSelectField.js +91 -0
  208. package/dist/patterns/FormField/FormSliderField.d.ts +22 -0
  209. package/dist/patterns/FormField/FormSliderField.js +128 -0
  210. package/dist/patterns/FormField/FormSwitchField.d.ts +19 -0
  211. package/dist/patterns/FormField/FormSwitchField.js +88 -0
  212. package/dist/patterns/FormField/FormTextAreaField.d.ts +12 -0
  213. package/dist/patterns/FormField/FormTextAreaField.js +91 -0
  214. package/dist/patterns/FormField/FormTextField.d.ts +23 -0
  215. package/dist/patterns/FormField/FormTextField.js +103 -0
  216. package/dist/patterns/FormField/RadioGroupField.d.ts +38 -0
  217. package/dist/patterns/FormField/RadioGroupField.js +201 -0
  218. package/dist/patterns/FormField/SelectField.d.ts +43 -0
  219. package/dist/patterns/FormField/SelectField.js +211 -0
  220. package/dist/patterns/FormField/SwitchField.d.ts +27 -0
  221. package/dist/patterns/FormField/SwitchField.js +105 -0
  222. package/dist/patterns/FormField/TextAreaField.d.ts +37 -0
  223. package/dist/patterns/FormField/TextAreaField.js +134 -0
  224. package/dist/patterns/FormField/TextField.d.ts +51 -0
  225. package/dist/patterns/FormField/TextField.js +256 -0
  226. package/dist/patterns/FormField/error-message.d.ts +6 -0
  227. package/dist/patterns/FormField/error-message.js +8 -0
  228. package/dist/patterns/FormField/field-styles.d.ts +44 -0
  229. package/dist/patterns/FormField/field-styles.js +89 -0
  230. package/dist/patterns/FormField/field-types.d.ts +4 -0
  231. package/dist/patterns/FormField/use-field-ids.d.ts +18 -0
  232. package/dist/patterns/FormField/use-field-ids.js +53 -0
  233. package/dist/patterns/List/List.d.ts +38 -0
  234. package/dist/patterns/List/List.js +174 -0
  235. package/dist/patterns/MentionsInput/FormMentionsField.d.ts +18 -0
  236. package/dist/patterns/MentionsInput/FormMentionsField.js +124 -0
  237. package/dist/patterns/MentionsInput/MentionsInput.d.ts +57 -0
  238. package/dist/patterns/MentionsInput/MentionsInput.js +133 -0
  239. package/dist/patterns/MentionsInput/mention-text.d.ts +24 -0
  240. package/dist/patterns/MentionsInput/mention-text.js +31 -0
  241. package/dist/patterns/Menubar/Menubar.d.ts +22 -0
  242. package/dist/patterns/Menubar/Menubar.js +79 -0
  243. package/dist/patterns/NavigationMenu/NavigationMenu.d.ts +27 -0
  244. package/dist/patterns/NavigationMenu/NavigationMenu.js +104 -0
  245. package/dist/patterns/NumberField/FormNumberField.d.ts +18 -0
  246. package/dist/patterns/NumberField/FormNumberField.js +119 -0
  247. package/dist/patterns/NumberField/NumberField.d.ts +57 -0
  248. package/dist/patterns/NumberField/NumberField.js +242 -0
  249. package/dist/patterns/Pagination/Pagination.d.ts +31 -0
  250. package/dist/patterns/Pagination/Pagination.js +275 -0
  251. package/dist/patterns/Pagination/page-items.d.ts +18 -0
  252. package/dist/patterns/Pagination/page-items.js +40 -0
  253. package/dist/patterns/PhoneField/FormPhoneField.d.ts +22 -0
  254. package/dist/patterns/PhoneField/FormPhoneField.js +97 -0
  255. package/dist/patterns/PhoneField/PhoneField.d.ts +60 -0
  256. package/dist/patterns/PhoneField/PhoneField.js +448 -0
  257. package/dist/patterns/PhoneField/phone-value.d.ts +26 -0
  258. package/dist/patterns/PhoneField/phone-value.js +38 -0
  259. package/dist/patterns/QRCode/QRCode.d.ts +37 -0
  260. package/dist/patterns/QRCode/QRCode.js +120 -0
  261. package/dist/patterns/QRCode/qr-path.d.ts +7 -0
  262. package/dist/patterns/QRCode/qr-path.js +25 -0
  263. package/dist/patterns/ResizablePanels/ResizablePanels.d.ts +34 -0
  264. package/dist/patterns/ResizablePanels/ResizablePanels.js +175 -0
  265. package/dist/patterns/ResizablePanels/panel-sizes.d.ts +31 -0
  266. package/dist/patterns/ResizablePanels/panel-sizes.js +54 -0
  267. package/dist/patterns/RichTextEditor/FormRichTextField.d.ts +18 -0
  268. package/dist/patterns/RichTextEditor/FormRichTextField.js +118 -0
  269. package/dist/patterns/RichTextEditor/RichTextEditor.d.ts +71 -0
  270. package/dist/patterns/RichTextEditor/RichTextEditor.js +453 -0
  271. package/dist/patterns/SearchInput/SearchInput.d.ts +26 -0
  272. package/dist/patterns/SearchInput/SearchInput.js +98 -0
  273. package/dist/patterns/SideNav/SideNav.d.ts +50 -0
  274. package/dist/patterns/SideNav/SideNav.js +269 -0
  275. package/dist/patterns/Stat/Stat.d.ts +51 -0
  276. package/dist/patterns/Stat/Stat.js +292 -0
  277. package/dist/patterns/Stepper/Stepper.d.ts +35 -0
  278. package/dist/patterns/Stepper/Stepper.js +110 -0
  279. package/dist/patterns/TagGroup/TagGroup.d.ts +44 -0
  280. package/dist/patterns/TagGroup/TagGroup.js +151 -0
  281. package/dist/patterns/TagsInput/FormTagsInputField.d.ts +18 -0
  282. package/dist/patterns/TagsInput/FormTagsInputField.js +124 -0
  283. package/dist/patterns/TagsInput/TagsInput.d.ts +51 -0
  284. package/dist/patterns/TagsInput/TagsInput.js +97 -0
  285. package/dist/patterns/Timeline/Timeline.d.ts +29 -0
  286. package/dist/patterns/Timeline/Timeline.js +85 -0
  287. package/dist/patterns/Toolbar/Toolbar.d.ts +31 -0
  288. package/dist/patterns/Toolbar/Toolbar.js +105 -0
  289. package/dist/patterns/Tour/Tour.d.ts +38 -0
  290. package/dist/patterns/Tour/Tour.js +333 -0
  291. package/dist/patterns/TransferList/FormTransferListField.d.ts +19 -0
  292. package/dist/patterns/TransferList/FormTransferListField.js +117 -0
  293. package/dist/patterns/TransferList/TransferList.d.ts +53 -0
  294. package/dist/patterns/TransferList/TransferList.js +441 -0
  295. package/dist/patterns/TreeSelect/FormTreeSelectField.d.ts +28 -0
  296. package/dist/patterns/TreeSelect/FormTreeSelectField.js +88 -0
  297. package/dist/patterns/TreeSelect/TreeSelect.d.ts +49 -0
  298. package/dist/patterns/TreeSelect/TreeSelect.js +375 -0
  299. package/dist/patterns/TreeView/TreeView.d.ts +40 -0
  300. package/dist/patterns/TreeView/TreeView.js +296 -0
  301. package/dist/provider/DesignSystemProvider.d.ts +54 -0
  302. package/dist/provider/DesignSystemProvider.js +270 -0
  303. package/dist/provider/nonce.d.ts +7 -0
  304. package/dist/provider/nonce.js +13 -0
  305. package/dist/styles.css +2 -0
  306. package/dist/theme/chart-palette.d.ts +51 -0
  307. package/dist/theme/chart-palette.js +112 -0
  308. package/dist/theme/create-theme.d.ts +52 -0
  309. package/dist/theme/create-theme.js +75 -0
  310. package/dist/theme/style-element.d.ts +28 -0
  311. package/dist/theme/style-element.js +79 -0
  312. package/dist/theme/tenant-branding.d.ts +48 -0
  313. package/dist/theme/tenant-branding.js +65 -0
  314. package/dist/theme/theme-switch.d.ts +25 -0
  315. package/dist/theme/theme-switch.js +90 -0
  316. package/dist/theme/token-names.d.ts +3 -0
  317. package/dist/theme/token-names.js +166 -0
  318. package/dist/theme.css +241 -0
  319. package/dist/tokens.css +383 -0
  320. package/dist/types/direction.d.ts +4 -0
  321. package/dist/types/tone.d.ts +7 -0
  322. package/dist/utils/cn.d.ts +7 -0
  323. package/dist/utils/cn.js +50 -0
  324. package/dist/utils/first-field.d.ts +8 -0
  325. package/dist/utils/first-field.js +10 -0
  326. package/dist/utils/layout.d.ts +33 -0
  327. package/dist/utils/layout.js +30 -0
  328. package/dist/utils/popup.d.ts +12 -0
  329. package/dist/utils/popup.js +27 -0
  330. package/docs/accessibility.md +61 -0
  331. package/docs/advanced-components.md +38 -0
  332. package/docs/ai-assistants.md +44 -0
  333. package/docs/architecture.md +65 -0
  334. package/docs/browser-support.md +30 -0
  335. package/docs/charts.md +56 -0
  336. package/docs/components.md +2928 -0
  337. package/docs/conventions.md +19 -0
  338. package/docs/customization.md +79 -0
  339. package/docs/dates-files-data.md +48 -0
  340. package/docs/design-principles.md +50 -0
  341. package/docs/faq.md +68 -0
  342. package/docs/forms.md +114 -0
  343. package/docs/getting-started.md +64 -0
  344. package/docs/icons.md +48 -0
  345. package/docs/internationalization.md +64 -0
  346. package/docs/layout-and-navigation.md +51 -0
  347. package/docs/nextjs.md +69 -0
  348. package/docs/releasing.md +40 -0
  349. package/docs/testing.md +242 -0
  350. package/docs/theming.md +118 -0
  351. package/docs/typescript.md +62 -0
  352. package/llms-full.txt +4573 -0
  353. package/llms.txt +52 -0
  354. package/package.json +193 -6
package/llms-full.txt ADDED
@@ -0,0 +1,4573 @@
1
+ # @primecoderin/fast-ui-react 1.0.0: full documentation
2
+
3
+ > A React 19 design system on Base UI and Tailwind CSS 4. This file holds the guides and the component reference in one document.
4
+
5
+ - Import from `@primecoderin/fast-ui-react`. Form fields bound to react-hook-form come from `@primecoderin/fast-ui-react/forms`, charts from `@primecoderin/fast-ui-react/charts`, the rich text editor from `@primecoderin/fast-ui-react/editor` and `@primecoderin/fast-ui-react/editor-forms`. Plain form fields (`TextField`, `SelectField` ...) are in the main entry and need no form library.
6
+ - Import `@primecoderin/fast-ui-react/styles.css` once at the app's entry and wrap the app in `DesignSystemProvider`. The app needs no Tailwind and no font of its own.
7
+ - Components hold no text of their own: every string a user reads (labels, hints, error messages, button names) is a prop, so pass the app's translated text. Give an icon-only control an `aria-label`.
8
+ - Props follow `value` / `onValueChange`, `checked` / `onCheckedChange`, `open` / `onOpenChange`. Use `aria-label`, never `ariaLabel`.
9
+ - Style with tokens, not colour values: `bg-primary`, `text-fg-secondary`, `border-line`. Tailwind's own palette (`bg-red-500`) and type scale are switched off.
10
+ - Components are Client Components (they start with "use client"), so Server Components can import them. The pure helpers (`createTheme`, `cn`) are safe in Server Components.
11
+ - Do not invent props or exports: check `components.md` (or the MCP server's `get_export`) for the real ones.
12
+
13
+ # Getting started
14
+
15
+ ```bash
16
+ npm install @primecoderin/fast-ui-react
17
+ ```
18
+
19
+ The package needs React 19 in the app (`react` and `react-dom`, which a React app already has). Everything else,
20
+ Base UI included, comes with it. Three features live in their own entries, so an app that does not use them never
21
+ installs, downloads or bundles what they need:
22
+
23
+ | You use | Import from | Also install |
24
+ | --- | --- | --- |
25
+ | Components, patterns, theming | `@primecoderin/fast-ui-react` | nothing |
26
+ | Form fields bound to react-hook-form (Forms (the "Forms" section)) | `@primecoderin/fast-ui-react/forms` | `react-hook-form` 7.91 or later 7.x |
27
+ | Charts (Charts (the "Charts" section)) | `@primecoderin/fast-ui-react/charts` | `recharts` 3.11 or later 3.x |
28
+ | The rich text editor (Advanced components (the "Advanced components" section)) | `@primecoderin/fast-ui-react/editor` | `@tiptap/core @tiptap/pm @tiptap/react @tiptap/starter-kit`, 3.35 or later 3.x |
29
+ | The rich text editor as a form field | `@primecoderin/fast-ui-react/editor-forms` | the TipTap packages and `react-hook-form` |
30
+
31
+ These are optional peer dependencies with those ranges (`peerDependencies` in `package.json`): an app on Recharts 2
32
+ or TipTap 2 gets a peer-dependency warning from npm and must upgrade to use that entry.
33
+
34
+ **1. Import the stylesheet once**, at the app's entry. It carries the font, the tokens, the base rules and every
35
+ Tailwind class the components use, so the app needs no Tailwind and no font of its own:
36
+
37
+ ```ts
38
+ import "@primecoderin/fast-ui-react/styles.css";
39
+ ```
40
+
41
+ The font is Inter, served from the package's own files (`dist/fonts/`): no `<link>` to add and no request to
42
+ another site, so a Content-Security-Policy of `font-src 'self'` allows it. One variable file per character set
43
+ covers every weight, and a browser downloads only the files whose characters a page shows (47 KB for English), and
44
+ none if the app sets another font with `createTheme`. A right-to-left page uses Arial instead, since Inter has no
45
+ Hebrew or Arabic. The font's licence (SIL Open Font License) ships next to it.
46
+
47
+ **2. Wrap the app in the provider.** It sets `data-theme` and `dir` on `<html>`, applies tenant branding, and
48
+ hosts the toaster and the shared tooltip delay.
49
+
50
+ ```tsx
51
+ import { Button, DesignSystemProvider } from "@primecoderin/fast-ui-react";
52
+
53
+ export const App = () => (
54
+ <DesignSystemProvider themeMode="light" direction="ltr">
55
+ <Button variant="primary">Save</Button>
56
+ </DesignSystemProvider>
57
+ );
58
+ ```
59
+
60
+ ## Vite and other frameworks
61
+
62
+ - **Vite** needs no plugin and no configuration: the same three steps. The package's own Storybook runs on Vite.
63
+ - **Next.js** has its own page (the "Next.js" section).
64
+ - **React Router, Remix, TanStack Start, Astro and others** are not tested yet. The package is ESM, ships plain CSS
65
+ and starts its components with `"use client"`, so any React 19 app whose bundler imports a `.css` file should work.
66
+ Please report a problem with the framework and its version.
67
+
68
+ ## Next steps
69
+
70
+ - **Your brand and fonts:** Theme, branding and tokens (the "Theme, branding and tokens" section).
71
+ - **Next.js:** Next.js (the "Next.js" section) (Server Components, `"use client"`, App Router and Pages Router).
72
+ - **Forms:** Forms (the "Forms" section), plain fields and react-hook-form fields.
73
+ - **Styling one component:** Styling and customization (the "Styling and customization" section); types: TypeScript (the "TypeScript" section).
74
+ - **Every component, with its props:** Components (the Components reference below).
75
+ - **Right to left, translation, accessibility:** Internationalization (the "Internationalization" section), Accessibility (the "Accessibility" section).
76
+ - **Something not working:** Troubleshooting and FAQ (the "Troubleshooting and FAQ" section).
77
+
78
+ ---
79
+
80
+ # Next.js
81
+
82
+ The package works in the App Router and the Pages Router, with Turbopack or webpack. Every component module is
83
+ marked `"use client"`, so a Server Component imports components directly; the pure helpers (`createTheme`,
84
+ `cn`, `FAST_ICONS`, `TOKEN_NAMES`) are not, so a Server Component can call them too:
85
+
86
+ ```tsx
87
+ // app/layout.tsx: a Server Component
88
+ import type { ReactNode } from "react";
89
+ import "@primecoderin/fast-ui-react/styles.css";
90
+ import { createTheme, DesignSystemProvider } from "@primecoderin/fast-ui-react";
91
+
92
+ const theme = createTheme({ branding: { primary: "#6d28d9", onPrimary: "#fff" } });
93
+
94
+ export default function RootLayout({ children }: { children: ReactNode }) {
95
+ return (
96
+ <html lang="en" dir="ltr">
97
+ <body>
98
+ <DesignSystemProvider themeMode="light" direction="ltr" theme={theme}>
99
+ {children}
100
+ </DesignSystemProvider>
101
+ </body>
102
+ </html>
103
+ );
104
+ }
105
+ ```
106
+
107
+ - **Event handlers stay on the client.** A component that passes `onValueChange` or `onClick` is rendered from a
108
+ Client Component file, as in any Next.js app; a Server Component can render one that takes only data.
109
+ - **Put `dir` on `<html>` in the layout** as well as on the provider, so the server's HTML is already right to
110
+ left. Without the steps below, the provider sets `data-theme` and the theme's `<style>` when the page hydrates,
111
+ so until then the page shows the default light theme and colours.
112
+
113
+ ## No flash of the wrong theme
114
+
115
+ The server knows the user's choice if the app keeps it in a cookie. Render it on `<html>`, and render the theme's
116
+ stylesheet in `<head>` under the id the provider uses; the provider then finds both already right and changes
117
+ nothing when it hydrates:
118
+
119
+ ```tsx
120
+ // app/layout.tsx
121
+ import type { ReactNode } from "react";
122
+ import { cookies } from "next/headers";
123
+ import { createTheme, DesignSystemProvider, THEME_STYLE_ID } from "@primecoderin/fast-ui-react";
124
+
125
+ export default async function RootLayout({ children }: { children: ReactNode }) {
126
+ const mode = (await cookies()).get("theme")?.value === "dark" ? "dark" : "light";
127
+ const theme = createTheme(await loadTenantTheme()); // the app's own loader: the tenant's ThemeDefinition
128
+ return (
129
+ <html lang="en" dir="ltr" data-theme={mode}>
130
+ <head>
131
+ <style id={THEME_STYLE_ID} dangerouslySetInnerHTML={{ __html: theme.css }} />
132
+ </head>
133
+ <body>
134
+ <DesignSystemProvider themeMode={mode} direction="ltr" theme={theme}>
135
+ {children}
136
+ </DesignSystemProvider>
137
+ </body>
138
+ </html>
139
+ );
140
+ }
141
+ ```
142
+
143
+ `theme.css` is safe to write into the page: `createTheme` keeps only known token names and drops any value that
144
+ could leave its declaration (see Theme, branding and tokens (the "Theme, branding and tokens" section)). Under a nonce-based
145
+ Content-Security-Policy, give the `<style>` the same `nonce` as the provider. For `themeMode="system"`, the server
146
+ cannot know the system's setting; a small inline script in `<head>` (with the nonce) can set `data-theme` from
147
+ `matchMedia("(prefers-color-scheme: dark)")` before the first paint.
148
+ - **In the Pages Router**, import the stylesheet and wrap the app in the provider in `pages/_app.tsx`.
149
+
150
+ ---
151
+
152
+ # Theme, branding and tokens
153
+
154
+ `DesignSystemProvider` takes these props:
155
+
156
+ | Prop | Type | What it does |
157
+ | --- | --- | --- |
158
+ | `themeMode` | `"light"` \| `"dark"` \| `"system"` | The colour theme. `"system"` follows the operating system's setting and changes with it. The app keeps a user's own choice; the provider stores nothing. |
159
+ | `direction` | `"ltr"` \| `"rtl"` | The text direction (`dir` on `<html>`). |
160
+ | `theme` | `Theme` | A theme made with `createTheme` (below): the primary colour and any other design token. |
161
+ | `branding` | `TenantBranding` | Only the primary colour, with the shades derived from it. `createTheme`'s `branding` is the same object; use one of the two. |
162
+ | `toastLabels` | `ToastLabelsInput` | The toasts' titles and dismiss text, in the user's language. Any left out are in English. |
163
+ | `nonce` | `string` | The page's Content-Security-Policy nonce (below). |
164
+
165
+ **`createTheme`** sets the primary colour and any design token, for both themes or for one. Make the theme
166
+ once, at module level, and pass it to the provider:
167
+
168
+ ```tsx
169
+ import { createTheme, DesignSystemProvider } from "@primecoderin/fast-ui-react";
170
+
171
+ const theme = createTheme({
172
+ branding: { primary: "#6d28d9", onPrimary: "#fff" }, // the primary colour; its shades are derived
173
+ tokens: { "font-family": "Georgia, serif" }, // both themes
174
+ light: { surface: "#faf8ff" }, // the light theme only
175
+ dark: { surface: "#17122b" }, // the dark theme only
176
+ });
177
+
178
+ export const App = () => (
179
+ <DesignSystemProvider themeMode="system" direction="ltr" theme={theme}>
180
+ {/* ... */}
181
+ </DesignSystemProvider>
182
+ );
183
+ ```
184
+
185
+ - **Token names** are the `--fast-*` variables in the package's `dist/tokens.css` without the prefix: colours
186
+ (`surface`, `fg-secondary`, `tone-error-solid`), the font (`font-family`), radii (`radius-md`), shadows
187
+ (`shadow-card`) and the type scale (`text-body`, `text-body-line-height`, `text-h1-font-weight`). They are typed, so the editor completes them and a typo does not compile; `TOKEN_NAMES`
188
+ lists them at run time. Storybook's Colors page shows the colour tokens.
189
+ - **What is left out.** A name that is not a token, or a value that could leave its declaration (it holds `;`,
190
+ a brace, a comment, `url()` or `image()`, or an unclosed quote or bracket), is dropped, and the rest of the
191
+ theme still applies. `theme.ignored` lists what was dropped, such as `"light.surfce"`, so data that arrives at run time can be checked.
192
+ - **What follows the primary.** The ramp of fills, hovers, links and focus, and also selected rows, row hover and the
193
+ info card. The success, warning, error and info tones stay as they are, so a red or green brand never looks like
194
+ an error or a success.
195
+ - **On unmount** the provider puts back the `dir` and `data-theme` the page had before it.
196
+ - **Which wins.** `light` and `dark` beat `tokens`, and the theme beats `branding`: set a token in one place.
197
+ A theme also beats the stylesheet's right-to-left rule, so a `font-family` in `tokens`, `light` or `dark`
198
+ replaces the Arial the design system uses on right-to-left pages: give a font that covers the page's script, or
199
+ keep Arial after it in the list (`"Georgia, Arial, serif"`).
200
+ - **Another font is the app's to load.** The package ships Inter only; an app that sets another `font-family`
201
+ loads that font itself (a `<link>`, its own `@font-face`, or a Fontsource package).
202
+ - **White label.** A tenant's look is one `createTheme` call: the primary colour, any other colour, the font,
203
+ the corner radii, the shadows and the type scale, made from data fetched for the tenant at run time.
204
+
205
+ ## Changing it at run time
206
+
207
+ Everything the provider takes can change while the app runs, with no reload and no rebuild:
208
+
209
+ ```tsx
210
+ const theme = useMemo(
211
+ () => createTheme({ branding: { primary }, tokens: { "font-family": font } }),
212
+ [primary, font],
213
+ );
214
+
215
+ <DesignSystemProvider themeMode={mode} direction={direction} theme={theme}>
216
+ ```
217
+
218
+ - **Colours and font.** Pass a new `theme` (or `branding`): a colour the user picked, a font, the tenant fetched
219
+ after sign-in. The provider rewrites its one `<style>` element in place. The variables live on `<html>`, so every
220
+ component, popups in `<body>` included, takes the new values at once, and the charts measure their axes again
221
+ for a new font. The provider compares the CSS text, so a theme rebuilt with the same values costs nothing.
222
+ - **Light and dark.** Change `themeMode`; the switch cross-fades where the browser supports view transitions and
223
+ the visitor has not asked for reduced motion.
224
+ - **Direction.** Change `direction`; see Internationalization (the "Internationalization" section).
225
+
226
+ ## Several tenants
227
+
228
+ One provider sets the page's look, so a page shows one tenant at a time: a multi-tenant app builds the theme from
229
+ the signed-in tenant's data. That data is checked (unknown token names and unsafe values are dropped and listed in
230
+ `theme.ignored`), but not judged:
231
+
232
+ - **Contrast is the tenant's.** `onPrimary`, the text on the primary fill, is not derived from the primary colour:
233
+ it stays the default dark text unless given, so a dark primary needs `onPrimary: "#fff"`. Nothing checks that a
234
+ tenant's colours are readable.
235
+ - **Not every value is a token.** Colours, the font, the type scale, radii, shadows and the layout sizes are; the
236
+ spacing scale, the focus ring's width and the animation timings are not.
237
+
238
+ ## A Content-Security-Policy nonce
239
+
240
+ A policy that allows inline styles only by nonce (`style-src 'nonce-…'`, without `'unsafe-inline'`) blocks every
241
+ `<style>` element that has no nonce. Pass the page's nonce to the provider, at run time, from wherever the
242
+ server puts it:
243
+
244
+ ```tsx
245
+ <DesignSystemProvider themeMode="light" direction="ltr" theme={theme} nonce={nonce}>
246
+ ```
247
+
248
+ The nonce goes on every `<style>` and `<script>` the design system adds: Base UI's own, and the provider's
249
+ (the theme, the branding, and the instant theme switch). `applyTheme`, `applyTenantBranding`,
250
+ `applyThemeMode` and `applyThemePreference` take it too, for an app that calls them without the provider.
251
+
252
+ ## An app that runs its own Tailwind 4
253
+
254
+ An app that writes its own classes with the design system's tokens (`bg-primary`, `text-fg-secondary`,
255
+ `rounded-tile`) imports the foundation instead of the ready-made stylesheet, and tells Tailwind to scan the
256
+ package for the classes the components use:
257
+
258
+ ```css
259
+ @layer theme, base, components, utilities;
260
+
261
+ @import "tailwindcss/theme.css" layer(theme);
262
+ @import "tailwindcss/utilities.css" layer(utilities) source("../");
263
+ @import "@primecoderin/fast-ui-react/foundation.css";
264
+ @source "../node_modules/@primecoderin/fast-ui-react/dist";
265
+ ```
266
+
267
+ The foundation empties Tailwind's own colour, type, radius and shadow scales, so `bg-red-500` or `text-lg`
268
+ generate nothing: only the design system's tokens exist. It brings the font too (`fonts.css`, the same Inter files
269
+ as the ready-made stylesheet), which the app's bundler copies from the package like any other asset.
270
+
271
+ ---
272
+
273
+ # Prop conventions
274
+
275
+ Every component follows the same few rules, so one you have not used yet works like the ones you have:
276
+
277
+ | What | Props | Examples |
278
+ | --- | --- | --- |
279
+ | A value the user picks | `value` + `onValueChange` | `Tabs`, `SegmentedControl`, `TextField`, `SelectField`, `RadioGroupField`, `PhoneField`, `Combobox`, `MultiSelect`, `Slider`, `NumberField`, `Rating`, `ColorPicker`, `DateTimePicker`, `SearchInput`, `TreeSelect`, `MenuRadioGroup`, `OtpInput` |
280
+ | On or off | `checked` + `onCheckedChange` | `CheckboxBox`, `CheckboxField`, `SwitchField`, `FormCheckboxField`, `FormSwitchField` |
281
+ | Pressed or not | `pressed` + `onPressedChange` (a group: `value` + `onValueChange`, an array) | `ToggleButton`, `ToggleGroup` |
282
+ | A popup's state | `open` + `onOpenChange` | `Dialog`, `Drawer` |
283
+ | The accessible name, where there is no visible label | `aria-label` | `Tabs`, `SegmentedControl`, `DataTable`, `Popover`, `StatGroup` |
284
+ | Text the user reads | a prop (`label`, `labels`, `title`), never built in | every component |
285
+
286
+ **Controlled or not.** A component with a `value` (or `checked`, `open`) is controlled: you hold the state and update it
287
+ in the handler. Where a component can also keep its own state, it takes a `defaultValue` (or `defaultOpen`) instead:
288
+ `Accordion` and `Collapsible` do; the form fields are always controlled. Check a component's props in the
289
+ component reference (the Components reference below). A controlled field works with any form library.
290
+
291
+ A handler receives the new value itself (`onValueChange("active")`), not an event.
292
+
293
+ ---
294
+
295
+ # Design principles
296
+
297
+ The components and design tokens that interfaces are built from: colour, type, spacing, radius, shadows
298
+ and icons, and the controls and patterns made of them. Every example here uses sample data.
299
+
300
+
301
+ ## Built on
302
+
303
+ **Base UI** provides the accessible, unstyled behaviour; **Tailwind CSS 4** does all the styling;
304
+ **CVA** (class-variance-authority) defines the variants; **`cn()`** (clsx with tailwind-merge) merges class
305
+ names; the icons are **lucide**.
306
+
307
+ ## Principles
308
+
309
+ - **Tokens, never colour values.** Colours are utilities such as `bg-primary`, `text-fg-secondary`,
310
+ `border-line` and the tone roles (`bg-success-tint`, `text-error-text`). Tailwind's own palette, type,
311
+ radius and shadow scales are switched off, so `bg-red-500` or `text-lg` produces nothing.
312
+ - **Canonical Tailwind classes.** `w-4`, not `w-[16px]`; `bg-(--x)`, not `bg-[--x]`.
313
+ - **Variants with CVA, merging with `cn()`.** A component that draws one surface takes `className` and
314
+ merges it last, so the caller can place it or override a default. Compositions that own their layout
315
+ (form fields, dialogs, menus) take none: wrap them to place them.
316
+ - **State is styled with data attributes**: `data-checked:`, `data-disabled:`, `data-highlighted:`,
317
+ `data-popup-open:`, `data-invalid:`, `data-starting-style:`, `data-ending-style:`.
318
+ - **Presentation only.** Components hold no copy of their own: every text a user reads arrives through props
319
+ (labels, `PaginationLabels`, `ToastLabels`, `PhoneFieldLabels`), so the caller translates it.
320
+ - **Form fields are controlled, and bind to react-hook-form on request.** A plain field (`TextField`,
321
+ `SelectField`, ...) takes `value` and `onValueChange` and the validation message as `errorMessage`, so it works
322
+ with any form library or none. Its `Form*` twin in `/forms` takes the form's `control` and a field `name`; the
323
+ caller's `formatError` turns a stored validation message into the text shown.
324
+
325
+ ## Accessibility
326
+
327
+ - Text meets WCAG AA contrast (4.5:1, large text 3:1) in both themes. Where the brand teal is too pale for
328
+ text, its darker `-text` shade is used, and text on the teal fill is dark.
329
+ - Every control works from the keyboard: Tab and Shift+Tab move between controls, Enter or Space activates,
330
+ the arrow keys move inside menus, lists, tabs and radio groups, and Escape closes a popup and returns
331
+ focus to what opened it.
332
+ - The focus ring (`ring-focus`) shows for keyboard focus only.
333
+ - Dialogs and panels keep focus inside while open and start in their first field.
334
+ - Labels, hints and error messages are tied to their control, and errors are announced as they appear.
335
+ - A control with no visible text needs an accessible name (`aria-label`), and decorative icons are hidden
336
+ from assistive technology.
337
+
338
+ ## Responsive behaviour
339
+
340
+ Layouts change at Tailwind's `sm` breakpoint (640px), and the app shell's navigation at `md` (768px). Below `sm`, a `StatGroup` stacks its stats, and dialogs and drawers
341
+ take the width of the screen less a small margin. Right to left mirrors every layout through logical
342
+ utilities (`ps-*`, `ms-*`, `inset-s-*`, `text-start`); `rtl:` is only for a glyph or a slide that must flip.
343
+
344
+ ---
345
+
346
+ # Styling and customization
347
+
348
+ From the broadest change to the narrowest: the theme, a token in one place, a class on one element, a wrapper.
349
+
350
+ ## 1. The theme: every component at once
351
+
352
+ `createTheme` sets the primary colour, the font, the radii or any other token for the whole app or for one tenant.
353
+ This is the way to apply a brand; it needs no CSS. See Theme, branding and tokens (the "Theme, branding and tokens" section).
354
+
355
+ ## 2. A token: one value, wherever it is used
356
+
357
+ Every colour, size and radius is a CSS variable (`--fast-primary`, `--fast-surface` ...) that the components read
358
+ through Tailwind utilities (`bg-primary`, `text-fg-secondary`, `border-line`). Change a variable on an element and
359
+ what reads that variable inside it follows:
360
+
361
+ ```css
362
+ .billing-section {
363
+ --fast-primary: #6d28d9;
364
+ --fast-primary-hover: #5b21b6;
365
+ --fast-primary-active: #4c1d95;
366
+ --fast-primary-text: #5b21b6;
367
+ --fast-focus: #6d28d9;
368
+ }
369
+ ```
370
+
371
+ Two limits apply to a variable set on an element rather than through `createTheme`:
372
+
373
+ - **Each shade is its own variable.** `--fast-primary` is only the fill: hover, pressed, light, pale, text and the
374
+ focus ring are separate tokens, so set each one the section uses (the list above covers buttons and links).
375
+ Tokens derived from others at the root (`selected`, `surface-hover`, the shadows, `chart-1`) keep the page's value.
376
+ `createTheme`'s `branding` derives the whole ramp from one colour, but for the whole page.
377
+ - **Popups are outside the element.** Menus, dialogs, popovers, tooltips and toasts render at the end of `<body>`,
378
+ so they keep the page's values.
379
+
380
+ The variables, their groups and the utilities that read them are listed in `llms-full.txt` (see
381
+ AI coding assistants (the "AI coding assistants" section)) and in the package's `dist/tokens.css`.
382
+
383
+ ## 3. A class on one element
384
+
385
+ A component that draws a single surface (`Button`, `Card`, `Avatar`, `Stat` ...) accepts `className` and merges it
386
+ last, with `cn()` (clsx and tailwind-merge), so your class wins over the component's own:
387
+
388
+ ```tsx
389
+ <Button variant="primary" className="w-full">Save</Button>
390
+ ```
391
+
392
+ - **Use the design system's utilities.** Tailwind's own palette, type, radius and shadow scales are switched off, so
393
+ `bg-red-500` or `text-lg` produces nothing; use `bg-error-tint`, `text-body-sm` and the other token names.
394
+ - **An app that imports `styles.css` has no Tailwind of its own.** A utility the components do not already use is
395
+ not in the stylesheet. Write the CSS yourself, or run Tailwind 4 in the app with `foundation.css`
396
+ (see Theme, branding and tokens (the "Theme, branding and tokens" section)).
397
+ - **Compositions take no `className`.** A component that owns its layout (form fields, dialogs, menus, the date
398
+ picker) does not expose its inner parts: wrap it and place the wrapper.
399
+ - A component's props table in the component reference (the Components reference below) says whether it takes `className`, `style`
400
+ and the attributes of the element it renders.
401
+
402
+ ## 4. Variants
403
+
404
+ Variants are props (`variant`, `size`, `tone`), defined with [CVA](https://cva.style). The values are in the props
405
+ table and in the component's stories. A variant that does not exist is a type error, not a silent fallback.
406
+
407
+ ## 5. State
408
+
409
+ Components mark their state with data attributes: `data-checked`, `data-disabled`, `data-highlighted`,
410
+ `data-popup-open`, `data-invalid`, `data-starting-style`, `data-ending-style`. A wrapper's CSS can target them,
411
+ and Tailwind reads them as variants (`data-checked:bg-primary`). Do not use them in tests: assert a state through
412
+ its ARIA attribute (see Testing (the "Testing with Playwright" section)).
413
+
414
+ ## 6. Composing
415
+
416
+ - **Wrap, do not fork.** A `PrimaryButton` that fixes two props and passes the rest is a three-line component.
417
+ - **Build your own with the same parts.** `cn()` and the tokens are exported; a custom component that uses them looks
418
+ and themes like the rest. A component that needs the app's translations, routing or data belongs in the app.
419
+ - **Icons.** The icons are [lucide](https://lucide.dev); pass any React element as an `icon` prop.
420
+
421
+ ## Animation
422
+
423
+ Components animate with CSS transitions and Base UI's `data-starting-style` / `data-ending-style` states. All motion
424
+ stops for a visitor who asks for reduced motion, through one rule in the stylesheet.
425
+
426
+ ---
427
+
428
+ # Icons
429
+
430
+ The icons are [lucide](https://lucide.dev), through `lucide-react`, which is a dependency of the package: an app that
431
+ imports icons from it shares the copy.
432
+
433
+ ## Passing an icon to a component
434
+
435
+ Components that take an icon (`Button`, `MenuItem`, `IconTile`, `Stat`, `EmptyState`, `Dialog`, `Drawer`, `ToggleButton` ...) take a React element in
436
+ an `icon` prop, and size it by font size:
437
+
438
+ ```tsx
439
+ import { Plus } from "lucide-react";
440
+ import { Button } from "@primecoderin/fast-ui-react";
441
+
442
+ <Button icon={<Plus />}>Add</Button>;
443
+ ```
444
+
445
+ - **Icons are decorative.** The component hides them from assistive technology. A control that shows only an icon
446
+ needs an `aria-label`: `<Button variant="icon" icon={<Plus />} aria-label="Add" />`.
447
+ - **Colour follows the text** (`currentColor`), so an icon takes the control's colour in every theme and state.
448
+ - Any React element works, so a different icon library or an inline SVG does too.
449
+
450
+ ## One icon for each thing
451
+
452
+ `FAST_ICONS` names one icon for each thing an interface shows (`search`, `filter`, `add`, `edit`, `delete`, `download`,
453
+ `calendar`, `settings`, `check`, `warning`, `error`, `info` ...), so the same thing has the same icon on every
454
+ screen. Take an icon from it before picking one; `FastIconName` is the union of the names:
455
+
456
+ ```tsx
457
+ import { FAST_ICONS, type FastIconName } from "@primecoderin/fast-ui-react";
458
+
459
+ const SearchIcon = FAST_ICONS.search;
460
+ const name: FastIconName = "search";
461
+ ```
462
+
463
+ `FAST_ICONS` covers three general groups: common navigation (`dashboard`, `home`, `analytics`, `billing`, `users`,
464
+ `settings` ...), actions (`search`, `filter`, `add`, `edit`, `delete`, `download`, `calendar`, `arrow`) and status
465
+ (`bolt`, `check`, `close`, `warning`, `error`, `info`). Import directly from `lucide-react` for anything else.
466
+
467
+ ## Right to left
468
+
469
+ lucide's icons do not mirror. An icon that means a direction (`arrow`, a chevron that means "next") must flip in a
470
+ right-to-left layout: add `rtl:rotate-180`, as the calendar's arrows do. See Internationalization (the "Internationalization" section).
471
+
472
+ ## Size
473
+
474
+ An icon is sized by the font size of the component it sits in, so it scales with the type. To size one yourself,
475
+ give it a Tailwind size utility the stylesheet has (`size-4` is 16px; see Styling and customization (the "Styling and customization" section)).
476
+
477
+ ---
478
+
479
+ # TypeScript
480
+
481
+ The package ships its own declarations (`dist/**/*.d.ts`) and needs no `@types` package.
482
+
483
+ ## Prop types
484
+
485
+ Each component exports its props type under the name `<Component>Props`, together with the unions its props use
486
+ (`ButtonVariant`, `AlertTone` ...):
487
+
488
+ ```ts
489
+ import type { ButtonProps, ButtonVariant } from "@primecoderin/fast-ui-react";
490
+
491
+ const variant: ButtonVariant = "primary";
492
+ const props: ButtonProps = { variant, children: "Save" };
493
+ ```
494
+
495
+ A component that renders an element accepts that element's attributes (a `Button` takes everything a `<button>`
496
+ does), minus the few the design system owns. The component reference (the Components reference below) lists what each takes.
497
+
498
+ To get the props of a component without importing its type, use React's helper:
499
+ `type Props = React.ComponentProps<typeof Button>`.
500
+
501
+ ## Strictness
502
+
503
+ Optional props are declared `| undefined`, so the types work with `exactOptionalPropertyTypes: true`: passing
504
+ `undefined` to an optional prop is allowed. A unit test (`tests/unit/optional-props.test.ts`) checks every optional
505
+ property in the source, so a new prop cannot forget it.
506
+
507
+ ## Form fields
508
+
509
+ The react-hook-form fields are generic over the form's values, so `name` is checked against them:
510
+
511
+ ```tsx
512
+ import { useForm } from "react-hook-form";
513
+ import { FormTextField } from "@primecoderin/fast-ui-react/forms";
514
+
515
+ interface Values {
516
+ email: string;
517
+ }
518
+
519
+ export function EmailForm() {
520
+ const { control } = useForm<Values>();
521
+ return <FormTextField control={control} name="email" label="Email" />; // name: "email" only
522
+ }
523
+ ```
524
+
525
+ The types are `Form<Field>FieldProps<Values>`. The plain fields (`TextField` ...) need no generics:
526
+ `value` and `onValueChange` carry the type.
527
+
528
+ ## Theme and tokens
529
+
530
+ - `TokenName` is the union of every token's name (generated from `tokens.css`), and `TokenValues` the object of
531
+ values `createTheme` takes, so a misspelled token is a type error.
532
+ - `DesignSystemProviderProps` types the provider's props; `ThemePreference` (`"light" | "dark" | "system"`) its
533
+ `themeMode`, `TextDirection` its `direction`, `TenantBranding` its `branding` and `Theme` (made by `createTheme` from a
534
+ `ThemeDefinition`) its `theme`. `ThemeMode` is the resolved `"light" | "dark"`.
535
+
536
+ ## Entries and module settings
537
+
538
+ The package is ESM only and has five entries (see Getting started (the "Getting started" section)). Use
539
+ `"moduleResolution": "bundler"` (or `"node16"` / `"nodenext"`), which resolve the `exports` map; the old `"node"`
540
+ (node10) setting does not.
541
+
542
+ ---
543
+
544
+ # Forms
545
+
546
+ Every form field comes in two forms. The **plain field** is in the main entry and works with any form library or
547
+ none: it is controlled, taking `value` and `onValueChange` (`checked` and `onCheckedChange` for a checkbox or
548
+ switch), and the validation message as `errorMessage`. The **bound field** is in the `/forms` entry and takes a
549
+ react-hook-form `control` and a `name` instead; it renders the plain field. An app that does not use
550
+ react-hook-form never loads it.
551
+
552
+ | Plain field (main entry) | Bound to react-hook-form (`/forms`) |
553
+ | --- | --- |
554
+ | `TextField` | `FormTextField` |
555
+ | `TextAreaField` | `FormTextAreaField` |
556
+ | `SelectField` | `FormSelectField` |
557
+ | `CheckboxField` | `FormCheckboxField` |
558
+ | `SwitchField` | `FormSwitchField` |
559
+ | `RadioGroupField` | `FormRadioGroupField` |
560
+ | `PhoneField` | `FormPhoneField` |
561
+ | `DateTimePicker` | `FormDateTimeField` |
562
+ | `TreeSelect` | `FormTreeSelectField` |
563
+
564
+ These inputs are **bare controls**, like `DateTimePicker` and `TreeSelect`: the box alone, without a label,
565
+ hint or message. Each has a bound field in `/forms` that adds them.
566
+
567
+ | Bare control (main entry) | Bound to react-hook-form (`/forms`) | The value |
568
+ | --- | --- | --- |
569
+ | `Combobox` | `FormComboboxField` | the chosen option's `value`, or `""` |
570
+ | `Autocomplete` | `FormAutocompleteField` | the text |
571
+ | `MultiSelect` | `FormMultiSelectField` | an array of the chosen options' `value`s |
572
+ | `TagsInput` | `FormTagsInputField` | an array of the tags |
573
+ | `NumberField` | `FormNumberField` | a number, or `null` while empty |
574
+ | `Slider` | `FormSliderField` | a number, or an array of numbers for a range |
575
+ | `Rating` | `FormRatingField` | a number from 0 (none) to the number of stars |
576
+ | `ColorPicker` | `FormColorField` | the colour as `"#rrggbb"`, or `""` |
577
+ | `DateRangePicker` | `FormDateRangeField` | `{ start, end }`, `"yyyy-MM-dd"` each |
578
+ | `FileUpload` | `FormFileUploadField` | an array of `File`s |
579
+ | `TransferList` | `FormTransferListField` | an array of the chosen items' `id`s |
580
+ | `Cascader` | `FormCascaderField` | the path: an array of the `value` of each step |
581
+ | `MentionsInput` | `FormMentionsField` | the text, with each mention written into it |
582
+ | `RichTextEditor` (`/editor`) | `FormRichTextField` (`/editor-forms`) | the text as HTML |
583
+ | `ToggleButton`, `ToggleGroup` | none | pressed or not; an array of the pressed items' `value`s |
584
+
585
+ Without react-hook-form, put a bare control in `FieldFrame` for its label, message and hint, and give the control
586
+ the label's id so it is named by it:
587
+
588
+ ```tsx
589
+ import { useId, useState } from "react";
590
+ import { Combobox, FieldFrame } from "@primecoderin/fast-ui-react";
591
+
592
+ export function TeamField({ teams }: { teams: { value: string; label: string }[] }) {
593
+ const labelId = useId();
594
+ const [team, setTeam] = useState("");
595
+ return (
596
+ <FieldFrame label="Team" labelId={labelId} invalid={false}>
597
+ <Combobox
598
+ aria-labelledby={labelId}
599
+ options={teams}
600
+ value={team}
601
+ onValueChange={setTeam}
602
+ noMatchesLabel="No team matches"
603
+ />
604
+ </FieldFrame>
605
+ );
606
+ }
607
+ ```
608
+
609
+ With state of your own, or any other form library:
610
+
611
+ ```tsx
612
+ import { useState } from "react";
613
+ import { Button, SelectField, TextField } from "@primecoderin/fast-ui-react";
614
+
615
+ export function MemberForm({ roles, save }: { roles: { value: string; label: string }[]; save: () => void }) {
616
+ const [name, setName] = useState("");
617
+ const [role, setRole] = useState("");
618
+ return (
619
+ <form onSubmit={save}>
620
+ <TextField label="Name" value={name} onValueChange={setName} errorMessage={name === "" ? "Enter a name" : undefined} />
621
+ <SelectField label="Role" value={role} onValueChange={setRole} options={roles} />
622
+ <Button type="submit" variant="primary">Save</Button>
623
+ </form>
624
+ );
625
+ }
626
+ ```
627
+
628
+ With react-hook-form:
629
+
630
+ ```tsx
631
+ import { useForm } from "react-hook-form";
632
+ import { Button } from "@primecoderin/fast-ui-react";
633
+ import { FormTextField, FormSelectField } from "@primecoderin/fast-ui-react/forms";
634
+
635
+ export function MemberForm({ roles, save }: { roles: { value: string; label: string }[]; save: (values: { name: string; role: string }) => void }) {
636
+ const { control, handleSubmit } = useForm({ defaultValues: { name: "", role: "" } });
637
+ return (
638
+ <form onSubmit={handleSubmit(save)}>
639
+ <FormTextField control={control} name="name" label="Name" rules={{ required: "Enter a name" }} />
640
+ <FormSelectField control={control} name="role" label="Role" options={roles} rules={{ required: "Choose a role" }} />
641
+ <Button type="submit" variant="primary">Save</Button>
642
+ </form>
643
+ );
644
+ }
645
+ ```
646
+
647
+ The bound fields take the plain field's props, except the ones react-hook-form supplies (`value`, `onValueChange`,
648
+ `errorMessage`, `invalid`, `onBlur`, `inputRef`, and `name`, which is typed to the form's field names), and add
649
+ `rules` (react-hook-form's validation rules, on every bound field) and `formatError`, which turns a stored validation message into display text. A
650
+ plain field takes the text as it is: `errorMessage` is already in the user's language. `inputRef` and `onBlur`
651
+ are for a form library that focuses the first invalid field and tracks which fields were left.
652
+
653
+ A `Slider` cannot be named by `<label htmlFor>`: Base UI puts the `id` on a part that is not the range input, so
654
+ give it `aria-labelledby` (a `FieldFrame` label id) or `aria-label`.
655
+
656
+ The pieces to build a field of your own (`FieldFrame`, `fieldControl`, `fieldInput`, `toErrorText`) stay in the
657
+ main entry.
658
+
659
+ ---
660
+
661
+ # Dates, files and data
662
+
663
+ | For | Use |
664
+ | --- | --- |
665
+ | A month of days always on show, to pick a day or a range | `Calendar` (`mode="range"` for a range) |
666
+ | A start and an end day in one field | `DateRangePicker` |
667
+ | Choosing files, by button or by drop | `FileUpload` (`accept`, `maxSize`, `maxFiles`, progress and errors by file) |
668
+ | Rows of text with an avatar and actions, optionally chosen | `List` |
669
+ | A hierarchy that opens and closes, with the full keyboard | `TreeView` |
670
+ | One record's details as term and value pairs | `DescriptionList` |
671
+ | Events in order, joined by a line | `Timeline` |
672
+ | Slides that scroll and snap | `Carousel` |
673
+ | A keyboard key, code or a command | `Kbd`, `CodeSnippet` (a copy button) |
674
+
675
+ `Calendar` and `DateRangePicker` hold days as text, `"2026-10-24"`, like `DateTimePicker`, with no time zone. A day's
676
+ button is named with its weekday and its number, "Saturday 24 October 2026", so the name contains what the button
677
+ shows. The weeks start on the locale's first day of the week (Monday for `de` or `enGB`); without a `locale`, Sunday,
678
+ and Home and End follow it. A day that cannot be read or does not exist (`"2026-02-31"`) is treated as no day. Today is
679
+ read only in the browser: rendered on a server with nothing picked and no `defaultMonth`, a calendar shows its month
680
+ once hydrated.
681
+
682
+ `FileUpload` never sends a file: the app does that, and reports how far it got through `statuses` (a `Map` from a
683
+ `File` to `{ progress, error }`). What it refuses (a type not in `accept`, a file over `maxSize`, one past
684
+ `maxFiles`) is reported through `onReject` with the reason, so the app words the message in its own language.
685
+ With `name`, the files are also kept in a hidden file input, so a form the browser submits sends them. Without
686
+ `multiple`, of several files dropped together the first is kept and the rest are reported as `count`.
687
+ `formatFileSize(bytes, locale)` writes a size for the user's locale and is exported for the app's own use.
688
+
689
+ ## The date and time picker
690
+
691
+ `DateTimePicker` and `FormDateTimeField` (from `@primecoderin/fast-ui-react/forms`) pick a date, a date and time, or a time.
692
+ The value is the text a native input holds (`"2026-10-24"`, `"2026-10-24T14:05"`, `"14:05"`), with no time
693
+ zone. Like every component, the picker holds no text of its own: `labels` carries each text it shows and
694
+ announces, and `locale` is a date-fns locale for the names of months and days. Both default to English. An app
695
+ in another language passes its own:
696
+
697
+ ```tsx
698
+ import { he } from "date-fns/locale/he";
699
+ import type { DateTimePickerLabels } from "@primecoderin/fast-ui-react";
700
+ import { FormDateTimeField } from "@primecoderin/fast-ui-react/forms";
701
+
702
+ const labels: DateTimePickerLabels = { select: "בחר", today: "היום" /* ...every key */ };
703
+
704
+ <FormDateTimeField control={control} name="startDate" label="Start date" labels={labels} locale={he} />;
705
+ ```
706
+
707
+ `date-fns` is a dependency of the package. An app that imports a locale (`date-fns/locale/he`) lists `date-fns`
708
+ in its own `package.json` too, so the import does not depend on how the package manager lays out `node_modules`.
709
+
710
+ ---
711
+
712
+ # Charts
713
+
714
+ The charts come from their own entry, `@primecoderin/fast-ui-react/charts`, so an app that draws none never loads
715
+ `recharts` (an optional peer, like `react-hook-form`):
716
+
717
+ ```bash
718
+ npm install recharts
719
+ ```
720
+
721
+ ```tsx
722
+ import { BarChart, DonutChart, GaugeChart, LineChart, Sparkline } from "@primecoderin/fast-ui-react/charts";
723
+
724
+ const data = [
725
+ { month: "Jan", orders: 120, returns: 12 },
726
+ { month: "Feb", orders: 150, returns: 18 },
727
+ ];
728
+
729
+ <LineChart
730
+ aria-label="Orders and returns per month"
731
+ data={data}
732
+ xKey="month"
733
+ xLabel="Month"
734
+ series={[
735
+ { key: "orders", label: "Orders" },
736
+ { key: "returns", label: "Returns" },
737
+ ]}
738
+ />;
739
+ ```
740
+
741
+ | Chart | For |
742
+ | --- | --- |
743
+ | `LineChart` | a trend over time, a few measures side by side |
744
+ | `AreaChart` | a volume over time; `stacked` for how a total divides into parts |
745
+ | `BarChart` | a comparison between categories; `stacked` for parts of each total |
746
+ | `DonutChart` | how a whole splits into five parts or fewer |
747
+ | `GaugeChart` | one value in a range (load, quota used, a score); `bands` turn it green, amber, red as it climbs (a plain SVG, `role="meter"`) |
748
+ | `Sparkline` | a tiny trend, with no axes, in a card or a table row (a plain SVG, not Recharts) |
749
+
750
+ - **SVG, themed.** The charts draw SVG, so they read CSS variables: the series take the `--fast-chart-1` to
751
+ `--fast-chart-5` tokens in order (the first follows the primary colour, so a tenant's branding reaches the
752
+ charts), and the grid and axis take `--fast-chart-grid` and `--fast-chart-axis`. Each series may set its own
753
+ `color`, any CSS colour or variable. `getChartPalette` stays for libraries that draw to a canvas.
754
+ - **A table for a screen reader.** The drawing is hidden from assistive technology and the same numbers are given
755
+ as a table named by `aria-label`. `series[].label`, `xLabel` and the number formats come from the app, so the
756
+ charts hold no text of their own. A `Sparkline` is an image named by its `aria-label`; say the trend in words.
757
+ - **Always left to right.** The plot reads left to right on a right-to-left page too, as an axis of numbers or
758
+ dates does; the legend and the page around it follow the page's direction.
759
+ - **Series that differ by more than colour.** Line and area series after the first are dashed or dotted, and the
760
+ legend shows the same; bars differ by colour and position only.
761
+ - **Gauge value.** `aria-valuenow` stays within the gauge's min and max; `aria-valuetext` says the value as written.
762
+ - **Fonts.** The charts measure their axes again when the font changes (a theme, the right-to-left font, a web font
763
+ that finishes loading).
764
+ - **Motion.** The charts grow in over 400 ms, and draw at once for a visitor who asks for less motion.
765
+ - **Numbers.** `formatValue` and `formatX` write the axis, the tooltip and the table: `` (n) => `${n} kr` ``.
766
+ - **Size.** The chart fills the width of its container, and `height` (default 240) sets the plot's height; give
767
+ the container a width.
768
+
769
+ ---
770
+
771
+ # Advanced components
772
+
773
+ | For | Use |
774
+ | --- | --- |
775
+ | A search over commands, opened from a shortcut | `CommandPalette` (the app opens it, usually on Ctrl or Cmd and K) |
776
+ | Panels with draggable, keyboard-operable dividers | `ResizablePanels` |
777
+ | Moving items between two lists | `TransferList` |
778
+ | Choosing through levels (country, region, city) | `Cascader` |
779
+ | A text area that suggests people after "@" | `MentionsInput` |
780
+ | A guided walk through the page | `Tour` (a ring and a card for each step) |
781
+ | The page's main action in a corner | `FloatingActionButton` (with `actions`, it opens a menu) |
782
+ | A QR code for a link | `QRCode` (SVG, black on white whatever the theme) |
783
+ | Formatted text | `RichTextEditor`, from [its own entry](#rich-text) |
784
+
785
+ `QRCode` always draws dark on light, because a code with its colours inverted is not read by every scanner. It is an
786
+ image to a screen reader, named by `aria-label`: put the address in text beside it.
787
+
788
+ ## Rich text
789
+
790
+ The editor is built on [TipTap](https://tiptap.dev), which an app installs only if it uses the editor:
791
+
792
+ ```bash
793
+ npm install @tiptap/core @tiptap/pm @tiptap/react @tiptap/starter-kit
794
+ ```
795
+
796
+ ```tsx
797
+ import { RichTextEditor } from "@primecoderin/fast-ui-react/editor";
798
+ import { FormRichTextField } from "@primecoderin/fast-ui-react/editor-forms"; // with react-hook-form
799
+ ```
800
+
801
+ The two are separate entries so that using the editor alone does not need `react-hook-form`, and using the forms
802
+ without the editor does not need TipTap. The value is HTML, with paragraphs, two heading levels, bulleted and
803
+ numbered lists, bold, italic, links and line breaks (Shift+Enter): only what the toolbar makes. Other elements,
804
+ pasted or typed through a shortcut, are dropped, and a link keeps only its address (no `class`, `target`, `rel`
805
+ or `title`). Ctrl or Cmd+K opens the link field; an address that is not allowed (`javascript:`) keeps it open,
806
+ marked invalid. **Clean the HTML on your server before showing text that another person wrote**: the editor's
807
+ schema limits what it writes, but a client can send anything. The editor's own `<style>` carries the provider's
808
+ nonce. Every text (the toolbar's names, the link field's buttons) comes through `labels`.
809
+
810
+ ---
811
+
812
+ # Layout and navigation
813
+
814
+ An app that imports `styles.css` has no Tailwind of its own, so the package lays pages out too:
815
+
816
+ | For | Use |
817
+ | --- | --- |
818
+ | Children in a row or a column, with a gap | `Stack` (`direction`, `gap`, `align`, `justify`, `wrap`) |
819
+ | Equal columns, or as many as fit | `Grid` (`columns`, or `minColumnWidth` for cards that wrap by themselves) |
820
+ | A page's content, centred and no wider than a limit | `Container` (`size`: `narrow`, `default`, `wide`, `full`) |
821
+ | A rule between groups | `Separator` |
822
+ | Text that goes somewhere | `Link` (`render` takes the app's router link) |
823
+ | The path to the current page | `Breadcrumbs` |
824
+ | Sections that open and close | `Accordion` (several), `Collapsible` (one) |
825
+ | A scrolling region with slim scrollbars | `ScrollArea` |
826
+ | A row of controls that is one Tab stop | `Toolbar`, `ToolbarButton`, `ToolbarSeparator` |
827
+ | Menus | `Menu`, `ContextMenu` (a right click), `Menubar` and `MenubarMenu`; items: `MenuItem`, `MenuCheckboxItem`, `MenuRadioItem`, `MenuLinkItem`, `MenuSubmenu`, `MenuGroup`, `MenuSeparator` |
828
+ | The top navigation of a site | `NavigationMenu` |
829
+ | The navigation down the side of an app | `SideNav` (sections, groups, a collapsed form of icons) |
830
+ | The frame of an app | `AppShell` (a sticky header, the navigation beside the page, the page as `<main>`) |
831
+ | The steps of a process | `Stepper` |
832
+
833
+ `Stack`, `Grid` and `Container` take a gap in steps of 4px (`gap={4}` is 16px) rather than a class, so they work
834
+ with the ready-made stylesheet. A link in any of the navigation components takes `href`, or `render` for the app's
835
+ router link: `render={<RouterLink to="/orders" />}`; the component keeps its look and the router keeps the
836
+ navigation.
837
+
838
+ ```tsx
839
+ import { useState } from "react";
840
+ import { AppShell, Container, SideNav, Stack, type SideNavProps } from "@primecoderin/fast-ui-react";
841
+
842
+ export function Layout({ sections }: { sections: SideNavProps["sections"] }) {
843
+ const [navOpen, setNavOpen] = useState(false);
844
+ return (
845
+ <AppShell
846
+ labels={{ navigation: "Main navigation", openNavigation: "Open menu", closeNavigation: "Close menu", skipToContent: "Skip to content" }}
847
+ navOpen={navOpen}
848
+ onNavOpenChange={setNavOpen}
849
+ header={<strong>Acme</strong>}
850
+ nav={<SideNav aria-label="Main" current="orders" onNavigate={() => setNavOpen(false)} sections={sections} />}
851
+ >
852
+ <Container>
853
+ <Stack gap={6}>{/* the page */}</Stack>
854
+ </Container>
855
+ </AppShell>
856
+ );
857
+ }
858
+ ```
859
+
860
+ From the `md` breakpoint (768px) the navigation is a column beside the page, `--fast-size-sidenav` wide; below it
861
+ the navigation is a drawer that the header's menu button opens. The layout sizes are tokens: `size-header`,
862
+ `size-sidenav`, `size-sidenav-collapsed`, `container-max` and `z-sticky`, which `createTheme` can change.
863
+
864
+ ---
865
+
866
+ # Internationalization
867
+
868
+ The package holds no text of its own, so it works in any language the app can translate, and it lays out
869
+ right to left as it does left to right.
870
+
871
+ ## Text
872
+
873
+ Every string a user reads arrives through props: `label`, `hint`, `errorMessage`, and `labels` objects for
874
+ components with several strings (`PaginationLabels`, `ToastLabels`, `PhoneFieldLabels`, `DateTimePickerLabels`,
875
+ `DateRangePickerLabels`, `RichTextEditorLabels`, and so on). Pass the app's translations from whichever library it
876
+ uses (react-intl, i18next, Lingui, next-intl); the package has no dependency on any of them.
877
+
878
+ A few components export English defaults for their `labels` so a demo works at once: `ENGLISH_PICKER_LABELS`,
879
+ `ENGLISH_RANGE_LABELS`, `ENGLISH_TOAST_LABELS`. They are English only and meant to be replaced; an app that ships
880
+ in other languages passes its own.
881
+
882
+ Validation messages follow the same rule: a plain field takes `errorMessage`, and a react-hook-form field stores a
883
+ message key and shows what the app's `formatError` returns (see Forms (the "Forms" section)).
884
+
885
+ ## Right to left
886
+
887
+ `DesignSystemProvider` sets `dir` and `data-theme` on `<html>`:
888
+
889
+ ```tsx
890
+ <DesignSystemProvider themeMode="light" direction="rtl">
891
+ {children}
892
+ </DesignSystemProvider>
893
+ ```
894
+
895
+ - **Switching at run time.** Pass a new `direction` (from the app's state or its locale) and the provider updates
896
+ `dir` on `<html>` straight away: the layout mirrors, the arrow keys reverse and the right-to-left font applies, with
897
+ no reload. On unmount it puts back the `dir` the page had before.
898
+ - **A region in the other direction** (a right-to-left quote in a left-to-right page): put `dir` on that region's
899
+ element yourself and wrap it in a second `DesignSystemProvider` with the same `direction`. The inner provider only
900
+ tells Base UI's behaviour (arrow keys, popup placement) the direction; the outer one keeps the theme and `<html>`.
901
+
902
+ - Layouts use logical properties (`ps-*`, `pe-*`, `ms-*`, `inset-s-*`, `text-start`), so they mirror without
903
+ `rtl:` overrides. `rtl:` appears only for a glyph or a slide that must flip.
904
+ - Arrow keys follow the reading direction: in a right-to-left layout, ArrowRight moves to the previous item.
905
+ - Icons that point somewhere (the calendar's previous and next arrows, for one) flip with `rtl:rotate-180`. Charts do not: an axis of numbers or dates reads left
906
+ to right in a right-to-left language too.
907
+ - Every story is tested in both directions, so a component that breaks when mirrored fails the build. The
908
+ toolbar's **Direction** switch shows it in Storybook.
909
+
910
+ ## Numbers, dates and calendars
911
+
912
+ - `NumberField` takes `locale` and `format` (any `Intl.NumberFormat` options).
913
+ - File sizes format through `Intl.NumberFormat`.
914
+ - The calendars, date and date-time pickers take a date-fns `locale` for the names of months and days and the first day of the week: import it
915
+ from `date-fns/locale/<code>` (for example `he` or `ar-SA`) and pass it. `date-fns` is a dependency of the
916
+ package; an app that already uses it shares the copy. Dates are always written day first and times in 24 hours,
917
+ whatever the locale. See Dates, files and data (the "Dates, files and data" section).
918
+
919
+ ## Fonts
920
+
921
+ Inter, the default font, covers Latin, Cyrillic, Greek and Vietnamese, but not Hebrew or Arabic, so a right-to-left
922
+ page (any language) switches to Arial. For Arabic, Persian or Urdu, CJK or Indic scripts, set a font made for the
923
+ script with `createTheme` (see Theme, branding and tokens (the "Theme, branding and tokens" section)) and keep a fallback after it. A font set
924
+ that way applies in both directions; switch it with the language if the two need different fonts.
925
+
926
+ ## Not covered
927
+
928
+ Month and day names follow `locale`, but the date and time order do not. There is no built-in translation catalogue, pluralization or message formatting, and no automatic locale
929
+ detection: the app decides the language and direction and passes both in.
930
+
931
+ ---
932
+
933
+ # Testing with Playwright
934
+
935
+ Every component gives its elements a role, an accessible name and a state, the same information a screen
936
+ reader uses. A test can find an element the way a person does: a button by its text, a field by its label, a
937
+ dialog by its title. Locators written this way keep working when the styling or the markup changes. The
938
+ components render no test ids.
939
+
940
+ The examples below run against this Storybook, and the names in them are each story's sample data. Open the
941
+ story, try the locator, then use the same pattern with the application's own labels.
942
+
943
+ ## Choosing a locator
944
+
945
+ Use the first of these that fits:
946
+
947
+ - **`getByRole(role, { name })`** for anything a person operates: buttons, links, fields, tabs, menu items,
948
+ options, dialogs and table rows. The name is the visible text, or the label of a control that shows only an
949
+ icon.
950
+ - **`getByLabel(text)`** for form fields.
951
+ - **`getByText(text)`** for content that has no role: badges, tags, metric and status cards.
952
+
953
+ When the same name appears more than once, chain from a container: a dialog, a table row, a list item.
954
+
955
+ A name matches as a substring unless the locator passes `exact: true`: `name: "Active"` also finds "Inactive",
956
+ and `name: "Page 1"` also finds "Page 13".
957
+
958
+ Avoid CSS classes, which change with the design, and element ids such as `base-ui-_r_3_`, which are generated
959
+ on every render. The `data-*` state attributes (`data-checked`, `data-disabled`) are for styling: assert a
960
+ state through its ARIA attribute instead (see **States**).
961
+
962
+ ## Buttons and links
963
+
964
+ ```ts
965
+ page.getByRole("button", { name: "Save changes" });
966
+ // A button that shows only an icon is named by its label.
967
+ page.getByRole("button", { name: "Show password" });
968
+ // A clickable card is one button named by all of its text: match part of it.
969
+ page.getByRole("button", { name: /Website redesign/ });
970
+ page.getByRole("link", { name: "Projects" });
971
+ ```
972
+
973
+ ## Form fields
974
+
975
+ ```ts
976
+ await page.getByLabel("Project name").fill("Website redesign");
977
+ await page.getByLabel("Notes").fill("Ship before the review.");
978
+
979
+ // A select: open it, then choose. The list opens at the end of the page, outside the field.
980
+ await page.getByRole("combobox", { name: "Priority" }).click();
981
+ await page.getByRole("option", { name: "High" }).click();
982
+ await expect(page.getByRole("combobox", { name: "Priority" })).toHaveText("High");
983
+
984
+ // A searchable list: type to filter, then choose.
985
+ await page.getByRole("combobox", { name: "Organization" }).fill("Glob");
986
+ await page.getByRole("option", { name: "Globex Labs" }).click();
987
+
988
+ // A phone number: the calling code and the number are two controls, each with its own name.
989
+ await page.getByLabel("Country calling code").click();
990
+ await page.getByRole("option", { name: "+44 United Kingdom" }).click();
991
+ await page.getByLabel("Phone").fill("2071234567");
992
+
993
+ await page.getByRole("checkbox", { name: "Send me a daily summary" }).check();
994
+ await page.getByRole("switch", { name: "Email notifications" }).uncheck();
995
+ await page.getByRole("radio", { name: "Next day" }).check();
996
+ ```
997
+
998
+ A required field shows an asterisk after its label. The asterisk is part of the label's text but not of the
999
+ field's name, so `getByLabel("Phone", { exact: true })` finds nothing when the field is required. Use
1000
+ `getByLabel("Phone")` or `getByRole("textbox", { name: "Phone", exact: true })`.
1001
+
1002
+ ### Validation messages
1003
+
1004
+ ```ts
1005
+ // The message is an alert, and it is the field's description.
1006
+ await expect(page.getByRole("alert")).toHaveText("Project name is required");
1007
+ await expect(page.getByLabel("Project name")).toHaveAttribute("aria-invalid", "true");
1008
+ await expect(page.getByLabel("Project name")).toHaveAccessibleDescription("Project name is required");
1009
+ ```
1010
+
1011
+ ## Tabs, segmented controls and menus
1012
+
1013
+ ```ts
1014
+ await page.getByRole("tab", { name: "Activity" }).click();
1015
+ await expect(page.getByRole("tab", { name: "Activity" })).toHaveAttribute("aria-selected", "true");
1016
+
1017
+ // A segmented control is a radio group.
1018
+ await page
1019
+ .getByRole("radiogroup", { name: "Filter by status" })
1020
+ .getByRole("radio", { name: "Active", exact: true })
1021
+ .check();
1022
+
1023
+ // A menu opens from its button, and its entries are menu items.
1024
+ await page.getByRole("button", { name: "Row actions" }).click();
1025
+ await page.getByRole("menuitem", { name: "Edit" }).click();
1026
+
1027
+ // A choice of one inside a menu is a set of menu item radios.
1028
+ await page.getByRole("button", { name: "Sort: Name" }).click();
1029
+ await page.getByRole("menuitemradio", { name: "Date created" }).click();
1030
+ ```
1031
+
1032
+ ## Dialogs, drawers and popovers
1033
+
1034
+ ```ts
1035
+ await page.getByRole("button", { name: "New project" }).click();
1036
+ const dialog = page.getByRole("dialog", { name: "New project" });
1037
+ await dialog.getByLabel("Project name").fill("Website redesign");
1038
+ await dialog.getByRole("combobox", { name: "Team" }).click();
1039
+ // The list opens outside the dialog, so the option is found from the page.
1040
+ await page.getByRole("option", { name: "Design" }).click();
1041
+ await page.keyboard.press("Escape");
1042
+ await expect(dialog).toBeHidden();
1043
+
1044
+ // A confirmation (a Dialog with modalType="alert") is an alert dialog.
1045
+ page.getByRole("alertdialog", { name: "Delete project?" });
1046
+ // A drawer is a dialog named by its title, even when the title is not drawn.
1047
+ page.getByRole("dialog", { name: "Filters" });
1048
+ // A popover is a dialog too. A hover popover opens while the pointer rests on its trigger.
1049
+ await page.getByRole("button", { name: "3 reviewers" }).hover();
1050
+ await expect(page.getByRole("dialog", { name: "Reviewers" })).toBeVisible();
1051
+ ```
1052
+
1053
+ ## Notifications
1054
+
1055
+ ```ts
1056
+ const notifications = page.getByRole("region", { name: "Notifications" });
1057
+
1058
+ // A notification is a dialog named by its title, and its message is its text.
1059
+ const saved = notifications.getByRole("dialog", { name: "Success" });
1060
+ await expect(saved).toContainText("Your changes were saved.");
1061
+
1062
+ // The dismiss button shows while the pointer is on the notification.
1063
+ await saved.hover();
1064
+ await saved.getByRole("button", { name: "Dismiss notification" }).click();
1065
+
1066
+ // An error stays out of the accessibility tree until it has focus, and its message is announced as an alert.
1067
+ await expect(page.getByRole("alert").filter({ hasText: "The server did not respond." })).toHaveCount(1);
1068
+ notifications.getByRole("alertdialog", { name: "Unable to complete", includeHidden: true });
1069
+ ```
1070
+
1071
+ A notification closes itself after five seconds, and the timer pauses while the pointer is over the
1072
+ notifications. Assert right after the action that raises it, or hover the notifications first.
1073
+
1074
+ ## Tables and pagination
1075
+
1076
+ ```ts
1077
+ // A table card's scrolling area is a region named after its table.
1078
+ const projects = page.getByRole("region", { name: "Projects" });
1079
+ await expect(projects.getByRole("table")).toBeVisible();
1080
+
1081
+ // A row is named by the text of its cells: match a value only that row has.
1082
+ const row = page.getByRole("row", { name: /PRJ-102/ });
1083
+ await expect(row).toContainText("In progress");
1084
+ await expect(row.getByRole("cell", { name: "Mobile app" })).toBeVisible();
1085
+
1086
+ const pager = page.getByRole("navigation", { name: "Pagination" });
1087
+ await pager.getByRole("button", { name: "Page 2", exact: true }).click();
1088
+ await expect(pager.getByRole("button", { name: "Page 2", exact: true })).toHaveAttribute("aria-current", "page");
1089
+ await pager.getByRole("button", { name: "Next" }).click();
1090
+ await page.getByRole("combobox", { name: "Rows per page" }).selectOption("50");
1091
+ ```
1092
+
1093
+ In the application's data tables, column headers are `columnheader`s. A sortable column's header holds a button
1094
+ with the column's name and carries `aria-sort`. A selectable row has a checkbox named after that row, and a
1095
+ selected row has `aria-selected="true"`. A long table can render only the rows in view: scroll, filter or page
1096
+ before locating a row further down.
1097
+
1098
+ ## Content without a role, messages and loading
1099
+
1100
+ ```ts
1101
+ // Badges, tags, metric and status cards are text: find them inside the row, list item or card they belong to.
1102
+ await expect(page.getByRole("row", { name: /PRJ-103/ })).toContainText("Failed");
1103
+ const processing = page
1104
+ .getByRole("list", { name: "Order summary" })
1105
+ .getByRole("listitem")
1106
+ .filter({ hasText: "Processing" });
1107
+ await expect(processing).toContainText("37");
1108
+
1109
+ // An error message is an alert, and other notices are status messages.
1110
+ page.getByRole("alert").filter({ hasText: "Payment method declined" });
1111
+ page.getByRole("status").filter({ hasText: "Changes saved" });
1112
+ page.getByRole("alert").getByRole("button", { name: "Try again" });
1113
+
1114
+ // Loading: a spinner is a status holding its label as text, a skeleton is a busy progress bar, and a busy
1115
+ // button is disabled.
1116
+ page.getByRole("status").filter({ hasText: "Loading results" });
1117
+ page.getByRole("progressbar", { name: "Loading rows" });
1118
+ await expect(page.getByRole("button", { name: "Saving" })).toBeDisabled();
1119
+
1120
+ // A tooltip has no role: hover its control, then find its text.
1121
+ await page.getByRole("button", { name: "Edit" }).hover();
1122
+ await expect(page.getByText("Edit", { exact: true })).toBeVisible();
1123
+ ```
1124
+
1125
+ ## States
1126
+
1127
+ Assert a state through the attribute that assistive technology reads:
1128
+
1129
+ - **Disabled**: `toBeDisabled()`. It covers both the native `disabled` attribute and `aria-disabled="true"`,
1130
+ which tabs, menu items, a busy button and a button that stays focusable while disabled use.
1131
+ - **Checked**: `toBeChecked()` and `not.toBeChecked()` for checkboxes, switches, radios and menu item radios. A
1132
+ partly selected checkbox has `aria-checked="mixed"`.
1133
+ - **Selected**: a tab or a table row has `aria-selected="true"`.
1134
+ - **Open**: the control that opened a list, menu or popover has `aria-expanded="true"`.
1135
+ - **Invalid and required**: `aria-invalid="true"`, with the message as the field's accessible description;
1136
+ `aria-required="true"`.
1137
+ - **Loading**: `aria-busy="true"` on a busy button, a skeleton or a loading table.
1138
+ - **Current page**: `aria-current="page"`.
1139
+ - **Sorted column**: `aria-sort="ascending"` or `aria-sort="descending"`.
1140
+
1141
+ ## Things to know
1142
+
1143
+ - **Names follow the interface language.** Every label and name is translated, so run tests in one language.
1144
+ - **Popups open at the end of the page**, outside the element that opens them. Locate options, menu items and
1145
+ popovers from `page`, not from the field or the dialog.
1146
+ - **An open list adds two hidden "Dismiss" buttons** for screen-reader users. Scope any locator for a button
1147
+ named "Dismiss" to its container.
1148
+ - **Animations**: dialogs, panels and popups fade and slide, and Playwright waits for them. After closing one,
1149
+ assert `toBeHidden()`.
1150
+ - **Right to left** changes the layout, not the roles.
1151
+ - **Test ids**: the components render none, and most do not pass one through. When role, label and text cannot
1152
+ single out an element, ask for a test id on it.
1153
+
1154
+ ## Unit tests with Testing Library
1155
+
1156
+ The same queries work in Testing Library: `screen.getByRole("button", { name: "Save changes" })`. Render the
1157
+ component inside `DesignSystemProvider`, as the app does, so it gets the direction, the tooltip delay and the
1158
+ toaster:
1159
+
1160
+ ```tsx
1161
+ render(
1162
+ <DesignSystemProvider themeMode="light" direction="ltr">
1163
+ <SaveBar />
1164
+ </DesignSystemProvider>,
1165
+ );
1166
+ ```
1167
+
1168
+ - **Use `themeMode="light"` or `"dark"`.** `"system"` reads `window.matchMedia`, which jsdom does not have; stub it
1169
+ if a test needs the system setting.
1170
+ - **jsdom is not a browser.** The package's own tests run every story in Chromium (Vitest browser mode), not in
1171
+ jsdom. Components that measure or position (charts, scroll areas, popups, resizable panels) need `ResizeObserver`
1172
+ and layout, which jsdom lacks; test those in a browser runner (Vitest browser mode or Playwright component tests).
1173
+
1174
+ ---
1175
+
1176
+ # Accessibility
1177
+
1178
+ The package aims at WCAG 2.2 level AA. This page says what is built in, how it is checked and what it cannot
1179
+ promise, so an app can plan its own testing.
1180
+
1181
+ ## What the components do
1182
+
1183
+ - **Behaviour from Base UI.** Menus, selects, dialogs, tabs, tooltips, sliders and the other composite widgets
1184
+ take their roles, states and keyboard handling from [Base UI](https://base-ui.com/react/overview/accessibility),
1185
+ which follows the WAI-ARIA Authoring Practices.
1186
+ - **Keyboard.** Every control works without a mouse: Tab and Shift+Tab move between controls, Enter or Space
1187
+ activates, the arrow keys move inside menus, lists, tabs, radio groups, calendars and trees, and Escape closes
1188
+ a popup and returns the focus to what opened it. Dialogs and panels keep the focus inside while open. The
1189
+ keys of right-to-left layouts are mirrored.
1190
+ - **Focus.** A visible focus ring (`ring-focus`) shows for keyboard focus only.
1191
+ - **Contrast.** Text meets 4.5:1 (large text 3:1) in the light and dark themes. Where the brand colour is too pale
1192
+ for text, its darker `-text` shade is used. A tenant's own primary colour is not checked: an app
1193
+ that lets tenants pick one (see Theme, branding and tokens (the "Theme, branding and tokens" section)) is responsible for its contrast.
1194
+ - **Names and messages.** A form field's label, hint and error message are tied to its control, and an error is
1195
+ announced when it appears. A control with no visible text takes an `aria-label`, and decorative icons are hidden
1196
+ from assistive technology.
1197
+ - **Motion.** Animation stops for a visitor who asks for reduced motion (`prefers-reduced-motion`): a global rule
1198
+ in the stylesheet, and the carousel's and the tour's smooth scrolling becomes an instant jump. Nothing moves by
1199
+ itself: the carousel has no autoplay.
1200
+ - **Layout.** Layouts reflow at narrow widths (the `sm` breakpoint, 640px; the app shell's navigation at `md`,
1201
+ 768px), and the stylesheet does not lock the page's zoom.
1202
+
1203
+ ## How it is checked
1204
+
1205
+ Every story, which is every component state, is rendered three times: light, dark and right to left. Each run
1206
+ fails on an axe violation (`@storybook/addon-a11y` with `test: "error"`). Keyboard stories press the real keys,
1207
+ and each component's `Interactions` story exercises its behaviour. The checks run in Chromium; see
1208
+ Browser support (the "Browser support" section).
1209
+
1210
+ ## What it does not promise
1211
+
1212
+ - **Automated checks find only part of the problems.** axe finds roughly a third to a half of WCAG issues. The
1213
+ suite does not replace a screen reader pass, and no manual assistive-technology audit is recorded for this
1214
+ version. Test the pages an app composes, as a component's accessibility does not make a page accessible.
1215
+ - **Bar series differ only by colour.** Lines and areas are dashed too; bars are not.
1216
+ - **Some names need an attribute.** A `MentionsInput` named only by `id` and a `<label htmlFor>` leaves its suggestion
1217
+ list unnamed: give it `aria-label` or `aria-labelledby`. A `DataTable` row with `onRowActivate` is announced as a
1218
+ row, not a control: put a real link or button in a cell.
1219
+ - **Dragging has no single-pointer alternative.** `ResizablePanels` dividers move by dragging or with the keyboard (arrow
1220
+ keys, Home, End); WCAG 2.5.7 (dragging movements) is therefore not met. Offer preset sizes or a toggle in the app if
1221
+ it is needed.
1222
+ - **Reduced motion and status text.** A ProgressBar stays still under reduced motion (a full bar at half opacity);
1223
+ a Spinner's label arrives just after it does, so a screen reader announces it.
1224
+ - **One story is checked only as "todo".** The Toast `Interactions` story runs axe as `todo`: Base UI keeps an error
1225
+ toast `aria-hidden` while it can still take focus, and announces it through a separate alert instead.
1226
+ - **The app supplies the words.** Labels, error messages, alt text and page structure (headings, landmarks) are
1227
+ the app's; the package has no text of its own to get wrong. See Internationalization (the "Internationalization" section).
1228
+ - **Charts are visual.** The line, area, bar and donut charts have an accessible name and a visually hidden data
1229
+ table that a screen reader reads instead of the drawing, so the data you pass is the data announced. A gauge is a
1230
+ `meter` with its value; a sparkline is an image named by its `aria-label`, with no table. See Charts (the "Charts" section).
1231
+ - **Windows high contrast** (`forced-colors`) is not tested yet.
1232
+
1233
+ ## Reporting a problem
1234
+
1235
+ Open an issue with the component, what an assistive technology said or did, and the browser and screen reader.
1236
+ An accessibility defect in a component is treated as a bug.
1237
+
1238
+ ---
1239
+
1240
+ # Browser support
1241
+
1242
+ The package targets current evergreen browsers. The floor comes from **Tailwind CSS 4**, whose stylesheet uses
1243
+ `@property`, `color-mix()` and cascade layers:
1244
+
1245
+ | Browser | Minimum |
1246
+ | --- | --- |
1247
+ | Chrome and Edge | 111 |
1248
+ | Safari and iOS Safari | 16.4 |
1249
+ | Firefox | 128 |
1250
+
1251
+ These are the minimums Tailwind 4 documents, not a list this project has verified one by one.
1252
+
1253
+ ## What is tested
1254
+
1255
+ The test suite runs every story in **Chromium** (through Playwright), light, dark and right to left. Safari and
1256
+ Firefox are not part of the automated tests, so a rendering difference there is found by users, not by the build.
1257
+ If you meet one, please report it with the browser version.
1258
+
1259
+ ## Not supported
1260
+
1261
+ - Internet Explorer and the legacy (pre-Chromium) Edge.
1262
+ - Browsers without CSS cascade layers or `color-mix()`.
1263
+
1264
+ Server-side rendering is supported: see Next.js (the "Next.js" section).
1265
+
1266
+ ## JavaScript
1267
+
1268
+ The package is ESM only and ships modern syntax (it needs `react/compiler-runtime`, so React 19). An app's bundler
1269
+ decides what to transpile for its own targets. The types are generated by TypeScript 6; use a recent TypeScript in the app.
1270
+
1271
+ ---
1272
+
1273
+ # Architecture
1274
+
1275
+ How the package is put together: what is in the repository, how it is built and what an app receives.
1276
+
1277
+ ## The repository
1278
+
1279
+ | Folder | Content |
1280
+ | --- | --- |
1281
+ | `src/components/` | Single controls and marks: `Button`, `Menu`, `Tooltip`, `Tabs` and the like |
1282
+ | `src/patterns/` | Compositions of components: form fields, pickers, dialogs, tables, charts, the editor |
1283
+ | `src/provider/` | `DesignSystemProvider` |
1284
+ | `src/theme/` | `createTheme`, tenant branding, theme switching, the generated token names |
1285
+ | `src/styles/` | The CSS: `tokens.css` (the `--fast-*` variables), `theme.css` (Tailwind's mappings), `global.css`, `fonts.css` and the generated font files |
1286
+ | `src/hooks/`, `src/utils/`, `src/types/`, `src/icons/` | Hooks, `cn()`, shared types, the icon set |
1287
+ | `src/index.ts`, `forms.ts`, `charts.ts`, `editor.ts`, `editor-forms.ts` | The five entries. The package exports only what these export |
1288
+ | `stories/` | The Storybook documentation (the components, and `guides/`, which renders `docs/`), and the tests that run on it |
1289
+ | `tests/unit/` | Pure logic, tested in Node |
1290
+ | `mcp/` | The MCP server for coding assistants (`@primecoderin/fast-ui-react-mcp`) |
1291
+ | `scripts/` | Generators: token names, fonts, the MCP catalogue, the component reference, `llms.txt` |
1292
+ | `docs/` | These guides |
1293
+
1294
+ ## The layers
1295
+
1296
+ ```
1297
+ Base UI behaviour: roles, keyboard, focus, positioning (unstyled)
1298
+ Tailwind CSS 4 every style, from the --fast-* tokens (no Tailwind palette)
1299
+ CVA + cn() variants, and class merging with the caller's className
1300
+ Components one concern each, no text of their own
1301
+ Patterns compositions: the form fields, pickers, dialogs ...
1302
+ ```
1303
+
1304
+ A component imports only from this package's `src/` and its dependencies; one that needs the app's translations,
1305
+ routing or data does not belong here. See Prop conventions (the "Prop conventions" section) for how the props are named.
1306
+
1307
+ ## Entries and optional dependencies
1308
+
1309
+ The main entry never reaches an optional package. `react-hook-form`, `recharts` and TipTap each sit behind an
1310
+ entry of their own (`/forms`, `/charts`, `/editor`, `/editor-forms`), declared as optional peer dependencies, so an
1311
+ app that does not use them installs and bundles none of them. A unit test (`tests/unit/entries.test.ts`) fails if
1312
+ the main entry starts importing one.
1313
+
1314
+ ## What the build produces
1315
+
1316
+ | File | Made by | Content |
1317
+ | --- | --- | --- |
1318
+ | `dist/index.js`, `dist/**/*.js` | Vite (library mode) | one ES module per source file, `index.js` re-exporting them, so an app's bundler keeps only what it imports. Dependencies stay imports. Component modules start with `"use client"`; the pure helpers (`createTheme`, `cn`, the token names) do not, so a Server Component can call them. The React Compiler runs on it, so it imports `react/compiler-runtime` (React 19) |
1319
+ | `dist/**/*.d.ts` | `tsc` | the type declarations |
1320
+ | `dist/styles.css` | Tailwind CLI | the ready-made, minified stylesheet, with the font's `@font-face` rules |
1321
+ | `dist/foundation.css`, `fonts.css`, `tokens.css`, `theme.css`, `global.css` | copied | the unprocessed foundation for apps with their own Tailwind (see Theme, branding and tokens (the "Theme, branding and tokens" section)) |
1322
+ | `dist/fonts/` | copied | Inter's variable WOFF2 files, one per character set, and the font's licence; both stylesheets point to them |
1323
+
1324
+ The package also ships `CHANGELOG.md`, `LICENSE`, `llms.txt` and `llms-full.txt` (see AI coding assistants (the "AI coding assistants" section)).
1325
+
1326
+ ## Generated files
1327
+
1328
+ Do not edit these by hand; the command regenerates them.
1329
+
1330
+ | File | Command | From |
1331
+ | --- | --- | --- |
1332
+ | `src/theme/token-names.ts` | `npm run tokens` (the build runs it) | `src/styles/tokens.css` |
1333
+ | `src/styles/fonts.css`, `src/styles/fonts/` | `npm run fonts` (the build runs it) | the `@fontsource-variable/inter` devDependency |
1334
+ | `mcp/catalog.json` | `npm run mcp:build` (the tests run it) | the source, the stories and `docs/` |
1335
+ | `docs/components.md`, `docs/testing.md`, `docs/design-principles.md`, `llms.txt`, `llms-full.txt` | `npm run docs` | the catalogue, the doc comments, `docs/`, `stories/testing.mdx` and `stories/introduction.mdx` |
1336
+
1337
+ A unit test fails while a generated file differs from what its command produces.
1338
+
1339
+ ---
1340
+
1341
+ # Troubleshooting and FAQ
1342
+
1343
+ ## The components have no styles
1344
+
1345
+ Import the stylesheet once, at the app's entry: `import "@primecoderin/fast-ui-react/styles.css";`. An app that runs its
1346
+ own Tailwind 4 imports `foundation.css` instead and lets its Tailwind scan the package: see
1347
+ Theme, branding and tokens (the "Theme, branding and tokens" section).
1348
+
1349
+ ## `bg-red-500` or `text-lg` produces nothing
1350
+
1351
+ Intended. The package switches Tailwind's own palette, type, radius and shadow scales off in favour of the design
1352
+ tokens (`bg-primary`, `text-fg-secondary`, `border-line`). An app that imports `styles.css` has no Tailwind of
1353
+ its own; the utilities that exist are the ones the components use. Add the app's own CSS or run Tailwind 4 yourself
1354
+ (see above).
1355
+
1356
+ ## "You're importing a component that needs `useState`" (Next.js)
1357
+
1358
+ The component modules start with `"use client"`, so a Server Component can import them as it imports any Client
1359
+ Component. If the message names the app's own file, that file uses a hook or an event handler and needs
1360
+ `"use client"` itself. See Next.js (the "Next.js" section).
1361
+
1362
+ ## "Cannot find module `react-hook-form`" (or `recharts`, `@tiptap/react`)
1363
+
1364
+ Each belongs to an entry of its own and is an optional peer dependency. Install what the entry needs:
1365
+ `@primecoderin/fast-ui-react/forms` needs `react-hook-form`, `/charts` needs `recharts`, `/editor` the four TipTap
1366
+ packages. The table is in Getting started (the "Getting started" section).
1367
+
1368
+ ## The font is not Inter, or the page has no font
1369
+
1370
+ Check that `styles.css` is imported and that a Content-Security-Policy allows `font-src 'self'`. If the app sets
1371
+ another font with `createTheme`, Inter is not downloaded at all. See Theme, branding and tokens (the "Theme, branding and tokens" section).
1372
+
1373
+ ## Inline styles are blocked by my Content-Security-Policy
1374
+
1375
+ `DesignSystemProvider` takes a `nonce` for the `<style>` element it writes. See the CSP section of
1376
+ Theme, branding and tokens (the "Theme, branding and tokens" section).
1377
+
1378
+ ## Can I use it without a provider?
1379
+
1380
+ Render `DesignSystemProvider` once at the root: it sets the theme and direction on `<html>`, applies branding and
1381
+ hosts the toaster and tooltip delay. Components outside it lose that, and `toast` has nowhere to show.
1382
+
1383
+ ## Can I use my own brand colour?
1384
+
1385
+ Yes: `createTheme` and tenant branding; see Theme, branding and tokens (the "Theme, branding and tokens" section).
1386
+
1387
+ ## Does it work with TypeScript's `exactOptionalPropertyTypes`?
1388
+
1389
+ Yes. Optional props are declared `| undefined`, so passing `undefined` is allowed under that option (a unit test
1390
+ checks every optional property in the source).
1391
+
1392
+ ## Which React versions?
1393
+
1394
+ React 19 only. The build uses the React Compiler, which imports `react/compiler-runtime`.
1395
+
1396
+ ## Can I use it with Vue, Svelte or Angular?
1397
+
1398
+ No. It is a React library.
1399
+
1400
+ ## A test cannot find a component
1401
+
1402
+ Components expose accessible roles and names, so query by role and name rather than by class. The
1403
+ testing guide (the "Testing with Playwright" section) shows each component's selectors with Playwright examples.
1404
+
1405
+ ## Where do I report a bug or ask for a component?
1406
+
1407
+ Open an issue (templates for both are provided). For a component, say what the other libraries call it and what it
1408
+ must do; see also the [roadmap](https://github.com/primecoderIN/fast-ui-react/blob/master/ROADMAP.md) for what is planned.
1409
+
1410
+ ---
1411
+
1412
+ # AI coding assistants
1413
+
1414
+ Two things help an assistant (Claude Code, Cursor, Copilot, Windsurf and others) use the package correctly: the
1415
+ `llms.txt` files, which need no setup, and an MCP server, which answers questions on demand. Both are generated from
1416
+ the source, so they match the version installed.
1417
+
1418
+ ## llms.txt and llms-full.txt
1419
+
1420
+ The package ships two plain Markdown files, following the [llms.txt](https://llmstxt.org) convention:
1421
+
1422
+ - **`llms.txt`** is a short index: the rules to know before writing code (what to import, no built-in text, tokens
1423
+ instead of colour values) and a link with one line to each guide.
1424
+ - **`llms-full.txt`** is the guides, the design tokens and the reference of every component with its props, in one
1425
+ file, for loading whole into a context window.
1426
+
1427
+ They are in the installed package, so a project can point its assistant at them without a network:
1428
+
1429
+ ```
1430
+ node_modules/@primecoderin/fast-ui-react/llms.txt
1431
+ node_modules/@primecoderin/fast-ui-react/llms-full.txt
1432
+ ```
1433
+
1434
+ For example, in a `CLAUDE.md` or `AGENTS.md`: "UI components come from `@primecoderin/fast-ui-react`; read
1435
+ `node_modules/@primecoderin/fast-ui-react/llms.txt` before using them." Or give the files to a tool that takes documentation
1436
+ as a file or a URL. In this repository, `npm run docs` regenerates them.
1437
+
1438
+ ## The MCP server
1439
+
1440
+ `@primecoderin/fast-ui-react-mcp` gives Claude Code, Cursor, VS Code and other assistants the library's exact API: every
1441
+ component's props with types and defaults, the tokens, these guides and tested examples. Add it once:
1442
+
1443
+ ```bash
1444
+ claude mcp add fast-ui -- npx -y @primecoderin/fast-ui-react-mcp
1445
+ ```
1446
+
1447
+ Other clients, and what it offers: [the MCP server's README](https://github.com/primecoderIN/fast-ui-react/blob/master/mcp/README.md).
1448
+
1449
+ ## Which one
1450
+
1451
+ | | llms.txt | MCP server |
1452
+ | --- | --- | --- |
1453
+ | Setup | none: a file in `node_modules` | one command, and `npx` at run time |
1454
+ | Cost | the file's tokens whenever it is loaded (`llms-full.txt` is large) | only the answer to each question |
1455
+ | Best for | a rule in the project's instructions; tools without MCP | looking up one component's props or an example while coding |
1456
+
1457
+ ---
1458
+
1459
+ # Releasing
1460
+
1461
+ For maintainers. Releases follow [semantic versioning](https://semver.org) because every consuming app upgrades on
1462
+ its own schedule: a token or prop that is renamed without a major version breaks them.
1463
+
1464
+ ## What counts as which
1465
+
1466
+ | Change | Version |
1467
+ | --- | --- |
1468
+ | A fix that changes no export, prop or token | patch |
1469
+ | A new component, prop, token or entry | minor |
1470
+ | A removed or renamed export, prop or token; a changed default; a raised peer dependency range | major |
1471
+
1472
+ ## Steps
1473
+
1474
+ 1. **Update `CHANGELOG.md`.** Move the items under "Unreleased" into a heading for the new version and date, in
1475
+ the [Keep a Changelog](https://keepachangelog.com) groups (Added, Changed, Deprecated, Removed, Fixed,
1476
+ Security). Start each breaking change with "**Breaking:**" and say what to do instead.
1477
+ 2. **Bump the version in both packages.** Update `version` in `package.json` and `mcp/package.json` to the same
1478
+ version (for example `npm version minor --no-git-tag-version` and the same in `mcp/package.json`): the MCP server's
1479
+ catalogue is generated from this package.
1480
+ 3. **Regenerate docs and lockfile.** Run `npm run docs` so `docs/components.md`, `llms.txt` and `llms-full.txt` carry
1481
+ the new version, and run `npm install --package-lock-only` if dependencies changed.
1482
+ 4. **Check everything.** Run `npm run typecheck`, then `npm test` (unit tests, every story light, dark and right to
1483
+ left, and SSR + hydration).
1484
+ 5. **Check what will ship.** Run `npm run build`, then `npm pack --dry-run` and `npm pack --dry-run -w mcp` to verify
1485
+ the files (`dist/`, `docs/`, `CHANGELOG.md`, `LICENSE`, `llms.txt`, `llms-full.txt`, `package.json`, `README.md`
1486
+ for the main package; `dist/` and `catalog.json` for the MCP server). Both `package.json` files set
1487
+ `"publishConfig": { "access": "public" }`.
1488
+ 6. **Commit and tag.** Commit the version bump, changelog and regenerated docs on `master`, then create an annotated
1489
+ tag `v<version>` (e.g. `git tag -a v0.2.0 -m "v0.2.0"`).
1490
+ 7. **Publish.** Push the commit and tag (`git push origin master --follow-tags`). Pushing a `v*` tag triggers
1491
+ `.github/workflows/release.yml`, which verifies the tag matches both `package.json` versions, runs checks and
1492
+ publishes both `@primecoderin/fast-ui-react` and `@primecoderin/fast-ui-react-mcp` with npm provenance. To publish manually instead,
1493
+ run `npm publish` and `npm publish -w mcp` (each package's `prepack` builds it first). For a private feed, set
1494
+ `"publishConfig": { "registry": "https://<your-feed-address>/" }`.
1495
+ 8. **Release notes.** Create the GitHub Release for the tag from the changelog entry.
1496
+
1497
+ Deprecate rather than delete: mark an export `@deprecated` in its doc comment for one minor version before a major
1498
+ removes it.
1499
+
1500
+ ---
1501
+
1502
+ # Design tokens
1503
+
1504
+ The CSS variables a theme sets (`createTheme`) and the Tailwind utilities that read them.
1505
+
1506
+ - `--fast-primary` (Primary: teal): bg-primary, text-primary, border-primary. Light #00c5c1
1507
+ - `--fast-primary-hover` (Primary: teal): bg-primary-hover, text-primary-hover, border-primary-hover. Light #00afa9, dark #1ad0cc
1508
+ - `--fast-primary-active` (Primary: teal): bg-primary-active, text-primary-active, border-primary-active. Light #00977a, dark #00afa9
1509
+ - `--fast-primary-light` (Primary: teal): bg-primary-light, text-primary-light, border-primary-light. Light #e9fbfa, dark #0b3a3f
1510
+ - `--fast-primary-pale` (Primary: teal): bg-primary-pale, text-primary-pale, border-primary-pale. Light #f7ffff, dark #0d2f33
1511
+ - `--fast-primary-text` (Primary: teal): bg-primary-text, text-primary-text, border-primary-text. Light #007d79, dark #33deda
1512
+ - `--fast-primary-text-hover` (Primary: teal): bg-primary-text-hover, text-primary-text-hover, border-primary-text-hover. Light #006b68, dark #75e9e6
1513
+ - `--fast-primary-text-pressed` (Primary: teal): bg-primary-text-pressed, text-primary-text-pressed, border-primary-text-pressed. Light #00524f, dark #9eefee
1514
+ - `--fast-primary-large` (Primary: teal): bg-primary-large, text-primary-large, border-primary-large. Light #00977a, dark #33deda
1515
+ - `--fast-on-primary` (Primary: teal): bg-on-primary, text-on-primary, border-on-primary. Light #111827
1516
+ - `--fast-accent` (Accent: yellow): bg-accent, text-accent, border-accent. Light #ffd400
1517
+ - `--fast-accent-light` (Accent: yellow): bg-accent-light, text-accent-light, border-accent-light. Light #fff9cc, dark #3b3410
1518
+ - `--fast-accent-strong` (Accent: yellow): bg-accent-strong, text-accent-strong, border-accent-strong. Light #d4aa00, dark #ffd400
1519
+ - `--fast-on-accent` (Accent: yellow): bg-on-accent, text-on-accent, border-on-accent. Light #111827
1520
+ - `--fast-fg` (Text): bg-fg, text-fg, border-fg. Light #111827, dark #f3f4f6
1521
+ - `--fast-fg-body` (Text): bg-fg-body, text-fg-body, border-fg-body. Light #344054, dark #d6dae2
1522
+ - `--fast-fg-secondary` (Text): bg-fg-secondary, text-fg-secondary, border-fg-secondary. Light #475569, dark #b6bcc8
1523
+ - `--fast-fg-tertiary` (Text): bg-fg-tertiary, text-fg-tertiary, border-fg-tertiary. Light #667085, dark #9aa2b1
1524
+ - `--fast-fg-disabled` (Text): bg-fg-disabled, text-fg-disabled, border-fg-disabled. Light #9ca3af, dark #6b7280
1525
+ - `--fast-fg-inverted` (Text): bg-fg-inverted, text-fg-inverted, border-fg-inverted. Light #ffffff, dark #111827
1526
+ - `--fast-bg` (Surfaces and borders): bg-page, text-page, border-page. Light #ffffff, dark #1a1d24
1527
+ - `--fast-surface` (Surfaces and borders): bg-surface, text-surface, border-surface. Light #ffffff, dark #1a1d24
1528
+ - `--fast-surface-hover` (Surfaces and borders): bg-surface-hover, text-surface-hover, border-surface-hover. Light color-mix(in srgb, var(--fast-primary) 3%, var(--fast-surface)), dark color-mix(in srgb, var(--fast-primary) 7%, var(--fast-surface))
1529
+ - `--fast-bg-subtle` (Surfaces and borders): bg-subtle, text-subtle, border-subtle. Light #f3f6f8, dark #262b35
1530
+ - `--fast-bg-muted` (Surfaces and borders): bg-muted, text-muted, border-muted. Light #edf2f4, dark #2a303b
1531
+ - `--fast-bg-faint` (Surfaces and borders): bg-faint, text-faint, border-faint. Light #f9fbfc, dark #1e222a
1532
+ - `--fast-pressed` (Surfaces and borders): bg-pressed, text-pressed, border-pressed. Light #e5e9ec, dark #333a47
1533
+ - `--fast-canvas` (Surfaces and borders): bg-canvas, text-canvas, border-canvas. Light #f3f6f8, dark #14171c
1534
+ - `--fast-line` (Surfaces and borders): bg-line, text-line, border-line. Light #d9e0e5, dark #2f3542
1535
+ - `--fast-line-strong` (Surfaces and borders): bg-line-strong, text-line-strong, border-line-strong. Light #cfd8df, dark #424959
1536
+ - `--fast-line-subtle` (Surfaces and borders): bg-line-subtle, text-line-subtle, border-line-subtle. Light #e5e9ec, dark #2a303b
1537
+ - `--fast-selected` (Surfaces and borders): bg-selected, text-selected, border-selected. Light var(--fast-primary-light), dark var(--fast-primary-pale)
1538
+ - `--fast-overlay` (Surfaces and borders): bg-overlay, text-overlay, border-overlay. Light rgba(17, 24, 39, 0.62), dark rgba(0, 0, 0, 0.6)
1539
+ - `--fast-scrim` (Surfaces and borders): bg-scrim, text-scrim, border-scrim. Light rgba(17, 24, 39, 0.12), dark rgba(0, 0, 0, 0.35)
1540
+ - `--fast-destructive` (Destructive): bg-destructive, text-destructive, border-destructive. Light #dc2626
1541
+ - `--fast-destructive-hover` (Destructive): bg-destructive-hover, text-destructive-hover, border-destructive-hover. Light #b91c1c
1542
+ - `--fast-destructive-active` (Destructive): bg-destructive-active, text-destructive-active, border-destructive-active. Light #991b1b
1543
+ - `--fast-destructive-disabled` (Destructive): bg-destructive-disabled, text-destructive-disabled, border-destructive-disabled. Light #fca5a5
1544
+ - `--fast-on-destructive` (Destructive): bg-on-destructive, text-on-destructive, border-on-destructive. Light #ffffff
1545
+ - `--fast-focus` (Focus): bg-focus, text-focus, border-focus. Light #00977a, dark #33deda
1546
+ - `--fast-tone-success-solid` (Semantic tones: solid / tint / wash / border / text): bg-success-solid, text-success-solid, border-success-solid. Light #16a34a, dark #22c55e
1547
+ - `--fast-tone-success-tint` (Semantic tones: solid / tint / wash / border / text): bg-success-tint, text-success-tint, border-success-tint. Light #dcfce7, dark #14391f
1548
+ - `--fast-tone-success-wash` (Semantic tones: solid / tint / wash / border / text): bg-success-wash, text-success-wash, border-success-wash. Light #ecfdf3, dark #0f2a1a
1549
+ - `--fast-tone-success-border` (Semantic tones: solid / tint / wash / border / text): bg-success-border, text-success-border, border-success-border. Light #bbf7d0, dark #166534
1550
+ - `--fast-tone-success-text` (Semantic tones: solid / tint / wash / border / text): bg-success-text, text-success-text, border-success-text. Light #15803d, dark #86efac
1551
+ - `--fast-tone-warning-solid` (Semantic tones: solid / tint / wash / border / text): bg-warning-solid, text-warning-solid, border-warning-solid. Light #f59e0b, dark #fbbf24
1552
+ - `--fast-tone-warning-tint` (Semantic tones: solid / tint / wash / border / text): bg-warning-tint, text-warning-tint, border-warning-tint. Light #fef3c7, dark #3f2f0b
1553
+ - `--fast-tone-warning-wash` (Semantic tones: solid / tint / wash / border / text): bg-warning-wash, text-warning-wash, border-warning-wash. Light #fffbeb, dark #2e2308
1554
+ - `--fast-tone-warning-border` (Semantic tones: solid / tint / wash / border / text): bg-warning-border, text-warning-border, border-warning-border. Light #fde68a, dark #78571a
1555
+ - `--fast-tone-warning-text` (Semantic tones: solid / tint / wash / border / text): bg-warning-text, text-warning-text, border-warning-text. Light #b45309, dark #fcd34d
1556
+ - `--fast-tone-error-solid` (Semantic tones: solid / tint / wash / border / text): bg-error-solid, text-error-solid, border-error-solid. Light #ef4444, dark #f87171
1557
+ - `--fast-tone-error-tint` (Semantic tones: solid / tint / wash / border / text): bg-error-tint, text-error-tint, border-error-tint. Light #fee2e2, dark #471b1b
1558
+ - `--fast-tone-error-wash` (Semantic tones: solid / tint / wash / border / text): bg-error-wash, text-error-wash, border-error-wash. Light #fef2f2, dark #331414
1559
+ - `--fast-tone-error-border` (Semantic tones: solid / tint / wash / border / text): bg-error-border, text-error-border, border-error-border. Light #fecaca, dark #7f2a2a
1560
+ - `--fast-tone-error-text` (Semantic tones: solid / tint / wash / border / text): bg-error-text, text-error-text, border-error-text. Light #b91c1c, dark #fca5a5
1561
+ - `--fast-tone-info-solid` (Semantic tones: solid / tint / wash / border / text): bg-info-solid, text-info-solid, border-info-solid. Light #00c5c1, dark #22d3ee
1562
+ - `--fast-tone-info-tint` (Semantic tones: solid / tint / wash / border / text): bg-info-tint, text-info-tint, border-info-tint. Light #e9fbfa, dark #0b3a3f
1563
+ - `--fast-tone-info-wash` (Semantic tones: solid / tint / wash / border / text): bg-info-wash, text-info-wash, border-info-wash. Light #f6ffff, dark #082e32
1564
+ - `--fast-tone-info-border` (Semantic tones: solid / tint / wash / border / text): bg-info-border, text-info-border, border-info-border. Light #b8e9e7, dark #155e67
1565
+ - `--fast-tone-info-text` (Semantic tones: solid / tint / wash / border / text): bg-info-text, text-info-text, border-info-text. Light #007d79, dark #67e8f9
1566
+ - `--fast-tone-info-soft` (Semantic tones: solid / tint / wash / border / text): bg-info-soft, text-info-soft, border-info-soft. Light #e9fbfa, dark #0b3a3f
1567
+ - `--fast-tone-neutral-solid` (Semantic tones: solid / tint / wash / border / text): bg-neutral-solid, text-neutral-solid, border-neutral-solid. Light #94a3b8, dark #9ca3af
1568
+ - `--fast-tone-neutral-tint` (Semantic tones: solid / tint / wash / border / text): bg-neutral-tint, text-neutral-tint, border-neutral-tint. Light #f1f5f9, dark #2a2f3a
1569
+ - `--fast-tone-neutral-wash` (Semantic tones: solid / tint / wash / border / text): bg-neutral-wash, text-neutral-wash, border-neutral-wash. Light #f9fbfc, dark #222731
1570
+ - `--fast-tone-neutral-border` (Semantic tones: solid / tint / wash / border / text): bg-neutral-border, text-neutral-border, border-neutral-border. Light #e5e9ec, dark #3b4252
1571
+ - `--fast-tone-neutral-text` (Semantic tones: solid / tint / wash / border / text): bg-neutral-text, text-neutral-text, border-neutral-text. Light #475569, dark #d1d5db
1572
+ - `--fast-tone-pending-solid` (Semantic tones: solid / tint / wash / border / text): bg-pending-solid, text-pending-solid, border-pending-solid. Light #ffd400, dark #ffd400
1573
+ - `--fast-tone-pending-tint` (Semantic tones: solid / tint / wash / border / text): bg-pending-tint, text-pending-tint, border-pending-tint. Light #fff9cc, dark #3b3410
1574
+ - `--fast-tone-pending-wash` (Semantic tones: solid / tint / wash / border / text): bg-pending-wash, text-pending-wash, border-pending-wash. Light #fffde6, dark #2b260b
1575
+ - `--fast-tone-pending-border` (Semantic tones: solid / tint / wash / border / text): bg-pending-border, text-pending-border, border-pending-border. Light #fff383, dark #6b5d14
1576
+ - `--fast-tone-pending-text` (Semantic tones: solid / tint / wash / border / text): bg-pending-text, text-pending-text, border-pending-text. Light #92400e, dark #fde68a
1577
+ - `--fast-tone-reserved-solid` (Semantic tones: solid / tint / wash / border / text): bg-reserved-solid, text-reserved-solid, border-reserved-solid. Light #7c3aed, dark #a78bfa
1578
+ - `--fast-tone-reserved-tint` (Semantic tones: solid / tint / wash / border / text): bg-reserved-tint, text-reserved-tint, border-reserved-tint. Light #ede9fe, dark #2e1f5e
1579
+ - `--fast-tone-reserved-wash` (Semantic tones: solid / tint / wash / border / text): bg-reserved-wash, text-reserved-wash, border-reserved-wash. Light #f5f3ff, dark #231847
1580
+ - `--fast-tone-reserved-border` (Semantic tones: solid / tint / wash / border / text): bg-reserved-border, text-reserved-border, border-reserved-border. Light #ddd6fe, dark #4c3a8c
1581
+ - `--fast-tone-reserved-text` (Semantic tones: solid / tint / wash / border / text): bg-reserved-text, text-reserved-text, border-reserved-text. Light #6d28d9, dark #c4b5fd
1582
+ - `--fast-chart-1` (Charts). Light var(--fast-primary-large)
1583
+ - `--fast-chart-2` (Charts). Light #f59e0b, dark #fbbf24
1584
+ - `--fast-chart-3` (Charts). Light #7c3aed, dark #a78bfa
1585
+ - `--fast-chart-4` (Charts). Light #16a34a, dark #22c55e
1586
+ - `--fast-chart-5` (Charts). Light #9ca3af
1587
+ - `--fast-chart-grid` (Charts). Light #f3f4f6, dark #2a2f3a
1588
+ - `--fast-chart-axis` (Charts). Light #6b7280, dark #9ca3af
1589
+ - `--fast-sky` (Decorative): bg-sky, text-sky, border-sky. Light #38bdf8
1590
+ - `--fast-sky-tint` (Decorative): bg-sky-tint, text-sky-tint, border-sky-tint. Light #e0f2fe, dark #0c3346
1591
+ - `--fast-sky-text` (Decorative): bg-sky-text, text-sky-text, border-sky-text. Light #0369a1, dark #7dd3fc
1592
+ - `--fast-hero-from` (Decorative): bg-hero-from, text-hero-from, border-hero-from. Light #101d27
1593
+ - `--fast-hero-via` (Decorative): bg-hero-via, text-hero-via, border-hero-via. Light #123f45
1594
+ - `--fast-hero-to` (Decorative): bg-hero-to, text-hero-to, border-hero-to. Light #087f7b
1595
+ - `--fast-font-family` (Type): font-sans. Light Inter, Arial, sans-serif
1596
+ - `--fast-font-family-mono` (Type): font-mono. Light ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace
1597
+ - `--fast-size-header` (Layout). Light 56px
1598
+ - `--fast-size-sidenav` (Layout). Light 256px
1599
+ - `--fast-size-sidenav-collapsed` (Layout). Light 64px
1600
+ - `--fast-container-max` (Layout). Light 1200px
1601
+ - `--fast-z-sticky` (Layout). Light 100
1602
+ - `--fast-radius-check` (Radius): rounded-check. Light 4px
1603
+ - `--fast-radius-sm` (Radius): rounded-sm. Light 6px
1604
+ - `--fast-radius-md` (Radius): rounded-md. Light 8px
1605
+ - `--fast-radius-tile` (Radius): rounded-tile. Light 10px
1606
+ - `--fast-radius-lg` (Radius): rounded-lg. Light 12px
1607
+ - `--fast-radius-xl` (Radius): rounded-xl. Light 16px
1608
+ - `--fast-radius-pill` (Radius): rounded-pill. Light 999px
1609
+ - `--fast-shadow-sm` (Elevation): shadow-sm. Light 0 1px 3px rgba(17, 24, 39, 0.06)
1610
+ - `--fast-shadow-card` (Elevation): shadow-card. Light 0 2px 4px rgba(17, 24, 39, 0.02)
1611
+ - `--fast-shadow-md` (Elevation): shadow-md. Light 0 16px 42px rgba(17, 24, 39, 0.18)
1612
+ - `--fast-shadow-lg` (Elevation): shadow-lg. Light 0 20px 48px rgba(17, 24, 39, 0.2)
1613
+ - `--fast-shadow-modal` (Elevation): shadow-modal. Light 0 36px 100px rgba(17, 24, 39, 0.4)
1614
+ - `--fast-shadow-up` (Elevation): shadow-up. Light 0 -10px 30px rgba(17, 24, 39, 0.05)
1615
+ - `--fast-shadow-primary` (Elevation): shadow-primary. Light 0 5px 14px color-mix(in srgb, var(--fast-primary) 20%, transparent)
1616
+ - `--fast-shadow-tile` (Elevation): shadow-tile. Light 0 5px 14px color-mix(in srgb, var(--fast-primary-active) 10%, transparent)
1617
+ - `--fast-shadow-nav` (Elevation): shadow-nav. Light 0 2px 6px color-mix(in srgb, var(--fast-primary-active) 8%, transparent)
1618
+ - `--fast-shadow-action` (Elevation): shadow-action. Light 0 6px 20px color-mix(in srgb, var(--fast-primary) 30%, transparent)
1619
+ - `--fast-text-display` (Type scale): text-display. Light 48px
1620
+ - `--fast-text-display-line-height` (Type scale): text-display. Light 110%
1621
+ - `--fast-text-display-font-weight` (Type scale): text-display. Light 900
1622
+ - `--fast-text-h1` (Type scale): text-h1. Light 36px
1623
+ - `--fast-text-h1-line-height` (Type scale): text-h1. Light 120%
1624
+ - `--fast-text-h1-font-weight` (Type scale): text-h1. Light 700
1625
+ - `--fast-text-h2` (Type scale): text-h2. Light 28px
1626
+ - `--fast-text-h2-line-height` (Type scale): text-h2. Light 130%
1627
+ - `--fast-text-h2-font-weight` (Type scale): text-h2. Light 700
1628
+ - `--fast-text-h3` (Type scale): text-h3. Light 22px
1629
+ - `--fast-text-h3-line-height` (Type scale): text-h3. Light 130%
1630
+ - `--fast-text-h3-font-weight` (Type scale): text-h3. Light 700
1631
+ - `--fast-text-h4` (Type scale): text-h4. Light 18px
1632
+ - `--fast-text-h4-line-height` (Type scale): text-h4. Light 150%
1633
+ - `--fast-text-h4-font-weight` (Type scale): text-h4. Light 600
1634
+ - `--fast-text-body-lg` (Type scale): text-body-lg. Light 16px
1635
+ - `--fast-text-body-lg-line-height` (Type scale): text-body-lg. Light 150%
1636
+ - `--fast-text-body` (Type scale): text-body. Light 14px
1637
+ - `--fast-text-body-line-height` (Type scale): text-body. Light 1.5
1638
+ - `--fast-text-body-sm` (Type scale): text-body-sm. Light 13px
1639
+ - `--fast-text-body-sm-line-height` (Type scale): text-body-sm. Light 150%
1640
+ - `--fast-text-caption` (Type scale): text-caption. Light 12px
1641
+ - `--fast-text-caption-line-height` (Type scale): text-caption. Light 150%
1642
+ - `--fast-text-caption-font-weight` (Type scale): text-caption. Light 500
1643
+ - `--fast-text-tiny` (Type scale): text-tiny. Light 11px
1644
+ - `--fast-text-tiny-line-height` (Type scale): text-tiny. Light 150%
1645
+ - `--fast-text-micro` (Type scale): text-micro. Light 10px
1646
+ - `--fast-text-micro-line-height` (Type scale): text-micro. Light 150%
1647
+ - `--fast-text-button` (Type scale): text-button. Light 14px
1648
+ - `--fast-text-button-line-height` (Type scale): text-button. Light 100%
1649
+ - `--fast-text-button-font-weight` (Type scale): text-button. Light 600
1650
+ - `--fast-text-label` (Type scale): text-label. Light 12px
1651
+ - `--fast-text-label-line-height` (Type scale): text-label. Light 140%
1652
+ - `--fast-text-label-font-weight` (Type scale): text-label. Light 600
1653
+ - `--fast-text-title` (Type scale): text-title. Light 28px
1654
+ - `--fast-text-title-line-height` (Type scale): text-title. Light 1.2
1655
+ - `--fast-text-title-font-weight` (Type scale): text-title. Light 700
1656
+ - `--fast-text-title-letter-spacing` (Type scale): text-title. Light -0.04em
1657
+ - `--fast-text-dialog-title` (Type scale): text-dialog-title. Light 23px
1658
+ - `--fast-text-dialog-title-line-height` (Type scale): text-dialog-title. Light 1.5
1659
+ - `--fast-text-dialog-title-font-weight` (Type scale): text-dialog-title. Light 700
1660
+ - `--fast-text-dialog-title-letter-spacing` (Type scale): text-dialog-title. Light -0.025em
1661
+ - `--fast-text-section` (Type scale): text-section. Light 18px
1662
+ - `--fast-text-section-line-height` (Type scale): text-section. Light 1.5
1663
+ - `--fast-text-section-font-weight` (Type scale): text-section. Light 700
1664
+ - `--fast-text-figure` (Type scale): text-figure. Light 24px
1665
+ - `--fast-text-figure-line-height` (Type scale): text-figure. Light 1.5
1666
+ - `--fast-text-figure-font-weight` (Type scale): text-figure. Light 700
1667
+
1668
+ ---
1669
+
1670
+ # Components reference
1671
+
1672
+ A star after a prop's name means it is required. Every component that renders an element also accepts `ref`, forwarded to it, and the props of the element it renders where its description says so. Text a user reads always arrives through props (see the "Prop conventions" section).
1673
+
1674
+ ## Main entry: `@primecoderin/fast-ui-react`
1675
+
1676
+ ### Components
1677
+
1678
+ #### Avatar
1679
+
1680
+ A round badge with a person's initials, or a generic person when there is no name. Decorative.
1681
+
1682
+ ```ts
1683
+ import { Avatar } from "@primecoderin/fast-ui-react";
1684
+ ```
1685
+
1686
+ | Prop | Type | Default | Description |
1687
+ | --- | --- | --- | --- |
1688
+ | `name` | `string` | `""` | The person's name; the initials of its first and last word are shown. |
1689
+ | `size` | `AvatarSize` | `32` | |
1690
+ | `tone` | `"solid" \| "soft"` | `"solid"` | |
1691
+ | `className` | `string` | | Extra classes on the root element, merged last so they win over the defaults. |
1692
+
1693
+ Tested examples: `stories/components/avatar.stories.tsx`, `stories/foundations/branding.stories.tsx`
1694
+
1695
+ #### Button
1696
+
1697
+ A native button in one of the variants: primary for the one main action of a view, secondary (the default) for the rest, subtle in a toolbar, destructive to delete, icon for a lone glyph. Its type is "button" unless another is given, so it never submits a form by accident.
1698
+
1699
+ ```ts
1700
+ import { Button } from "@primecoderin/fast-ui-react";
1701
+ ```
1702
+
1703
+ | Prop | Type | Default | Description |
1704
+ | --- | --- | --- | --- |
1705
+ | `icon` | `ReactNode` | | An icon sized by the button's size. Decorative: give an icon-only button an `aria-label`. |
1706
+ | `iconPosition` | `"before" \| "after"` | `"before"` | |
1707
+ | `disabledFocusable` | `boolean` | `false` | Looks disabled and ignores clicks, but stays in the tab order. |
1708
+ | `isLoading` | `boolean` | `false` | Shows a spinner and blocks clicks while keeping the button focusable. |
1709
+ | `size` | `"small" \| "medium" \| "large" \| null` | | |
1710
+ | `variant` | `"destructive" \| "primary" \| "secondary" \| "outline" \| "tertiary" \| "subtle" \| "icon" \| null` | | |
1711
+
1712
+ Tested examples: `stories/components/button.stories.tsx`, `stories/components/toast.stories.tsx`, `stories/foundations/branding.stories.tsx`, `stories/foundations/theming.stories.tsx`
1713
+
1714
+ #### CheckboxBox
1715
+
1716
+ The checkbox square on its own, for form fields (inside a label) and table selection. It is the one place the foundation's checkbox look is defined.
1717
+
1718
+ ```ts
1719
+ import { CheckboxBox } from "@primecoderin/fast-ui-react";
1720
+ ```
1721
+
1722
+ | Prop | Type | Default | Description |
1723
+ | --- | --- | --- | --- |
1724
+ | `checked` * | `boolean` | | Whether the box is ticked. |
1725
+ | `onCheckedChange` * | `(checked: boolean) => void` | | Called with the new state when the person ticks or clears the box (a click or Space). |
1726
+ | `indeterminate` | `boolean` | `false` | The mixed state, e.g. a table header when only some rows are selected. |
1727
+ | `size` | `"medium" \| "large"` | `"medium"` | "large" is a 20px box (the default is 17px). |
1728
+ | `disabled` | `boolean` | | Greys the box out; it cannot be ticked or focused. |
1729
+ | `aria-label` | `string` | | For a box with no visible label beside it. |
1730
+ | `aria-labelledby` | `string` | | The id of the element that names the box. Inside a form field Base UI names every control after the field's label; this gives a box its own name (a row of a list, one of several boxes in one field). |
1731
+ | `name` | `string` | | The field's name in a submitted form: the box's hidden input submits "on" while ticked. |
1732
+ | `inputRef` | `Ref<HTMLInputElement>` | | The box's hidden `<input type="checkbox">`, e.g. for a form library to focus the first invalid field. |
1733
+ | `onBlur` | `FocusEventHandler<HTMLElement>` | | The box lost focus. |
1734
+ | `stopClickPropagation` | `boolean` | `false` | Keeps a click on the box from also reaching the row or card around it. |
1735
+
1736
+ Tested examples: `stories/components/checkbox-box.stories.tsx`, `stories/foundations/branding.stories.tsx`
1737
+
1738
+ #### CodeSnippet
1739
+
1740
+ Code or a command in the system's monospace, with a button that copies it. A long line scrolls sideways (the box takes the keyboard focus then, so the keys scroll it); the text is plain, for the app to colour if it wants. Inline, it is a `<code>` in a sentence.
1741
+
1742
+ ```ts
1743
+ import { CodeSnippet } from "@primecoderin/fast-ui-react";
1744
+ ```
1745
+
1746
+ | Prop | Type | Default | Description |
1747
+ | --- | --- | --- | --- |
1748
+ | `code` * | `string` | | The code or command, as text. Line breaks are kept. |
1749
+ | `labels` | `CodeSnippetLabels` | | Needed for the copy button; leave it out for a snippet with no button. |
1750
+ | `variant` | `"inline" \| "block"` | `"block"` | "block" (default) is a box of its own; "inline" sits in a line of text, with no copy button. |
1751
+ | `language` | `string` | | The language, e.g. "tsx": it is written on the element as `data-language` for the app's own highlighter. |
1752
+ | `copiedDuration` | `number` | `2000` | How long "Copied" shows, in milliseconds. Default 2000. |
1753
+ | `className` | `string` | | Extra classes on the root element, merged last so they win over the defaults. |
1754
+
1755
+ Tested examples: `stories/components/code-snippet.stories.tsx`
1756
+
1757
+ #### Collapsible
1758
+
1759
+ One section that opens and closes under a button: "Advanced options", "Show details". The button carries `aria-expanded`. For several in a stack, see Accordion.
1760
+
1761
+ ```ts
1762
+ import { Collapsible } from "@primecoderin/fast-ui-react";
1763
+ ```
1764
+
1765
+ | Prop | Type | Default | Description |
1766
+ | --- | --- | --- | --- |
1767
+ | `trigger` * | `ReactNode` | | The button's content: the section's name. |
1768
+ | `children` * | `ReactNode` | | What shows while the section is open. |
1769
+ | `open` | `boolean` | | Whether the section is open. Leave it out to let the section keep its own. |
1770
+ | `defaultOpen` | `boolean` | `false` | Whether the section starts open, when it keeps its own state. |
1771
+ | `onOpenChange` | `((open: boolean) => void)` | | Called with the new state when the person opens or closes the section. |
1772
+ | `disabled` | `boolean` | `false` | Not interactive, and shown as disabled. |
1773
+ | `className` | `string` | | Extra classes on the root element, merged last so they win over the defaults. |
1774
+
1775
+ Tested examples: `stories/components/collapsible.stories.tsx`
1776
+
1777
+ #### Container
1778
+
1779
+ A page's content, centred, no wider than `size`, with room at both edges on a narrow screen.
1780
+
1781
+ ```ts
1782
+ import { Container } from "@primecoderin/fast-ui-react";
1783
+ ```
1784
+
1785
+ | Prop | Type | Default | Description |
1786
+ | --- | --- | --- | --- |
1787
+ | `size` | `"default" \| "narrow" \| "wide" \| "full"` | `"default"` | |
1788
+ | `as` | `LayoutElement` | `"div"` | The element: a `div` (default), or a landmark where the container is one. |
1789
+
1790
+ Tested examples: `stories/components/container.stories.tsx`
1791
+
1792
+ #### ContextMenu
1793
+
1794
+ A menu that opens where the pointer is, from a right click or a long press on its area, or from the keyboard's Menu key or Shift and F10 while the area (or something in it) has the focus. The area is a tab stop for that, and the browser sends those keys to it as a `contextmenu` event. Its items are the same as Menu's, and closing the menu puts the focus back. A context menu is a shortcut, never the only way: whatever it does must be reachable another way too.
1795
+
1796
+ ```ts
1797
+ import { ContextMenu } from "@primecoderin/fast-ui-react";
1798
+ ```
1799
+
1800
+ | Prop | Type | Default | Description |
1801
+ | --- | --- | --- | --- |
1802
+ | `menu` * | `ReactNode` | | The menu's items: MenuItem, MenuSeparator, MenuSubmenu and the rest of Menu's parts. |
1803
+ | `children` * | `ReactNode` | | The area that opens the menu when it is right-clicked or long-pressed. |
1804
+ | `aria-label` | `string` | | Names the area, for a screen reader to say what has a menu: with it, the area is a named group. |
1805
+ | `className` | `string` | | Extra classes on the root element, merged last so they win over the defaults. |
1806
+
1807
+ Tested examples: `stories/components/context-menu.stories.tsx`
1808
+
1809
+ #### FloatingActionButton
1810
+
1811
+ The page's main action as a round button fixed to a corner: "New order", "Compose". With `actions` it opens a menu of several above it. It sits on the sticky layer (`--fast-z-sticky`), below popups and dialogs. Use one per screen, for the action people come to the screen for.
1812
+
1813
+ ```ts
1814
+ import { FloatingActionButton } from "@primecoderin/fast-ui-react";
1815
+ ```
1816
+
1817
+ | Prop | Type | Default | Description |
1818
+ | --- | --- | --- | --- |
1819
+ | `icon` * | `ReactNode` | | The button's glyph, e.g. a plus. |
1820
+ | `aria-label` | `string` | | The accessible name, e.g. "New order". An extended button (with `children`) is named by its text instead. |
1821
+ | `children` | `ReactNode` | | A label beside the glyph, making an extended button. |
1822
+ | `onClick` | `(() => void)` | | What the button does. Leave it out when `actions` is given: the button then opens a menu. |
1823
+ | `actions` | `ReactNode` | | Menu items (MenuItem and the rest of Menu's parts) the button opens above it, for several actions. |
1824
+ | `position` | `"bottom-end" \| "bottom-start"` | `"bottom-end"` | The corner: the end edge (default; the right, in left to right) or the start edge. |
1825
+ | `className` | `string` | | Extra classes on the root element, merged last so they win over the defaults. |
1826
+
1827
+ Tested examples: `stories/components/floating-action-button.stories.tsx`
1828
+
1829
+ #### Grid
1830
+
1831
+ Children in equal columns: a set number (`columns`) or as many as fit (`minColumnWidth`, for cards that should wrap). A child that must span columns or rows is the app's own CSS to say.
1832
+
1833
+ ```ts
1834
+ import { Grid } from "@primecoderin/fast-ui-react";
1835
+ ```
1836
+
1837
+ | Prop | Type | Default | Description |
1838
+ | --- | --- | --- | --- |
1839
+ | `columns` | `1 \| 6 \| 12 \| 5 \| 4 \| 3 \| 2` | `1` | A fixed number of equal columns. Give this or `minColumnWidth`. |
1840
+ | `minColumnWidth` | `string` | | As many equal columns as fit, none narrower than this CSS length (`"16rem"`, `"240px"`): the grid wraps by itself on a narrow screen, with no breakpoints. Wins over `columns`. |
1841
+ | `gap` | `0 \| 1 \| 6 \| 12 \| 5 \| 4 \| 3 \| 2 \| 8 \| 10` | `4` | The space between cells, in steps of 4px: 4 is 16px. Default 4. |
1842
+ | `as` | `LayoutElement` | `"div"` | The element: a `div` (default), or a landmark or list where the grid is one. |
1843
+
1844
+ Tested examples: `stories/components/grid.stories.tsx`
1845
+
1846
+ #### HoverPopover
1847
+
1848
+ A panel that opens while the pointer is over its trigger, and stays open while it is over the panel. The trigger is a button, so Enter or Space opens it from the keyboard and Escape closes it. Focus is not moved into it, so a keyboard user stays on the trigger; for a panel that should take focus, use a menu or dialog instead.
1849
+
1850
+ ```ts
1851
+ import { HoverPopover } from "@primecoderin/fast-ui-react";
1852
+ ```
1853
+
1854
+ | Prop | Type | Default | Description |
1855
+ | --- | --- | --- | --- |
1856
+ | `trigger` * | `ReactElement<unknown, string \| JSXElementConstructor<any>>` | | The element that opens the popover. It is the trigger itself, so it keeps its own props. |
1857
+ | `children` * | `ReactNode` | | The content. |
1858
+ | `aria-label` * | `string` | | Accessible name of the popover. |
1859
+ | `side` | `"top" \| "bottom" \| "left" \| "right" \| "inline-start" \| "inline-end"` | `"bottom"` | `inline-end` follows the text direction. |
1860
+ | `align` | `"center" \| "start" \| "end"` | `"center"` | |
1861
+ | `nativeButton` | `boolean` | `true` | Set to false when the trigger is not a `<button>`, e.g. a `<span>`; Base UI then adds the button role itself. |
1862
+
1863
+ Tested examples: `stories/components/hover-popover.stories.tsx`
1864
+
1865
+ #### IconTile
1866
+
1867
+ An icon on a rounded tinted square, to head a card, a section or a row.
1868
+
1869
+ ```ts
1870
+ import { IconTile } from "@primecoderin/fast-ui-react";
1871
+ ```
1872
+
1873
+ | Prop | Type | Default | Description |
1874
+ | --- | --- | --- | --- |
1875
+ | `icon` * | `ReactNode` | | An icon sized by font-size. Decorative: hidden from assistive technology. |
1876
+ | `tone` | `IconTileTone` | `"brand"` | |
1877
+ | `size` | `"small" \| "medium" \| "large"` | `"medium"` | |
1878
+ | `className` | `string` | | Extra classes on the root element, merged last so they win over the defaults. |
1879
+
1880
+ Tested examples: `stories/components/icon-tile.stories.tsx`
1881
+
1882
+ #### InlineError
1883
+
1884
+ A failure that belongs to a part of a page, in one line: icon, message, optional retry.
1885
+
1886
+ ```ts
1887
+ import { InlineError } from "@primecoderin/fast-ui-react";
1888
+ ```
1889
+
1890
+ | Prop | Type | Default | Description |
1891
+ | --- | --- | --- | --- |
1892
+ | `message` * | `string` | | |
1893
+ | `retryLabel` | `string` | | With `onRetry`, adds a retry button after the message. |
1894
+ | `onRetry` | `(() => void)` | | |
1895
+ | `className` | `string` | | Extra classes on the root element, merged last so they win over the defaults. |
1896
+
1897
+ Tested examples: `stories/components/inline-error.stories.tsx`
1898
+
1899
+ #### Kbd
1900
+
1901
+ A keyboard key, drawn as a small key cap: "Press <Kbd>Esc</Kbd> to close". It is a `<kbd>`, so a screen reader knows it is a key. For a combination write one per key, `<Kbd>Ctrl</Kbd> + <Kbd>K</Kbd>`.
1902
+
1903
+ ```ts
1904
+ import { Kbd } from "@primecoderin/fast-ui-react";
1905
+ ```
1906
+
1907
+ | Prop | Type | Default | Description |
1908
+ | --- | --- | --- | --- |
1909
+ | `children` * | `ReactNode` | | The key as the person reads it: "Ctrl", "Esc", "K", "⌘". |
1910
+ | `className` | `string` | | Extra classes on the root element, merged last so they win over the defaults. |
1911
+
1912
+ Tested examples: `stories/components/kbd.stories.tsx`
1913
+
1914
+ #### Link
1915
+
1916
+ Text that goes somewhere. A plain `<a>` by default; with `render` it is the app's router link, so navigation stays on the router and the look stays here. Its text, not colour alone, says it is a link: it is underlined on hover and focus.
1917
+
1918
+ ```ts
1919
+ import { Link } from "@primecoderin/fast-ui-react";
1920
+ ```
1921
+
1922
+ | Prop | Type | Default | Description |
1923
+ | --- | --- | --- | --- |
1924
+ | `tone` | `"brand" \| "inherit"` | `"brand"` | "brand" (default) is teal text; "inherit" takes the colour of the text around it. |
1925
+ | `underline` | `"hover" \| "always"` | `"hover"` | When the underline shows: on hover and focus (default), or always. Links inside a paragraph should always. |
1926
+ | `render` | `ReactElement<unknown, string \| JSXElementConstructor<any>>` | | Render another element in place of the `<a>`, with this link's look and props: the app's router link, `render={<RouterLink to="/orders" />}`. The element keeps its own `href` or `to`. |
1927
+
1928
+ Tested examples: `stories/components/link.stories.tsx`
1929
+
1930
+ #### Menu
1931
+
1932
+ A menu that opens from a button: items, radio choices, separators.
1933
+
1934
+ ```ts
1935
+ import { Menu } from "@primecoderin/fast-ui-react";
1936
+ ```
1937
+
1938
+ | Prop | Type | Default | Description |
1939
+ | --- | --- | --- | --- |
1940
+ | `trigger` * | `ReactElement<unknown, string \| JSXElementConstructor<any>>` | | The button that opens the menu. It is the trigger itself, so it keeps its own look and props. |
1941
+ | `children` * | `ReactNode` | | The content. |
1942
+ | `align` | `"center" \| "start" \| "end"` | `"end"` | Which edge of the trigger the menu lines up with. |
1943
+ | `size` | `"large" \| "default"` | `"default"` | "large" is the roomier menu: 40px rows and 16px text. |
1944
+
1945
+ Tested examples: `stories/components/menu.stories.tsx`
1946
+
1947
+ #### MenuCheckboxItem
1948
+
1949
+ An option that is on or off, with a check at the end edge while it is on ("Show grid", "Word wrap").
1950
+
1951
+ ```ts
1952
+ import { MenuCheckboxItem } from "@primecoderin/fast-ui-react";
1953
+ ```
1954
+
1955
+ | Prop | Type | Default | Description |
1956
+ | --- | --- | --- | --- |
1957
+ | `checked` * | `boolean` | | Whether the option is on. |
1958
+ | `onCheckedChange` * | `(checked: boolean) => void` | | Called with the new state when the person chooses the item. |
1959
+ | `children` * | `ReactNode` | | The content. |
1960
+ | `disabled` | `boolean` | | Not interactive, and shown as disabled. |
1961
+ | `closeOnClick` | `boolean` | `false` | Close the menu when the item is chosen. Default false: a person often sets several options in one visit. |
1962
+
1963
+
1964
+ #### MenuGroup
1965
+
1966
+ Items under a small heading: "Sort by", "View".
1967
+
1968
+ ```ts
1969
+ import { MenuGroup } from "@primecoderin/fast-ui-react";
1970
+ ```
1971
+
1972
+ | Prop | Type | Default | Description |
1973
+ | --- | --- | --- | --- |
1974
+ | `label` * | `string` | | The group's name: shown above its items in small type, and its accessible name. |
1975
+ | `children` * | `ReactNode` | | The content. |
1976
+
1977
+
1978
+ #### MenuItem
1979
+
1980
+ One command of a `Menu`: a label with an optional icon. `tone="danger"` marks one that deletes or removes.
1981
+
1982
+ ```ts
1983
+ import { MenuItem } from "@primecoderin/fast-ui-react";
1984
+ ```
1985
+
1986
+ | Prop | Type | Default | Description |
1987
+ | --- | --- | --- | --- |
1988
+ | `children` * | `ReactNode` | | The content. |
1989
+ | `icon` | `ReactNode` | | An icon sized by font-size, before the label. It takes the row's colour. |
1990
+ | `onClick` | `(() => void)` | | |
1991
+ | `disabled` | `boolean` | | Not interactive, and shown as disabled. |
1992
+ | `tone` | `"default" \| "danger"` | `"default"` | "danger" for an action that deletes or removes. |
1993
+
1994
+
1995
+ #### MenuLinkItem
1996
+
1997
+ An item that goes to a page: a real link, so it can be opened in a new tab and a screen reader announces it as one.
1998
+
1999
+ ```ts
2000
+ import { MenuLinkItem } from "@primecoderin/fast-ui-react";
2001
+ ```
2002
+
2003
+ | Prop | Type | Default | Description |
2004
+ | --- | --- | --- | --- |
2005
+ | `children` * | `ReactNode` | | The content. |
2006
+ | `href` | `string` | | |
2007
+ | `icon` | `ReactNode` | | An icon sized by font-size, before the label. |
2008
+ | `render` | `ReactElement<unknown, string \| JSXElementConstructor<any>>` | | The app's router link, `<RouterLink to="/settings" />`, to render in place of the plain `<a>`. |
2009
+
2010
+
2011
+ #### MenuRadioGroup
2012
+
2013
+ A set of mutually exclusive choices; the one in force is ticked.
2014
+
2015
+ ```ts
2016
+ import { MenuRadioGroup } from "@primecoderin/fast-ui-react";
2017
+ ```
2018
+
2019
+ | Prop | Type | Default | Description |
2020
+ | --- | --- | --- | --- |
2021
+ | `value` * | `TValue` | | The current value. Controlled: the caller keeps this state. |
2022
+ | `onValueChange` * | `(value: TValue) => void` | | Called with the new value when the user picks one; set `value` from it. |
2023
+ | `aria-label` * | `string` | | Accessible name of the group, e.g. "Language". |
2024
+ | `children` * | `ReactNode` | | The content. |
2025
+
2026
+
2027
+ #### MenuRadioItem
2028
+
2029
+ A radio choice: the label, with a check at the end edge when it is the one in force.
2030
+
2031
+ ```ts
2032
+ import { MenuRadioItem } from "@primecoderin/fast-ui-react";
2033
+ ```
2034
+
2035
+ | Prop | Type | Default | Description |
2036
+ | --- | --- | --- | --- |
2037
+ | `value` * | `string` | | The current value. Controlled: the caller keeps this state. |
2038
+ | `children` * | `ReactNode` | | The content. |
2039
+
2040
+
2041
+ #### MenuSeparator
2042
+
2043
+ A rule between groups of items, e.g. before a destructive one.
2044
+
2045
+ ```ts
2046
+ import { MenuSeparator } from "@primecoderin/fast-ui-react";
2047
+ ```
2048
+
2049
+ This component takes no props.
2050
+
2051
+
2052
+ #### MenuSubmenu
2053
+
2054
+ An item that opens a menu of its own beside it, with a chevron that points the way the page reads. The arrow keys open it (toward the end edge) and close it (toward the start edge).
2055
+
2056
+ ```ts
2057
+ import { MenuSubmenu } from "@primecoderin/fast-ui-react";
2058
+ ```
2059
+
2060
+ | Prop | Type | Default | Description |
2061
+ | --- | --- | --- | --- |
2062
+ | `label` * | `string` | | The item that opens the submenu. |
2063
+ | `children` * | `ReactNode` | | The submenu's items. |
2064
+ | `icon` | `ReactNode` | | An icon sized by font-size, before the label. |
2065
+ | `disabled` | `boolean` | | Not interactive, and shown as disabled. |
2066
+
2067
+
2068
+ #### OtpInput
2069
+
2070
+ A code entered one digit per box, for the codes emailed to a user. Typing moves on to the next box, Backspace on an empty box steps back, the arrow keys move between boxes. A pasted code (Ctrl/Cmd+V, the context menu, a long press on a phone) or one the browser fills in from a message fills all the boxes at once, wherever it lands, with anything that is not a digit left out. Copy and cut take the whole code, not one box of it. The boxes read left to right in every language, as the digits of a number do.
2071
+
2072
+ ```ts
2073
+ import { OtpInput } from "@primecoderin/fast-ui-react";
2074
+ ```
2075
+
2076
+ | Prop | Type | Default | Description |
2077
+ | --- | --- | --- | --- |
2078
+ | `value` * | `string` | | The digits typed so far, as text: "" up to a full code. Never holds a gap, so "12" is the first two boxes. |
2079
+ | `onValueChange` * | `(value: string) => void` | | Called with the new digits as the person types, deletes, pastes or cuts. |
2080
+ | `label` * | `string` | | Names the whole code for assistive technology, such as "Verification code". |
2081
+ | `getDigitLabel` * | `(position: number, total: number) => string` | | Names one box (`position` counts from 1), such as "Digit 3 of 6". |
2082
+ | `length` | `number` | `DEFAULT_LENGTH` | How many boxes; the code's length. |
2083
+ | `invalid` | `boolean` | `false` | Marks every box as holding a rejected code. Say why in text next to the input and point `aria-describedby` at it. |
2084
+ | `disabled` | `boolean` | `false` | Dims the boxes and takes them out of the tab order. |
2085
+ | `readOnly` | `boolean` | `false` | The code cannot be edited (typing, Backspace, paste and cut do nothing), but is still shown and read (a check is under way). |
2086
+ | `autoFocus` | `boolean` | `false` | Puts the cursor in the first box when the input appears. |
2087
+ | `aria-describedby` | `string` | | The ids of the text that describes the code, such as why it was rejected; given to every box. |
2088
+ | `className` | `string` | | Classes for the row of boxes, merged last. |
2089
+
2090
+ Tested examples: `stories/components/otp-input.stories.tsx`
2091
+
2092
+ #### Popover
2093
+
2094
+ A panel that opens from a button and holds controls the person works in, such as a column chooser: a heading, a few rows of checkboxes, a link. Focus moves into it when it opens, Escape or a click outside closes it, and focus returns to the button. For a list of actions use Menu; for a panel that only explains, HoverPopover.
2095
+
2096
+ ```ts
2097
+ import { Popover } from "@primecoderin/fast-ui-react";
2098
+ ```
2099
+
2100
+ | Prop | Type | Default | Description |
2101
+ | --- | --- | --- | --- |
2102
+ | `trigger` * | `ReactElement<unknown, string \| JSXElementConstructor<any>>` | | The button that opens the panel. It is the trigger itself, so it keeps its own look and props. |
2103
+ | `children` * | `ReactNode` | | The content. |
2104
+ | `aria-label` * | `string` | | Accessible name of the panel. |
2105
+ | `align` | `"center" \| "start" \| "end"` | `"end"` | Which edge of the trigger the panel lines up with. |
2106
+ | `className` | `string` | | Extra classes for the panel, e.g. its width. |
2107
+
2108
+ Tested examples: `stories/components/popover.stories.tsx`
2109
+
2110
+ #### ProgressBar
2111
+
2112
+ A thin bar with a block sliding across it: something is loading, with no way to say how far. For a visitor who asks for reduced motion the block does not move: the whole bar shows, faded.
2113
+
2114
+ ```ts
2115
+ import { ProgressBar } from "@primecoderin/fast-ui-react";
2116
+ ```
2117
+
2118
+ | Prop | Type | Default | Description |
2119
+ | --- | --- | --- | --- |
2120
+ | `label` * | `string` | | What is in progress, e.g. "Loading". |
2121
+ | `valueText` | `string` | | What a screen reader says in place of a value, after the label, e.g. "Loading the list". The bar has no value (it cannot say how far), so without this it has no value text at all and a screen reader announces the label and the progress bar. |
2122
+ | `className` | `string` | | Classes for the bar, e.g. a margin. |
2123
+
2124
+ Tested examples: `stories/components/progress-bar.stories.tsx`
2125
+
2126
+ #### Rating
2127
+
2128
+ A rating of stars. Each star is a radio button, so the arrow keys move and choose, Tab enters the group once, and a screen reader announces each star by `getValueLabel`. The stars under the pointer preview the choice. With `readOnly` it is an image that shows the rating. Whole stars only.
2129
+
2130
+ ```ts
2131
+ import { Rating } from "@primecoderin/fast-ui-react";
2132
+ ```
2133
+
2134
+ | Prop | Type | Default | Description |
2135
+ | --- | --- | --- | --- |
2136
+ | `value` * | `number` | | The rating, from 0 (none) to `max`. |
2137
+ | `getValueLabel` * | `(value: number, max: number) => string` | | What a rating of `value` out of `max` is called, e.g. `(n, max) => "3 of 5 stars"`. It names each star and the shown rating. |
2138
+ | `onValueChange` | `((value: number) => void)` | | Called with the new rating. Leave it out, or set `readOnly`, to only show a rating. |
2139
+ | `max` | `number` | `5` | How many stars. Default 5. |
2140
+ | `readOnly` | `boolean` | `false` | Show the rating without letting it change: the stars are an image, not controls. |
2141
+ | `disabled` | `boolean` | `false` | Dims the stars, which cannot be chosen or focused. |
2142
+ | `clearable` | `boolean` | `false` | Pressing the chosen star again sets the rating back to 0. |
2143
+ | `size` | `"small" \| "medium" \| "large"` | `"medium"` | The stars' size: small 16px, medium 20px (the default), large 26px. Small and medium stars that can be chosen each sit in a 24px box, the least size of a target, so they stand further apart than read-only ones. |
2144
+ | `invalid` | `boolean` | `false` | Marks the group invalid for assistive technology. |
2145
+ | `required` | `boolean` | `false` | Marks the group required for assistive technology; a field's label shows the asterisk. |
2146
+ | `name` | `string` | | The field's name in a submitted form. |
2147
+ | `aria-label` | `string` | | Accessible name of the group, e.g. "Rate this order". |
2148
+ | `aria-labelledby` | `string` | | The id of the element that names the group, such as a field's label. A read-only rating adds the rating shown to that name. |
2149
+ | `aria-describedby` | `string` | | The ids of the field's message and hint, read after the name. |
2150
+ | `onBlur` | `(() => void)` | | The group was left. |
2151
+ | `inputRef` | `Ref<HTMLInputElement>` | | The first star's radio input, for a form library to focus the first invalid field. |
2152
+ | `className` | `string` | | Classes for the row of stars, merged last. |
2153
+
2154
+ Tested examples: `stories/components/rating.stories.tsx`
2155
+
2156
+ #### ScrollArea
2157
+
2158
+ A region that scrolls with the design system's own slim scrollbars, which show while the pointer is over it or it scrolls. The browser's scrolling still does the work (wheel, touch, keys), so it feels native. Give it a height or width through `style`.
2159
+
2160
+ ```ts
2161
+ import { ScrollArea } from "@primecoderin/fast-ui-react";
2162
+ ```
2163
+
2164
+ | Prop | Type | Default | Description |
2165
+ | --- | --- | --- | --- |
2166
+ | `children` * | `ReactNode` | | The content. |
2167
+ | `aria-label` * | `string` | | Accessible name of the scrolling region, e.g. "Activity log". The region takes the keyboard focus, so the arrow keys, Page Up and Page Down scroll it for a person who cannot use a pointer. |
2168
+ | `orientation` | `"vertical" \| "horizontal" \| "both"` | `"vertical"` | Which way it scrolls: up and down (default), sideways, or both. |
2169
+ | `style` | `CSSProperties` | | The size that makes it scroll: `{ maxHeight: 320 }`. Without one the area is as tall as its content and has nothing to scroll. A number is pixels. |
2170
+ | `className` | `string` | | Extra classes on the root element, merged last so they win over the defaults. |
2171
+
2172
+ Tested examples: `stories/components/scroll-area.stories.tsx`
2173
+
2174
+ #### SegmentedControl
2175
+
2176
+ A few mutually exclusive choices in a grey pill, the chosen one raised on white in teal text. For a view filter that applies at once (All, Active, Inactive); the arrow keys move and choose, like a radio group, which it is.
2177
+
2178
+ ```ts
2179
+ import { SegmentedControl } from "@primecoderin/fast-ui-react";
2180
+ ```
2181
+
2182
+ | Prop | Type | Default | Description |
2183
+ | --- | --- | --- | --- |
2184
+ | `items` * | `readonly SegmentedItem[]` | | The choices, in order. Each `value` must be unique: it is the choice's key and what `onValueChange` reports. |
2185
+ | `value` * | `string` | | The `value` of the chosen item. |
2186
+ | `onValueChange` * | `(value: string) => void` | | Called with the `value` of the item chosen, by a click or by the arrow keys. |
2187
+ | `aria-label` * | `string` | | Accessible name of the group, e.g. "Filter by status". |
2188
+ | `fill` | `boolean` | `false` | Stretch to the width of the container and share it equally; a long label may wrap onto a second line. |
2189
+ | `className` | `string` | | Classes for the grey pill around the choices, merged last. |
2190
+
2191
+ Tested examples: `stories/components/segmented-control.stories.tsx`, `stories/foundations/branding.stories.tsx`
2192
+
2193
+ #### Separator
2194
+
2195
+ A thin rule between groups. It is `role="separator"`, so a screen reader announces the break.
2196
+
2197
+ ```ts
2198
+ import { Separator } from "@primecoderin/fast-ui-react";
2199
+ ```
2200
+
2201
+ | Prop | Type | Default | Description |
2202
+ | --- | --- | --- | --- |
2203
+ | `orientation` | `"vertical" \| "horizontal"` | `"horizontal"` | A horizontal rule (default) or a vertical one, which fills the height of a row. |
2204
+ | `tone` | `"strong" \| "default"` | `"default"` | "strong" is darker, for a rule that must be seen on a tinted surface. |
2205
+ | `className` | `string` | | Extra classes on the root element, merged last so they win over the defaults. |
2206
+
2207
+ Tested examples: `stories/components/separator.stories.tsx`
2208
+
2209
+ #### SkeletonCard
2210
+
2211
+ Placeholder for a card: a heading line and two lines of text.
2212
+
2213
+ ```ts
2214
+ import { SkeletonCard } from "@primecoderin/fast-ui-react";
2215
+ ```
2216
+
2217
+ | Prop | Type | Default | Description |
2218
+ | --- | --- | --- | --- |
2219
+ | `label` * | `string` | | What is loading, for assistive technology, e.g. "Loading results". |
2220
+
2221
+
2222
+ #### SkeletonItem
2223
+
2224
+ One placeholder bar. Decorative: the region around it carries the label.
2225
+
2226
+ ```ts
2227
+ import { SkeletonItem } from "@primecoderin/fast-ui-react";
2228
+ ```
2229
+
2230
+ | Prop | Type | Default | Description |
2231
+ | --- | --- | --- | --- |
2232
+ | `size` | `12 \| 16` | `12` | The bar's height in pixels: 12 (default) for a line of text, 16 for a heading. |
2233
+ | `width` | `string` | | The bar's width as a CSS length, e.g. "60%". Without it the bar is as wide as its container. |
2234
+ | `className` | `string` | | Classes for the bar, e.g. `flex-1` in a row. |
2235
+
2236
+
2237
+ #### SkeletonTable
2238
+
2239
+ Placeholder rows for a table that is loading.
2240
+
2241
+ ```ts
2242
+ import { SkeletonTable } from "@primecoderin/fast-ui-react";
2243
+ ```
2244
+
2245
+ | Prop | Type | Default | Description |
2246
+ | --- | --- | --- | --- |
2247
+ | `label` * | `string` | | What is loading, for assistive technology, e.g. "Loading results". |
2248
+ | `rows` | `number` | `5` | How many rows. Default 5. |
2249
+ | `columns` | `number` | `4` | How many columns in each row. Default 4. |
2250
+
2251
+
2252
+ #### SkeletonText
2253
+
2254
+ Placeholder lines for text that has not arrived.
2255
+
2256
+ ```ts
2257
+ import { SkeletonText } from "@primecoderin/fast-ui-react";
2258
+ ```
2259
+
2260
+ | Prop | Type | Default | Description |
2261
+ | --- | --- | --- | --- |
2262
+ | `label` * | `string` | | What is loading, for assistive technology, e.g. "Loading results". |
2263
+ | `lines` | `number` | `3` | How many lines; the last is shorter, as a paragraph's is. Default 3. |
2264
+
2265
+ Tested examples: `stories/components/skeleton.stories.tsx`
2266
+
2267
+ #### Slider
2268
+
2269
+ A slider for a number between `min` and `max`, or for a range of two. The arrow keys move a thumb by `step`, Page Up and Page Down by `largeStep`, Home and End to the ends; dragging the track moves the nearest thumb. It follows the page's direction: in right to left the minimum is at the right.
2270
+
2271
+ ```ts
2272
+ import { Slider } from "@primecoderin/fast-ui-react";
2273
+ ```
2274
+
2275
+ | Prop | Type | Default | Description |
2276
+ | --- | --- | --- | --- |
2277
+ | `value` * | `TValue` | | One number for one thumb, an array for a range (a thumb for each number, kept in order). |
2278
+ | `onValueChange` * | `(value: TValue extends number ? number : number[]) => void` | | Called while the thumb moves, with a number (one thumb) or an array (a range). |
2279
+ | `onValueCommitted` | `((value: TValue extends number ? number : number[]) => void)` | | Called once a drag or key press ends: the moment to save, where `onValueChange` would be too often. |
2280
+ | `min` | `number` | `0` | The least value, at the start of the track (Home goes there). Default 0. |
2281
+ | `max` | `number` | `100` | The greatest value, at the end of the track (End goes there). Default 100. |
2282
+ | `step` | `number` | `1` | What one arrow key press changes. Default 1. |
2283
+ | `largeStep` | `number` | | What Page Up and Page Down (or Shift and an arrow) change. Default 10. |
2284
+ | `minStepsBetweenValues` | `number` | | The least distance between two thumbs of a range, in steps. |
2285
+ | `disabled` | `boolean` | `false` | Greys the slider out; its thumbs cannot be moved or focused. |
2286
+ | `invalid` | `boolean` | `false` | Marks each thumb's range input invalid (`aria-invalid`) for assistive technology. |
2287
+ | `getValueText` | `((formattedValue: string, value: number, index: number) => string)` | | Writes a value as text for a screen reader, e.g. `(text) => `${text} km``. The number as formatted if omitted. |
2288
+ | `aria-label` | `string` | | The thumb's name, for one thumb with no label element of its own. A range names each thumb with `thumbLabels`. |
2289
+ | `aria-labelledby` | `string` | | The id of the element that names the slider, such as a field's label. |
2290
+ | `aria-describedby` | `string` | | The ids of the field's message and hint, read after the name. Given to each thumb's range input. |
2291
+ | `thumbLabels` | `readonly string[]` | | Names the thumbs of a range in order, e.g. ["Minimum price", "Maximum price"]. |
2292
+ | `name` | `string` | | The field's name in a submitted form. |
2293
+ | `onBlur` | `(() => void)` | | The slider was left. |
2294
+ | `id` | `string` | | The id of the first thumb's element: the `<div>` drawn on the track, not the range input inside it, whose id Base UI sets. So a `<label htmlFor>` cannot name the slider; name it with `aria-labelledby` or `aria-label`. |
2295
+ | `className` | `string` | | Classes for the slider's outer element (the full-width group around the track), merged last. |
2296
+
2297
+ Tested examples: `stories/components/slider.stories.tsx`
2298
+
2299
+ #### Spinner
2300
+
2301
+ A spinning arc on a faint ring.
2302
+
2303
+ ```ts
2304
+ import { Spinner } from "@primecoderin/fast-ui-react";
2305
+ ```
2306
+
2307
+ | Prop | Type | Default | Description |
2308
+ | --- | --- | --- | --- |
2309
+ | `size` | `"medium" \| "large" \| "tiny"` | | "tiny" (14px) inside a button, "medium" (20px, the default) on its own, "large" (32px) in an empty area. |
2310
+ | `label` | `string` | | What is loading, e.g. "Loading results". With a label the spinner is a status region (`role="status"`): it goes on the page empty and the label goes into it a moment later, as visually hidden text, so that it is a change screen readers report rather than a region that arrives with its text, which they often miss. Without a label it is decorative (inside a busy button, say). |
2311
+ | `inherit` | `boolean` | `false` | Draw in the colour of the surrounding text instead of the teal on a grey ring. |
2312
+ | `className` | `string` | | Classes for the ring itself, e.g. a margin. |
2313
+
2314
+ Tested examples: `stories/components/spinner.stories.tsx`
2315
+
2316
+ #### Stack
2317
+
2318
+ Children in a row or a column with a gap between them: the layout most of a page is. It sets no colour, size or padding of its own. In a right-to-left page a row runs right to left.
2319
+
2320
+ ```ts
2321
+ import { Stack } from "@primecoderin/fast-ui-react";
2322
+ ```
2323
+
2324
+ | Prop | Type | Default | Description |
2325
+ | --- | --- | --- | --- |
2326
+ | `direction` | `"column" \| "row"` | `"column"` | A column (default) or a row. |
2327
+ | `gap` | `0 \| 1 \| 6 \| 12 \| 5 \| 4 \| 3 \| 2 \| 8 \| 10` | `4` | The space between children, in steps of 4px: 4 is 16px. Default 4. |
2328
+ | `align` | `"center" \| "start" \| "end" \| "stretch" \| "baseline"` | | Where children sit across the direction. Default `stretch` in a column and `center` in a row. |
2329
+ | `justify` | `"center" \| "start" \| "end" \| "between"` | `"start"` | Where children sit along the direction. Default `start`. |
2330
+ | `wrap` | `boolean` | `false` | Let a row of children wrap onto more lines. |
2331
+ | `as` | `LayoutElement` | `"div"` | The element: a `div` (default), or a landmark or list where the stack is one. |
2332
+
2333
+ Tested examples: `stories/components/stack.stories.tsx`
2334
+
2335
+ #### StateIcon
2336
+
2337
+ An icon on a round tinted disc: the mark of an empty, success, error or confirmation state.
2338
+
2339
+ ```ts
2340
+ import { StateIcon } from "@primecoderin/fast-ui-react";
2341
+ ```
2342
+
2343
+ | Prop | Type | Default | Description |
2344
+ | --- | --- | --- | --- |
2345
+ | `icon` * | `ReactNode` | | An icon sized by font-size, e.g. a lucide icon. Decorative: hidden from assistive technology. |
2346
+ | `tone` | `ToneName` | `"neutral"` | |
2347
+ | `size` | `"small" \| "medium"` | `"medium"` | |
2348
+ | `className` | `string` | | Extra classes on the root element, merged last so they win over the defaults. |
2349
+
2350
+ Tested examples: `stories/components/state-icon.stories.tsx`
2351
+
2352
+ #### StatusBadge
2353
+
2354
+ Maps a status to a consistent pill. The caller decides which status gets which tone.
2355
+
2356
+ ```ts
2357
+ import { StatusBadge } from "@primecoderin/fast-ui-react";
2358
+ ```
2359
+
2360
+ | Prop | Type | Default | Description |
2361
+ | --- | --- | --- | --- |
2362
+ | `tone` * | `ToneName` | | |
2363
+ | `children` * | `ReactNode` | | The content. |
2364
+ | `size` | `"small" \| "medium"` | `"medium"` | |
2365
+ | `dot` | `boolean` | `false` | Puts a dot in the tone's colour before the label. |
2366
+ | `className` | `string` | | Extra classes on the root element, merged last so they win over the defaults. |
2367
+
2368
+ Tested examples: `stories/components/status-badge.stories.tsx`
2369
+
2370
+ #### Tabs
2371
+
2372
+ A row of tabs with an underline on the selected one, above the selected tab's panel.
2373
+
2374
+ ```ts
2375
+ import { Tabs } from "@primecoderin/fast-ui-react";
2376
+ ```
2377
+
2378
+ | Prop | Type | Default | Description |
2379
+ | --- | --- | --- | --- |
2380
+ | `items` * | `readonly TabItem[]` | | |
2381
+ | `value` * | `string` | | The current value. Controlled: the caller keeps this state. |
2382
+ | `onValueChange` * | `(value: string) => void` | | Called with the new value when the user picks one; set `value` from it. |
2383
+ | `aria-label` * | `string` | | Accessible name of the tab list. |
2384
+ | `children` * | `ReactNode` | | The selected tab's content, which the caller picks from `value`. It is the tab panel: the selected tab controls it and names it, so a screen reader tells which tab the content belongs to. |
2385
+ | `size` | `"small" \| "medium" \| "large"` | `"medium"` | |
2386
+ | `className` | `string` | | Classes for the tab row, e.g. a margin. |
2387
+ | `panelClassName` | `string` | | Classes for the panel. |
2388
+
2389
+ Tested examples: `stories/components/tabs.stories.tsx`, `stories/foundations/branding.stories.tsx`
2390
+
2391
+ #### Tag
2392
+
2393
+ A pill that labels: a category (neutral) or a count (brand). A status takes StatusBadge instead.
2394
+
2395
+ ```ts
2396
+ import { Tag } from "@primecoderin/fast-ui-react";
2397
+ ```
2398
+
2399
+ | Prop | Type | Default | Description |
2400
+ | --- | --- | --- | --- |
2401
+ | `children` * | `ReactNode` | | The content. |
2402
+ | `tone` | `"neutral" \| "brand"` | `"neutral"` | |
2403
+ | `size` | `"small" \| "medium" \| "large"` | `"medium"` | |
2404
+ | `strong` | `boolean` | `false` | Semibold, for a count that heads a section. |
2405
+ | `className` | `string` | | Extra classes on the root element, merged last so they win over the defaults. |
2406
+
2407
+ Tested examples: `stories/components/tag.stories.tsx`, `stories/foundations/branding.stories.tsx`, `stories/foundations/theming.stories.tsx`
2408
+
2409
+ #### ToggleButton
2410
+
2411
+ A two-state button (bold, favourite, mute): `aria-pressed` follows `pressed`. For one choice among several, see ToggleGroup.
2412
+
2413
+ ```ts
2414
+ import { ToggleButton } from "@primecoderin/fast-ui-react";
2415
+ ```
2416
+
2417
+ | Prop | Type | Default | Description |
2418
+ | --- | --- | --- | --- |
2419
+ | `pressed` * | `boolean` | | Whether the button is pressed. |
2420
+ | `onPressedChange` * | `(pressed: boolean) => void` | | Called with the new state when the person presses or releases the button. |
2421
+ | `children` | `ReactNode` | | The label. Leave it out for a glyph alone, and give `aria-label`. |
2422
+ | `icon` | `ReactNode` | | A glyph before the label. |
2423
+ | `size` | `"small" \| "medium" \| "large"` | `"medium"` | |
2424
+ | `disabled` | `boolean` | `false` | Not interactive, and shown as disabled. |
2425
+ | `aria-label` | `string` | | The accessible name, for a button with no text of its own. |
2426
+ | `className` | `string` | | Extra classes on the root element, merged last so they win over the defaults. |
2427
+
2428
+ Tested examples: `stories/components/toggle-button.stories.tsx`
2429
+
2430
+ #### ToggleGroup
2431
+
2432
+ Buttons joined in a row, each pressed or not. One at a time by default, any number with `multiple`; pressing the pressed item releases it, so the value can be empty. For a choice that is always one of several, with the arrow keys moving and choosing, see SegmentedControl. The arrow keys move between the items; Space or Enter presses.
2433
+
2434
+ ```ts
2435
+ import { ToggleGroup } from "@primecoderin/fast-ui-react";
2436
+ ```
2437
+
2438
+ | Prop | Type | Default | Description |
2439
+ | --- | --- | --- | --- |
2440
+ | `items` * | `readonly ToggleGroupItem[]` | | |
2441
+ | `value` * | `readonly string[]` | | The `value`s of the pressed items. |
2442
+ | `onValueChange` * | `(value: string[]) => void` | | Called with the `value`s of the pressed items. |
2443
+ | `aria-label` * | `string` | | Accessible name of the group, e.g. "Text style". |
2444
+ | `multiple` | `boolean` | `false` | Let several items be pressed at once (bold and italic). Otherwise pressing one releases the other. |
2445
+ | `size` | `"small" \| "medium" \| "large"` | `"medium"` | |
2446
+ | `disabled` | `boolean` | `false` | Not interactive, and shown as disabled. |
2447
+ | `className` | `string` | | Extra classes on the root element, merged last so they win over the defaults. |
2448
+
2449
+ Tested examples: `stories/components/toggle-group.stories.tsx`
2450
+
2451
+ #### Tooltip
2452
+
2453
+ A short label shown on hover and keyboard focus. Supplementary only: it never appears on touch, so the trigger must have its own accessible name.
2454
+
2455
+ ```ts
2456
+ import { Tooltip } from "@primecoderin/fast-ui-react";
2457
+ ```
2458
+
2459
+ | Prop | Type | Default | Description |
2460
+ | --- | --- | --- | --- |
2461
+ | `content` * | `ReactNode` | | |
2462
+ | `children` * | `ReactElement<unknown, string \| JSXElementConstructor<any>>` | | The element the tooltip describes. It is the trigger itself, so it keeps its own props. |
2463
+ | `side` | `"top" \| "bottom" \| "left" \| "right" \| "inline-start" \| "inline-end"` | `"top"` | `inline-start` and `inline-end` follow the text direction. |
2464
+
2465
+ Tested examples: `stories/components/tooltip.stories.tsx`
2466
+
2467
+ #### Typography
2468
+
2469
+ Text in one of the type scale's styles. Use it where a heading or paragraph must match the foundation.
2470
+
2471
+ ```ts
2472
+ import { Typography } from "@primecoderin/fast-ui-react";
2473
+ ```
2474
+
2475
+ | Prop | Type | Default | Description |
2476
+ | --- | --- | --- | --- |
2477
+ | `variant` | `TextStyleName` | `"body"` | A style of the type scale: display, h1 to h4, body large/regular/small, caption, button, label. |
2478
+ | `as` | `TypographyElement` | `"span"` | The element to render. Pick for document structure; the look comes from `variant`. |
2479
+ | `tone` | `TypographyTone` | `"primary"` | |
2480
+ | `truncate` | `boolean` | `false` | One line, cut off with an ellipsis. |
2481
+
2482
+ Tested examples: `stories/components/typography.stories.tsx`
2483
+
2484
+ ### Provider
2485
+
2486
+ #### DesignSystemProvider
2487
+
2488
+ Applies the theme, text direction and tenant branding, and hosts the app toaster and the shared tooltip delay. The theme is `data-theme` and the direction is `dir`, both on <html>: the CSS variables switch on the first, logical utilities and the font on the second. They go on the root, not a wrapper element, because Base UI portals (menus, dialogs, tooltips, toasts) render into <body> and would otherwise sit outside a wrapper's theme. DirectionProvider only tells Base UI's own behaviour (arrow keys, popup placement) which way the text runs; it does not touch the DOM. CSPProvider gives Base UI's own inline tags the page's nonce, and the provider puts it on the <style> elements it adds itself, so a strict policy allows them all. One provider per page: what it sets lives on <html>. A provider inside another only tells Base UI's behaviour its `direction` (put the same `dir` on that part of the page yourself); the outer one keeps the theme, the branding and the toaster, so the two cannot undo each other. When the provider unmounts, <html> gets back the `dir` and `data-theme` it had before (none, or the server's), and the theme's and branding's <style> elements go.
2489
+
2490
+ ```ts
2491
+ import { DesignSystemProvider } from "@primecoderin/fast-ui-react";
2492
+ ```
2493
+
2494
+ | Prop | Type | Default | Description |
2495
+ | --- | --- | --- | --- |
2496
+ | `themeMode` * | `ThemePreference` | | `"light"` or `"dark"`, or `"system"` to follow the operating system's setting, and change with it. |
2497
+ | `direction` * | `TextDirection` | | The text direction, `"ltr"` or `"rtl"`: the `dir` on <html>, and the way Base UI's keys and popups run. |
2498
+ | `children` * | `ReactNode` | | The app. |
2499
+ | `branding` | `TenantBranding \| null` | `null` | A tenant's own primary colour. Omit for the default teal. |
2500
+ | `theme` | `Theme \| null` | `null` | A theme made with `createTheme`: the primary colour and any other tokens. |
2501
+ | `toastLabels` | `ToastLabelsInput` | | The toasts' titles and dismiss label, in the user's language. Any left out are in English. |
2502
+ | `nonce` | `string` | | The page's Content-Security-Policy nonce. It goes on every <style> and <script> tag the design system adds: Base UI's own (a ScrollArea's scrollbar style, a Select aligned with its trigger) and the provider's (the theme, the branding, the instant theme switch). Omit where no policy applies. |
2503
+
2504
+ Tested examples: `stories/foundations/theming.stories.tsx`
2505
+
2506
+ ### Patterns
2507
+
2508
+ #### Accordion
2509
+
2510
+ Sections that open and close: a heading each, the content under it while it is open. One open at a time by default, any number with `multiple`. Each heading is a button, so Enter and Space open it, and the up and down arrow keys move between the headings. The height eases open (and does not move for a visitor who asks for less motion).
2511
+
2512
+ ```ts
2513
+ import { Accordion } from "@primecoderin/fast-ui-react";
2514
+ ```
2515
+
2516
+ | Prop | Type | Default | Description |
2517
+ | --- | --- | --- | --- |
2518
+ | `items` * | `readonly AccordionItem[]` | | |
2519
+ | `value` | `readonly string[]` | | The `value`s of the open sections. Leave it out to let the accordion keep its own. |
2520
+ | `defaultValue` | `readonly string[]` | | The `value`s the sections start open with, when the accordion keeps its own. |
2521
+ | `onValueChange` | `((value: string[]) => void)` | | Called with the `value`s of the open sections. |
2522
+ | `multiple` | `boolean` | `false` | Let several sections be open at once. Otherwise opening one closes the other. |
2523
+ | `headingLevel` | `6 \| 5 \| 4 \| 3 \| 2` | `3` | The level of the section headings, 2 to 6 (default 3). Pick the one below the heading the accordion sits under, so the page's outline stays in order. |
2524
+ | `disabled` | `boolean` | `false` | Not interactive, and shown as disabled. |
2525
+ | `className` | `string` | | Extra classes on the root element, merged last so they win over the defaults. |
2526
+
2527
+ Tested examples: `stories/patterns/accordion.stories.tsx`
2528
+
2529
+ #### Alert
2530
+
2531
+ An inline notification: icon, title, description, an optional action and a close button. An error alert is announced when it appears (`role="alert"`). The other tones are status regions (`role="status"`): a change to their text while they are shown is announced at the next pause, but one that appears with its text is often not announced at all. For a message that must be heard as it happens (a save that worked), keep the Alert on the page and change its text, or say it in another region that is already there.
2532
+
2533
+ ```ts
2534
+ import { Alert } from "@primecoderin/fast-ui-react";
2535
+ ```
2536
+
2537
+ | Prop | Type | Default | Description |
2538
+ | --- | --- | --- | --- |
2539
+ | `tone` * | `AlertTone` | | The colour, the icon and the live region: "error" is an alert (`role="alert"`), announced when it appears; the others are status regions (`role="status"`). |
2540
+ | `title` * | `string` | | The message, in a line, e.g. "Changes saved". |
2541
+ | `description` | `ReactNode` | | More detail under the title. |
2542
+ | `action` | `{ label: string; onClick: () => void; }` | | An optional inline link under the description. |
2543
+ | `className` | `string` | | Classes for the outer element, e.g. a margin. |
2544
+ | `onClose` | `(() => void)` | | Adds a close button. |
2545
+ | `closeLabel` | `string` | | Accessible name of the close button. |
2546
+
2547
+ Tested examples: `stories/patterns/alert.stories.tsx`
2548
+
2549
+ #### AppShell
2550
+
2551
+ The frame of an application: a sticky header, the navigation down the side, and the page. From the `md` breakpoint the navigation is a column beside the page (`--fast-size-sidenav` wide, `--fast-size-sidenav-collapsed` when collapsed); on a narrower screen it is a drawer that the header's menu button opens and its own close button, Escape or a tap on the page closes, and that closes by itself if the window grows. The page is a `<main>` that a skip link reaches. The sizes are tokens.
2552
+
2553
+ ```ts
2554
+ import { AppShell } from "@primecoderin/fast-ui-react";
2555
+ ```
2556
+
2557
+ | Prop | Type | Default | Description |
2558
+ | --- | --- | --- | --- |
2559
+ | `header` * | `ReactNode` | | The header: the app's name, search, the account menu. It is a sticky bar the page scrolls under. |
2560
+ | `nav` * | `ReactNode` | | The navigation, usually a SideNav. It is a column on a wide screen and the content of a drawer on a narrow one. |
2561
+ | `children` * | `ReactNode` | | The page. It is the `<main>`. |
2562
+ | `labels` * | `AppShellLabels` | | Every text it shows or announces, in the user's language (the library has no built-in text). |
2563
+ | `navOpen` * | `boolean` | | Whether the navigation drawer is open (on a narrow screen). |
2564
+ | `onNavOpenChange` * | `(open: boolean) => void` | | Called when the drawer should open or close: the header button, a click outside, Escape. |
2565
+ | `navCollapsed` | `boolean` | `false` | Make the navigation column narrow, for icons only (pass the same to SideNav's `collapsed`). |
2566
+ | `className` | `string` | | Extra classes on the root element, merged last so they win over the defaults. |
2567
+
2568
+ Tested examples: `stories/patterns/app-shell.stories.tsx`
2569
+
2570
+ #### Autocomplete
2571
+
2572
+ A text input with suggestions: the value is whatever is typed, and a list of the suggestions that contain it offers to complete it. Unlike Combobox the text need not be one of the suggestions. The arrow keys move through the list and Enter takes the suggestion.
2573
+
2574
+ ```ts
2575
+ import { Autocomplete } from "@primecoderin/fast-ui-react";
2576
+ ```
2577
+
2578
+ | Prop | Type | Default | Description |
2579
+ | --- | --- | --- | --- |
2580
+ | `suggestions` * | `readonly string[]` | | The suggestions: the ones that contain the typed text are listed. |
2581
+ | `value` * | `string` | | The text in the field: what was typed, or the suggestion that was chosen. |
2582
+ | `onValueChange` * | `(value: string) => void` | | Called with the new text as the person types, and with a suggestion's text when one is chosen. |
2583
+ | `noMatchesLabel` | `string` | | Shown when the typed text matches no suggestion. If omitted the list is hidden while nothing matches. |
2584
+ | `resultsLabel` | `((count: number) => string)` | | The number of suggestions the typed text matches, as a screen reader announces it (politely, as it changes): `(count) => `${count} suggestions``. Nothing is announced if omitted. |
2585
+ | `placeholder` | `string` | | |
2586
+ | `disabled` | `boolean` | `false` | Not interactive, and shown as disabled. |
2587
+ | `invalid` | `boolean` | `false` | Draws the box red and marks the input invalid for assistive technology. |
2588
+ | `required` | `boolean` | `false` | Marks the input required for assistive technology; the label shows the asterisk. |
2589
+ | `size` | `FieldSize` | `"medium"` | "small" is the compact density. |
2590
+ | `contentBefore` | `ReactNode` | | A decorative icon at the start of the box. |
2591
+ | `name` | `string` | | The field's name in a submitted form. |
2592
+ | `id` | `string` | | For a `<label htmlFor>` that names the input. |
2593
+ | `aria-label` | `string` | | The accessible name of the input and of its list of suggestions, for a field with no label element of its own. Give this or `aria-labelledby`. |
2594
+ | `aria-labelledby` | `string` | | The id of the element that names the input and its list, such as a field's label. |
2595
+ | `onBlur` | `(() => void)` | | The field was left. |
2596
+ | `inputRef` | `Ref<HTMLInputElement>` | | The `<input>`, for a form library to focus the first invalid field. |
2597
+
2598
+ Tested examples: `stories/patterns/autocomplete.stories.tsx`
2599
+
2600
+ #### Breadcrumbs
2601
+
2602
+ The path to the current page: each ancestor a link, the page itself plain text marked `aria-current="page"`. It is a `<nav>` with an ordered list, so a screen reader announces how many levels there are. The separator points the way the page reads.
2603
+
2604
+ ```ts
2605
+ import { Breadcrumbs } from "@primecoderin/fast-ui-react";
2606
+ ```
2607
+
2608
+ | Prop | Type | Default | Description |
2609
+ | --- | --- | --- | --- |
2610
+ | `items` * | `readonly BreadcrumbItem[]` | | The path from the top to the current page, in order. The last item is the current page. |
2611
+ | `aria-label` * | `string` | | Accessible name of the navigation, e.g. "Breadcrumb". |
2612
+ | `className` | `string` | | Extra classes on the root element, merged last so they win over the defaults. |
2613
+
2614
+ Tested examples: `stories/patterns/breadcrumbs.stories.tsx`
2615
+
2616
+ #### Calendar
2617
+
2618
+ A month of days on show, to pick one day or a range: the date picker's calendar, inline. The arrow buttons and Page Up and Page Down change the month, the month's name opens a list of months and years, and the arrow keys move between days (the other way in right to left). A range is two clicks, the start and then the end; a click before the start begins again. The weeks start on the locale's first day of the week.
2619
+
2620
+ ```ts
2621
+ import { Calendar } from "@primecoderin/fast-ui-react";
2622
+ ```
2623
+
2624
+ | Prop | Type | Default | Description |
2625
+ | --- | --- | --- | --- |
2626
+ | `value` * | `string \| DateRangeValue` | | The picked day, "yyyy-MM-dd", or an empty string for none. A day that cannot be read, or does not exist, is none. The picked range: `start` and `end` empty for none, `end` empty while only the start is picked. |
2627
+ | `onValueChange` * | `((value: string) => void) \| ((value: DateRangeValue) => void)` | | Called with the day the person picks. Called with the range as it grows: the start alone after the first click, then both. |
2628
+ | `mode` | `"range" \| "single"` | | One day. A range: the first click picks the start, the second the end. |
2629
+ | `min` | `string` | | The earliest day that can be picked, "yyyy-MM-dd". Earlier days are greyed out. |
2630
+ | `max` | `string` | | The latest day that can be picked, "yyyy-MM-dd". |
2631
+ | `labels` | `CalendarLabels` | | The texts, in the user's language. English if omitted. |
2632
+ | `locale` | `Locale` | | date-fns' locale for the names of months and days and the first day of the week (Monday for `de`), such as `he` from "date-fns/locale/he". English, with weeks from Sunday, if omitted. |
2633
+ | `defaultMonth` | `string` | | The month shown first when nothing is picked, as a day or a month: "2026-10-24" or "2026-10". Today's month if omitted or unreadable. |
2634
+ | `aria-label` | `string` | | Accessible name of the calendar's group, when it has no heading of its own. |
2635
+ | `className` | `string` | | Classes for the calendar's box, e.g. a margin or a width. |
2636
+
2637
+ Tested examples: `stories/patterns/calendar.stories.tsx`
2638
+
2639
+ #### Card
2640
+
2641
+ A surface that groups related content. Pass `onClick` to make the whole card a button: it becomes focusable, Enter and Space click it, and it lifts on hover. A button's content is read as one name, so a clickable card holds plain text: a heading inside it is not announced as a heading, and a control inside it is a control within a button. For a card with headings or its own controls, put a button or link inside the card instead.
2642
+
2643
+ ```ts
2644
+ import { Card } from "@primecoderin/fast-ui-react";
2645
+ ```
2646
+
2647
+ | Prop | Type | Default | Description |
2648
+ | --- | --- | --- | --- |
2649
+ | `variant` | `CardVariant` | `"standard"` | |
2650
+ | `padding` | `CardPadding` | `"medium"` | |
2651
+
2652
+ Tested examples: `stories/patterns/card.stories.tsx`
2653
+
2654
+ #### Carousel
2655
+
2656
+ Slides in a row that scroll sideways and snap into place: swipe or scroll on a touch screen, the buttons and dots elsewhere. It is a native scroll area, so it needs no script to move and works with the arrow keys once focused. Every slide is in the page for a screen reader. Nothing moves by itself: there is no autoplay. The slides run the way the page reads.
2657
+
2658
+ ```ts
2659
+ import { Carousel } from "@primecoderin/fast-ui-react";
2660
+ ```
2661
+
2662
+ | Prop | Type | Default | Description |
2663
+ | --- | --- | --- | --- |
2664
+ | `children` * | `ReactNode` | | The slides: one child each. |
2665
+ | `labels` * | `CarouselLabels` | | Every text it shows or announces, in the user's language (the library has no built-in text). |
2666
+ | `aria-label` * | `string` | | Accessible name of the carousel, e.g. "Featured products". |
2667
+ | `slidesPerView` | `1 \| 3 \| 2` | `1` | How many slides show at once. Default 1. |
2668
+ | `hideIndicators` | `boolean` | `false` | Hide the dots under the slides. Default shows them. |
2669
+ | `onIndexChange` | `((index: number) => void)` | | Called with the index of the first slide in view, as the carousel moves. |
2670
+ | `className` | `string` | | Extra classes on the root element, merged last so they win over the defaults. |
2671
+
2672
+ Tested examples: `stories/patterns/carousel.stories.tsx`
2673
+
2674
+ #### Cascader
2675
+
2676
+ Choosing through levels: a country, then a region, then a city. A button shows the chosen path and opens columns, one for each level; choosing a step opens its children beside it, and choosing a last step ends the choice. In the columns the up and down keys move, the key toward the end edge opens a step and goes in, the key toward the start edge goes back out, and Enter chooses. For a list of one level, see Combobox.
2677
+
2678
+ ```ts
2679
+ import { Cascader } from "@primecoderin/fast-ui-react";
2680
+ ```
2681
+
2682
+ | Prop | Type | Default | Description |
2683
+ | --- | --- | --- | --- |
2684
+ | `options` * | `readonly CascaderOption[]` | | |
2685
+ | `value` * | `readonly string[]` | | The path to the chosen option: the `value` of each step, from the first column to the last. Empty for none. |
2686
+ | `onValueChange` * | `(value: string[]) => void` | | Called with the path when a last step (an option with no children) is chosen. |
2687
+ | `labels` * | `CascaderLabels` | | Every text it shows or announces, in the user's language (the library has no built-in text). |
2688
+ | `placeholder` | `string` | | Shown on the button while nothing is chosen. `labels.choose` if omitted. |
2689
+ | `separator` | `string` | `" / "` | Written between the labels of the path on the button. Default " / ". |
2690
+ | `disabled` | `boolean` | `false` | Not interactive, and shown as disabled. |
2691
+ | `invalid` | `boolean` | `false` | Draws the red border. A button cannot carry aria-invalid, so the field is announced as invalid through its message, which `aria-describedby` ties to it. |
2692
+ | `size` | `FieldSize` | `"medium"` | |
2693
+ | `id` | `string` | | |
2694
+ | `aria-label` | `string` | | What names the field when there is no visible label. |
2695
+ | `aria-labelledby` | `string` | | The id of the element that is the field's label; the chosen path is added to the name. |
2696
+ | `aria-describedby` | `string` | | The ids of the field's message and hint, read after the name. |
2697
+ | `triggerRef` | `Ref<HTMLButtonElement>` | | |
2698
+ | `onBlur` | `(() => void)` | | The cascader was left: the panel closed, or focus moved off the button while closed. |
2699
+
2700
+ Tested examples: `stories/patterns/cascader.stories.tsx`
2701
+
2702
+ #### CheckboxField
2703
+
2704
+ A checkbox with its label, hint and error. It is controlled: it shows `checked` and reports a change through `onCheckedChange`. Bound to react-hook-form, it is FormCheckboxField.
2705
+
2706
+ ```ts
2707
+ import { CheckboxField } from "@primecoderin/fast-ui-react";
2708
+ ```
2709
+
2710
+ | Prop | Type | Default | Description |
2711
+ | --- | --- | --- | --- |
2712
+ | `label` * | `string` | | The visible label. |
2713
+ | `checked` * | `boolean` | | Whether it is checked. Controlled: the caller keeps this state. |
2714
+ | `onCheckedChange` * | `(checked: boolean) => void` | | Called with the new state when the person ticks or clears the box. |
2715
+ | `name` | `string` | | The field's name in a submitted form. |
2716
+ | `hint` | `string` | | |
2717
+ | `errorMessage` | `string` | | The validation message, in the user's language: shown in red under the box, which it marks invalid. |
2718
+ | `invalid` | `boolean` | `false` | Marks the field invalid without a message to show. |
2719
+ | `disabled` | `boolean` | `false` | Not interactive, and shown as disabled. |
2720
+ | `size` | `"medium" \| "large"` | `"medium"` | "large" is a 20px box (the default is 17px). |
2721
+ | `onBlur` | `(() => void)` | | The checkbox was left. |
2722
+ | `inputRef` | `Ref<HTMLInputElement>` | | The checkbox's hidden input, e.g. for a form library to focus the first invalid field. |
2723
+
2724
+ Tested examples: `stories/patterns/form-fields/checkbox-field.stories.tsx`
2725
+
2726
+ #### ColorPicker
2727
+
2728
+ A colour picker: a button showing the colour that opens a panel with an area for saturation (across) and brightness (up), a hue slider, the hex text and, if given, swatches. The value is hex text. The area is one slider for a screen reader, which reads its position through `labels.areaValue`; the arrow keys move it by 1 (10 with Shift). The panel is always left to right, like the colours it shows.
2729
+
2730
+ ```ts
2731
+ import { ColorPicker } from "@primecoderin/fast-ui-react";
2732
+ ```
2733
+
2734
+ | Prop | Type | Default | Description |
2735
+ | --- | --- | --- | --- |
2736
+ | `value` * | `string` | | The colour as hex, "#6d28d9"; an empty string for none. |
2737
+ | `onValueChange` * | `(value: string) => void` | | Called with the new colour as "#rrggbb" in lower case, as the person picks. |
2738
+ | `labels` * | `ColorPickerLabels` | | Every text it shows or announces, in the user's language (the library has no built-in text). |
2739
+ | `swatches` | `readonly string[]` | | Colours offered as one-click choices under the picker, as hex. |
2740
+ | `placeholder` | `string` | | Shown on the button while there is no colour. `labels.choose` if omitted. |
2741
+ | `disabled` | `boolean` | `false` | Not interactive, and shown as disabled. |
2742
+ | `invalid` | `boolean` | `false` | Draws the red border. A button cannot carry aria-invalid, so the field is announced as invalid through its message, which `aria-describedby` ties to it. |
2743
+ | `size` | `FieldSize` | `"medium"` | |
2744
+ | `id` | `string` | | |
2745
+ | `aria-label` | `string` | | What names the picker when there is no visible label. `labels.choose` if omitted. |
2746
+ | `aria-labelledby` | `string` | | The id of the element that is the picker's label; the chosen colour is added to the name. |
2747
+ | `aria-describedby` | `string` | | The ids of the field's message and hint, read after the name. |
2748
+ | `triggerRef` | `Ref<HTMLButtonElement>` | | |
2749
+ | `onBlur` | `(() => void)` | | The picker was left: the panel closed, or focus moved off it while closed. |
2750
+
2751
+ Tested examples: `stories/patterns/color-picker.stories.tsx`
2752
+
2753
+ #### Combobox
2754
+
2755
+ A select you can type into: the box shows the chosen option, typing filters the list to the options that contain the text, and the arrow keys and Enter choose. For a short list that needs no typing, see SelectField; for several choices, MultiSelect; for free text with suggestions, Autocomplete.
2756
+
2757
+ ```ts
2758
+ import { Combobox } from "@primecoderin/fast-ui-react";
2759
+ ```
2760
+
2761
+ | Prop | Type | Default | Description |
2762
+ | --- | --- | --- | --- |
2763
+ | `options` * | `readonly ComboboxOption[]` | | |
2764
+ | `value` * | `string` | | The chosen option's `value`; an empty string for none. |
2765
+ | `onValueChange` * | `(value: string) => void` | | Called with the chosen option's `value`. |
2766
+ | `noMatchesLabel` * | `string` | | Shown when the typed text matches no option. |
2767
+ | `resultsLabel` | `((count: number) => string)` | | The number of options the typed text matches, as a screen reader announces it (politely, as it changes): `(count) => `${count} results``. Nothing is announced if omitted. |
2768
+ | `placeholder` | `string` | | |
2769
+ | `disabled` | `boolean` | `false` | Not interactive, and shown as disabled. |
2770
+ | `invalid` | `boolean` | `false` | Draws the box red and marks the input invalid for assistive technology. |
2771
+ | `required` | `boolean` | `false` | Marks the input required for assistive technology; the label shows the asterisk. |
2772
+ | `size` | `FieldSize` | `"medium"` | "small" is the compact density. |
2773
+ | `contentBefore` | `ReactNode` | | A decorative icon at the start of the box. |
2774
+ | `name` | `string` | | The field's name in a submitted form. |
2775
+ | `id` | `string` | | For a `<label htmlFor>` that names the input. |
2776
+ | `aria-label` | `string` | | The accessible name of the input and of its list of options, for a combobox with no label element of its own. Give this or `aria-labelledby`: a `<label htmlFor>` alone names the input but not the list. |
2777
+ | `aria-labelledby` | `string` | | The id of the element that names the input and its list of options, such as a field's label. |
2778
+ | `onBlur` | `(() => void)` | | The combobox was left. |
2779
+ | `inputRef` | `Ref<HTMLInputElement>` | | The `<input>`, for a form library to focus the first invalid field. |
2780
+
2781
+ Tested examples: `stories/patterns/combobox.stories.tsx`
2782
+
2783
+ #### CommandPalette
2784
+
2785
+ A search box over a list of commands, opened over the page: type to narrow the list, the arrow keys move through it, Enter runs the command and Escape closes. The app opens it, usually from a shortcut such as Ctrl or Cmd and K, and says what each command does. To a screen reader it is a dialog holding a combobox whose list is announced.
2786
+
2787
+ ```ts
2788
+ import { CommandPalette } from "@primecoderin/fast-ui-react";
2789
+ ```
2790
+
2791
+ | Prop | Type | Default | Description |
2792
+ | --- | --- | --- | --- |
2793
+ | `open` * | `boolean` | | Whether the palette is open. Each opening starts with an empty search. |
2794
+ | `onOpenChange` * | `(open: boolean) => void` | | Called with `false` when the palette closes: Escape, a click outside, or a command run. |
2795
+ | `groups` * | `readonly CommandGroup[]` | | The commands, in groups, in the order they are listed. |
2796
+ | `labels` * | `CommandPaletteLabels` | | The palette's name, the search field's placeholder and the no-results text. |
2797
+
2798
+ Tested examples: `stories/patterns/command-palette.stories.tsx`
2799
+
2800
+ #### DataTable
2801
+
2802
+ An edge-to-edge table. When rows are activatable, a click is ignored while the user has text selected, so copying a cell's text does not navigate away.
2803
+
2804
+ ```ts
2805
+ import { DataTable } from "@primecoderin/fast-ui-react";
2806
+ ```
2807
+
2808
+ | Prop | Type | Default | Description |
2809
+ | --- | --- | --- | --- |
2810
+ | `columns` * | `readonly DataTableColumn<TRow>[]` | | The columns, in order from the start edge. |
2811
+ | `rows` * | `readonly TRow[]` | | The rows to show, in the order to show them: sorting and paging are the caller's. |
2812
+ | `getRowId` * | `(row: TRow) => RowId` | | A row's id, unique among the rows: the React key, and what `selection` holds. |
2813
+ | `aria-label` * | `string` | | Accessible name of the table. |
2814
+ | `onRowActivate` | `((row: TRow) => void)` | | Makes rows clickable and keyboard-activatable (Enter or Space): each row becomes a Tab stop. A screen reader hears a row there, not a button, so this is a convenience: give the same action a real control in a cell too, such as a link to the row's page. To open a panel under the row, use `expansion`, which draws its own button. |
2815
+ | `sort` | `DataTableSort` | | The column the rows are sorted by, shown on its header. Sorting itself is the caller's. |
2816
+ | `onSortChange` | `((columnId: string) => void)` | | Called with a sortable column's id when its header is pressed; the caller sorts and sets `sort`. |
2817
+ | `selection` | `DataTableSelection<TRow>` | | Adds a checkbox column. Selected ids may include rows on other pages. |
2818
+ | `expansion` | `DataTableExpansion<TRow>` | | Lets rows expand inline, each with a disclosure button. The caller owns which rows are open. |
2819
+ | `isLoading` | `boolean` | `false` | Shows placeholder rows in place of `rows`. |
2820
+ | `loadingRows` | `number` | `5` | How many placeholder rows to show while loading. |
2821
+ | `emptyState` | `ReactNode` | | Shown under the header when there are no rows. |
2822
+ | `stickyHeader` | `boolean` | `false` | Keep the header in view while the rows scroll inside a bounded container. |
2823
+ | `rowClassName` | `((row: TRow) => string \| undefined)` | | Extra classes for a row's `tr`, e.g. a tint for the rows of one kind. Merged last, so it can override the defaults. |
2824
+ | `virtualPadding` | `{ top: number; bottom: number; }` | | For a windowed list: `rows` is only the part in view, and these are the heights, in pixels, of the rows left out above and below it. They are drawn as empty rows, so the scroll bar is as long as the whole list would be. |
2825
+
2826
+ Tested examples: `stories/patterns/data-table.stories.tsx`
2827
+
2828
+ #### DateRangePicker
2829
+
2830
+ A field that picks a start and an end day: a button showing the range that opens a calendar, where the first click is the start and the second the end, and the panel closes. The value is two day texts. For one day, see DateTimePicker; for a calendar that is always on show, see Calendar.
2831
+
2832
+ ```ts
2833
+ import { DateRangePicker } from "@primecoderin/fast-ui-react";
2834
+ ```
2835
+
2836
+ | Prop | Type | Default | Description |
2837
+ | --- | --- | --- | --- |
2838
+ | `value` * | `DateRangeValue` | | The range: "yyyy-MM-dd" each, `end` empty while only the start is picked. |
2839
+ | `onValueChange` * | `(value: DateRangeValue) => void` | | Called with the range as the person picks. The panel closes once both ends are picked. |
2840
+ | `min` | `string` | | The earliest and latest day that can be picked, "yyyy-MM-dd". |
2841
+ | `max` | `string` | | |
2842
+ | `placeholder` | `string` | | Shown while there is no range. `labels.select` if omitted. |
2843
+ | `labels` | `DateRangePickerLabels` | `ENGLISH_RANGE_LABELS` | The texts of the field and its calendar. English if omitted. |
2844
+ | `locale` | `Locale` | `enUS` | date-fns' locale for the names of months and days and the first day of the week. English, with weeks from Sunday, if omitted. |
2845
+ | `disabled` | `boolean` | `false` | Not interactive, and shown as disabled. |
2846
+ | `invalid` | `boolean` | `false` | Draws the red border. A button cannot carry aria-invalid, so the field is announced as invalid through its message, which `aria-describedby` ties to it. |
2847
+ | `size` | `FieldSize` | `"medium"` | |
2848
+ | `icon` | `ReactNode` | | Replaces the calendar glyph at the end of the field. |
2849
+ | `id` | `string` | | |
2850
+ | `aria-label` | `string` | | What names the field when there is no visible label. |
2851
+ | `aria-labelledby` | `string` | | The id of the element that is the field's label; the chosen range is added to the name. |
2852
+ | `aria-describedby` | `string` | | The ids of the field's message and hint, read after the name. |
2853
+ | `triggerRef` | `Ref<HTMLButtonElement>` | | |
2854
+ | `onBlur` | `(() => void)` | | The picker was left: the panel closed, or focus moved off it while closed. |
2855
+
2856
+ Tested examples: `stories/patterns/date-range-picker.stories.tsx`
2857
+
2858
+ #### DateTimePicker
2859
+
2860
+ A date and time picker: a read-only field with a calendar glyph that opens a panel with the month, the days, the time sliders and Today or Now, Clear and Done. It is a button, so the value is picked and never typed, and it holds its value as the plain text a native `<input type="date">` holds (see `value`), so a form's schema and the code that turns the text into a request need nothing picker-specific. For a field with a label bound to react-hook-form use FormDateTimeField.
2861
+
2862
+ ```ts
2863
+ import { DateTimePicker } from "@primecoderin/fast-ui-react";
2864
+ ```
2865
+
2866
+ | Prop | Type | Default | Description |
2867
+ | --- | --- | --- | --- |
2868
+ | `value` * | `string` | | The value as the matching native input holds it, with no time zone: "2026-10-24" for a date, "2026-10-24T14:05" for a date and time, "14:05" for a time. Empty for none. Turning it into a moment and back is the caller's. |
2869
+ | `onValueChange` * | `(value: string) => void` | | Called with the new value as the person picks, and with "" when they clear it. |
2870
+ | `mode` | `PickerKind` | `"date"` | A day (default), a day and a time, or a time of day. |
2871
+ | `showSeconds` | `boolean` | `false` | Show and set the seconds as well: "14:05:09". For a date and time or a time. |
2872
+ | `min` | `string` | | The earliest and latest value, written as the value is ("2026-10-24"; a date and time may be a day alone, which is that day's first or last moment). Days outside are greyed out and cannot be picked, and a time outside becomes the nearer limit. |
2873
+ | `max` | `string` | | |
2874
+ | `defaultTime` | `string` | | The time a day gets when it is picked and the value has none: "00:00" for the start of a range, "23:59" for its end. The time now if omitted. Seconds are dropped unless `showSeconds`. |
2875
+ | `clearable` | `boolean` | `false` | Offer Clear, which empties the value. |
2876
+ | `showNow` | `boolean` | `true` | Offer Today (a date) or Now. Default true. |
2877
+ | `display` | `"full" \| "dayMonth"` | `"full"` | "dayMonth" shows a date as "24 October", for a date whose year does not matter (a season's first day). |
2878
+ | `placeholder` | `string` | | Shown while there is no value. `labels.select` if omitted. |
2879
+ | `labels` | `DateTimePickerLabels` | `ENGLISH_PICKER_LABELS` | The texts of the field and its panel, in the user's language. English if omitted. |
2880
+ | `locale` | `Locale` | `enUS` | date-fns' locale for the names of months and days and the first day of the week (Monday for `de`), such as `he` from "date-fns/locale/he". English, with weeks from Sunday, if omitted. Dates are always written day first and times in 24 hours, whatever the locale. |
2881
+ | `disabled` | `boolean` | `false` | Not interactive, and shown as disabled. |
2882
+ | `invalid` | `boolean` | `false` | Draws the red border. A button cannot carry aria-invalid, so the field is announced as invalid through its message, which `aria-describedby` ties to it. |
2883
+ | `size` | `FieldSize` | `"medium"` | |
2884
+ | `icon` | `ReactNode` | | Replaces the calendar (or, for a time, clock) glyph at the end of the field. |
2885
+ | `id` | `string` | | |
2886
+ | `aria-label` | `string` | | What names the field when there is no visible label. |
2887
+ | `aria-labelledby` | `string` | | The id of the element that is the field's label; the chosen value is added to the name. |
2888
+ | `aria-describedby` | `string` | | The ids of the field's message and hint, read after the name. |
2889
+ | `triggerRef` | `Ref<HTMLButtonElement>` | | |
2890
+ | `onBlur` | `(() => void)` | | The picker was left: the panel closed, or focus moved off it while closed. |
2891
+
2892
+ Tested examples: `stories/patterns/date-time-picker.stories.tsx`
2893
+
2894
+ #### DescriptionList
2895
+
2896
+ The details of one record as term and value pairs: an order's status, date and total. It is a `<dl>`, so a screen reader announces each value with its term. For a table of many records, see DataTable.
2897
+
2898
+ ```ts
2899
+ import { DescriptionList } from "@primecoderin/fast-ui-react";
2900
+ ```
2901
+
2902
+ | Prop | Type | Default | Description |
2903
+ | --- | --- | --- | --- |
2904
+ | `items` * | `readonly DescriptionListItem[]` | | |
2905
+ | `layout` | `"horizontal" \| "stacked"` | `"stacked"` | "stacked" (default) puts the term over its value; "horizontal" puts the terms in a column beside the values. |
2906
+ | `dividers` | `boolean` | `false` | A rule between the pairs. |
2907
+ | `className` | `string` | | Extra classes on the root element, merged last so they win over the defaults. |
2908
+
2909
+ Tested examples: `stories/patterns/description-list.stories.tsx`
2910
+
2911
+ #### Dialog
2912
+
2913
+ A modal dialog, opened and closed by its caller through `open` and `onOpenChange`: a header with an icon tile, eyebrow, title and close button, a body that scrolls, and a footer of actions.
2914
+
2915
+ ```ts
2916
+ import { Dialog } from "@primecoderin/fast-ui-react";
2917
+ ```
2918
+
2919
+ | Prop | Type | Default | Description |
2920
+ | --- | --- | --- | --- |
2921
+ | `open` * | `boolean` | | Whether it is open. Controlled: the caller keeps this state. |
2922
+ | `onOpenChange` * | `(open: boolean) => void` | | Called with the next open state (false on Escape, an outside click or a close button); set `open` from it. |
2923
+ | `title` * | `string` | | The title, shown and used as the accessible name. |
2924
+ | `children` * | `ReactNode` | | The content. |
2925
+ | `eyebrow` | `string` | | The small teal line above the title, e.g. the section the dialog belongs to. |
2926
+ | `icon` | `ReactNode` | | An icon in a teal tile before the title. |
2927
+ | `description` | `string` | | One small grey line under the title, e.g. an id. |
2928
+ | `actions` | `ReactNode` | | Footer buttons, end-aligned in the order given: Cancel first, then the primary action. |
2929
+ | `closeLabel` | `string` | | Accessible name for the close (X) button. The button is omitted when not provided. |
2930
+ | `modalType` | `"modal" \| "alert"` | `"modal"` | "alert" blocks outside-click and Escape dismissal, for decisions that must be answered. |
2931
+ | `size` | `"default" \| "narrow" \| "wide"` | `"default"` | Widest the dialog grows: 480px, 800px (default) or 940px. |
2932
+
2933
+ Tested examples: `stories/patterns/dialog.stories.tsx`
2934
+
2935
+ #### Drawer
2936
+
2937
+ A full-height panel that slides in at one edge over a dimmed page: navigation on a narrow screen (`start`), or filters and details (`end`). A header (glyph, title, an action), scrolling content and a footer; with `hideTitle`, only the content. Opening it puts the cursor in its first field, if it has one; Escape or a click on the page closes it, and focus stays inside while it is open.
2938
+
2939
+ ```ts
2940
+ import { Drawer } from "@primecoderin/fast-ui-react";
2941
+ ```
2942
+
2943
+ | Prop | Type | Default | Description |
2944
+ | --- | --- | --- | --- |
2945
+ | `open` * | `boolean` | | Whether it is open. Controlled: the caller keeps this state. |
2946
+ | `onOpenChange` * | `(open: boolean) => void` | | Called with the next open state (false on Escape, an outside click or a close button); set `open` from it. |
2947
+ | `title` * | `string` | | The drawer's name: shown in its header, and its accessible name. |
2948
+ | `children` * | `ReactNode` | | The content. |
2949
+ | `hideTitle` | `boolean` | `false` | Keep the title for assistive technology only, and draw no header: e.g. navigation that has its own heading. |
2950
+ | `side` | `DrawerSide` | `"end"` | |
2951
+ | `icon` | `ReactNode` | | A small glyph before the title. |
2952
+ | `headerAction` | `ReactNode` | | At the end of the header, e.g. a Reset button. |
2953
+ | `footer` | `ReactNode` | | Pinned under the content, e.g. the Apply button. |
2954
+ | `onSubmit` | `((event: SubmitEvent<HTMLFormElement>) => void)` | | Makes the content and footer one form, so Enter in a field submits it. |
2955
+ | `padding` | `DrawerPadding` | `"medium"` | |
2956
+ | `className` | `string` | | On the panel, e.g. a width: `w-[min(420px,90vw)]`. |
2957
+
2958
+ Tested examples: `stories/patterns/drawer.stories.tsx`
2959
+
2960
+ #### EmptyState
2961
+
2962
+ What a view shows when it has nothing to show: a title, an optional line, an icon and a call to action. It is a status region by default and an alert with `announce="assertive"` for a failure. A status region that appears with its text is often not announced, so where an empty result must be heard as it happens (a search that found nothing), also say so in a region that is already on the page, such as a results count. `variant="inline"` is the compact form for a table's empty row.
2963
+
2964
+ ```ts
2965
+ import { EmptyState } from "@primecoderin/fast-ui-react";
2966
+ ```
2967
+
2968
+ | Prop | Type | Default | Description |
2969
+ | --- | --- | --- | --- |
2970
+ | `title` * | `string` | | What the view has none of, e.g. "No projects yet". |
2971
+ | `description` | `string` | | A line under the title: why, or what to do next. |
2972
+ | `icon` | `ReactNode` | `<Search />` | The glyph on the disc or tile. Default a magnifying glass. |
2973
+ | `tone` | `ToneName` | `"neutral"` | The disc's colour, for `variant="page"`. Default neutral. |
2974
+ | `action` | `ReactNode` | | An optional call to action, e.g. a "Clear filters" button. |
2975
+ | `announce` | `"polite" \| "assertive"` | `"polite"` | The live region it is. "polite" (default) is a status region (`role="status"`): a change to its text while it is shown is announced at the next pause, but one that appears with its text is often not announced at all. "assertive", for a failure, is an alert (`role="alert"`), which is announced when it appears. |
2976
+ | `variant` | `"page" \| "inline"` | `"page"` | "page" fills a page or a card: an icon on a large disc. "inline" sits in a table's place (Figma's empty row): a small teal tile, a 13px title, one line. |
2977
+ | `className` | `string` | | Classes for the outer element, e.g. a height. |
2978
+
2979
+ Tested examples: `stories/patterns/empty-state.stories.tsx`
2980
+
2981
+ #### FieldFrame
2982
+
2983
+ The shared shell of every form field: label, control, validation message and hint, in a column or with the label beside the control. The field's state (invalid, and touched and dirty when a form library tracks them) goes through Base UI's Field, so the control is labelled and described for assistive technology automatically (for a control Base UI does not describe, see `messageIds`). Every field of the design system is built on it.
2984
+
2985
+ ```ts
2986
+ import { FieldFrame } from "@primecoderin/fast-ui-react";
2987
+ ```
2988
+
2989
+ | Prop | Type | Default | Description |
2990
+ | --- | --- | --- | --- |
2991
+ | `label` * | `string` | | The field's label, above the control or beside it. It names the control. |
2992
+ | `invalid` * | `boolean` | | Marks the field and its control invalid; the label turns red. |
2993
+ | `children` * | `ReactNode` | | The control. |
2994
+ | `name` | `string` | | The field's name: it identifies the field to Base UI and in a submitted form. |
2995
+ | `hideLabel` | `boolean` | `false` | Keep the label out of the layout and give it to assistive technology only. |
2996
+ | `hint` | `string` | | Help under the control, in grey; it describes the control. |
2997
+ | `required` | `boolean` | `false` | Adds the asterisk to the label. It does not mark the control: give the control `aria-required` too. |
2998
+ | `disabled` | `boolean` | `false` | Disables the field: Base UI controls inside it are disabled with it (a plain `<input>` needs its own `disabled`). |
2999
+ | `errorMessage` | `string` | | The validation message, already formatted for display. |
3000
+ | `successMessage` | `string` | | Shown instead of nothing when there is no error, in green, with a check. It describes the control and is announced when it appears. |
3001
+ | `touched` | `boolean` | | The field has been left. Base UI tracks it itself when omitted. |
3002
+ | `dirty` | `boolean` | | The value differs from the first one. Base UI tracks it itself when omitted. |
3003
+ | `orientation` | `FieldOrientation` | `"vertical"` | Label above the control (default) or in a column beside it. |
3004
+ | `size` | `FieldSize` | `"medium"` | The control's size, which sets the gap under the label. |
3005
+ | `triggerLabel` | `boolean` | `false` | The control is a button that opens a popup (select, combobox). Its label must not behave as a native <label>, which would also click the button. |
3006
+ | `labelId` | `string` | | The label's DOM id, for a control that names itself with `aria-labelledby` (a trigger whose button text is the chosen value, so it needs the label and the value both). |
3007
+ | `messageIds` | `{ error: string; hint: string; }` | | DOM ids for the validation message and the hint, for a control that Base UI does not describe by itself (a button that opens a panel): it lists them in its `aria-describedby`. |
3008
+
3009
+ Tested examples: `stories/patterns/form-fields/field-frame.stories.tsx`
3010
+
3011
+ #### FileUpload
3012
+
3013
+ A drop area and a button for choosing files, and the list of what was chosen, each with its size, a progress bar if the app reports one, and a button that removes it. Files are checked against `accept`, `maxSize` and `maxFiles` as they are added; what is refused is reported, not shown, so the app words it. The drop is for the pointer; the button is for everyone else. Sending the files is the app's; a form the browser submits itself sends them under `name`. A file's error is announced when the app sets it, and describes its Remove button.
3014
+
3015
+ ```ts
3016
+ import { FileUpload } from "@primecoderin/fast-ui-react";
3017
+ ```
3018
+
3019
+ | Prop | Type | Default | Description |
3020
+ | --- | --- | --- | --- |
3021
+ | `value` * | `readonly File[]` | | The chosen files, in the order they were added. |
3022
+ | `onValueChange` * | `(files: File[]) => void` | | Called with the new list when files are added or removed. |
3023
+ | `labels` * | `FileUploadLabels` | | Every text it shows or announces, in the user's language (the library has no built-in text). |
3024
+ | `accept` | `string` | | The kinds of file it takes, as the file input writes them: `"image/*,.pdf"`. Anything if omitted. |
3025
+ | `multiple` | `boolean` | `false` | Let several files be chosen. Otherwise a new choice replaces the one before, and of several files dropped at once the first that passes is taken and the others are reported to `onReject` as `count`. |
3026
+ | `maxSize` | `number` | | The largest a file may be, in bytes. |
3027
+ | `maxFiles` | `number` | | The most files the list takes. |
3028
+ | `onReject` | `((rejections: FileUploadRejection[]) => void)` | | Called with the files that were not added and why, so the app can tell the person in its own words. The files that were fine are added regardless. |
3029
+ | `statuses` | `ReadonlyMap<File, FileUploadStatus>` | | Progress and errors of the files, by file: the app sets them as it sends them. |
3030
+ | `description` | `string` | | A line in the drop area under the button: the limits, e.g. "PNG or JPG, up to 5 MB". |
3031
+ | `locale` | `string` | | The locale that writes the sizes, a BCP 47 tag. If omitted, the runtime's default locale (the browser's, or the server's when rendered there), not the page's `lang`. |
3032
+ | `disabled` | `boolean` | `false` | Not interactive, and shown as disabled. |
3033
+ | `invalid` | `boolean` | `false` | Draws the drop area red and marks it invalid for assistive technology. |
3034
+ | `name` | `string` | | The field's name in a submitted form. A hidden file input holds the chosen files, so a form the browser submits itself sends them under this name (where the browser can set a file input's files, as current browsers can). |
3035
+ | `id` | `string` | | |
3036
+ | `aria-label` | `string` | | The accessible name of the drop area, for an upload with no label element of its own. |
3037
+ | `aria-labelledby` | `string` | | The id of the element that names the drop area, such as a field's label. |
3038
+ | `aria-describedby` | `string` | | The ids of the field's message and hint. They describe the drop area and its Browse button, which takes the focus. |
3039
+ | `onBlur` | `(() => void)` | | The upload was left. |
3040
+ | `buttonRef` | `Ref<HTMLButtonElement>` | | The button that opens the chooser, for a form library to focus the first invalid field. |
3041
+ | `className` | `string` | | Extra classes on the root element, merged last so they win over the defaults. |
3042
+
3043
+ Tested examples: `stories/patterns/file-upload.stories.tsx`
3044
+
3045
+ #### List
3046
+
3047
+ Rows of text with an icon or avatar at the start and something at the end: contacts, files, notifications. A row can be a link, or a choice (one, or several, with the arrow keys or Tab and Space). Plain, it is a list a screen reader counts. For many records with columns, see DataTable.
3048
+
3049
+ ```ts
3050
+ import { List } from "@primecoderin/fast-ui-react";
3051
+ ```
3052
+
3053
+ | Prop | Type | Default | Description |
3054
+ | --- | --- | --- | --- |
3055
+ | `items` * | `readonly ListItem[]` | | |
3056
+ | `aria-label` * | `string` | | Accessible name of the list (of the group, when rows can be chosen). |
3057
+ | `selection` | `"none" \| "multiple" \| "single"` | `"none"` | Whether rows can be chosen: none (default), one (a choice, like radio buttons), or several (like checkboxes). |
3058
+ | `value` | `readonly string[]` | `[]` | The `id`s of the chosen rows. For `single` it holds one at most. |
3059
+ | `onValueChange` | `((value: string[]) => void)` | | Called with the `id`s of the chosen rows. |
3060
+ | `dividers` | `boolean` | `true` | A rule between the rows. |
3061
+ | `className` | `string` | | Extra classes on the root element, merged last so they win over the defaults. |
3062
+
3063
+ Tested examples: `stories/patterns/list.stories.tsx`
3064
+
3065
+ #### MentionsInput
3066
+
3067
+ A text area that suggests people as you type their name after "@": the list filters as you type, the arrow keys move through it, Enter or Tab writes the name into the text and Escape closes the list. The value is plain text, so the app finds the mentions it needs in it. To a screen reader it is a text box whose suggestions are announced as the arrow keys move through them.
3068
+
3069
+ ```ts
3070
+ import { MentionsInput } from "@primecoderin/fast-ui-react";
3071
+ ```
3072
+
3073
+ | Prop | Type | Default | Description |
3074
+ | --- | --- | --- | --- |
3075
+ | `value` * | `string` | | The text, with each mention written as the trigger and the name: "Ask |
3076
+ | `onValueChange` * | `(value: string) => void` | | Called with the text as it is typed, and when a person is chosen from the list. |
3077
+ | `suggestions` * | `readonly MentionSuggestion[]` | | The people that can be mentioned. |
3078
+ | `trigger` | `string` | `"@"` | The character that starts a mention. Default "@". |
3079
+ | `onMention` | `((suggestion: MentionSuggestion) => void)` | | Called with the person when one is chosen from the list. |
3080
+ | `maxSuggestions` | `number` | `6` | The most suggestions listed. Default 6. |
3081
+ | `placeholder` | `string` | | Shown in the empty text area, e.g. "Type @ to mention someone". |
3082
+ | `rows` | `number` | `4` | The height of the text area in lines. Default 4. |
3083
+ | `disabled` | `boolean` | `false` | Makes the text area read only and greyed. |
3084
+ | `invalid` | `boolean` | `false` | Draws the box red and marks the text area invalid for assistive technology. |
3085
+ | `required` | `boolean` | `false` | Marks the text area required for assistive technology; the label shows the asterisk. |
3086
+ | `size` | `FieldSize` | `"medium"` | The field size, as the other inputs have it. Default `medium`. |
3087
+ | `id` | `string` | | For a `<label htmlFor>` that names the text area. The list of suggestions is then named only by `aria-label`. |
3088
+ | `aria-label` | `string` | | What names the text area, and its list of suggestions, when there is no visible label. |
3089
+ | `aria-labelledby` | `string` | | The id of the element that names the text area and its list of suggestions, such as a field's label. |
3090
+ | `aria-describedby` | `string` | | The ids of the field's message and hint, read after the name. |
3091
+ | `onBlur` | `(() => void)` | | The text area was left. |
3092
+ | `inputRef` | `Ref<HTMLTextAreaElement>` | | The `<textarea>`, for a form library to focus the first invalid field. |
3093
+ | `className` | `string` | | Extra classes for the box around the text area and its list. Merged last. |
3094
+
3095
+ Tested examples: `stories/patterns/mentions-input.stories.tsx`
3096
+
3097
+ #### Menubar
3098
+
3099
+ An application's menu bar (File, Edit, View): a row of menus that is one stop in the Tab order. The left and right arrow keys move between the menus (the other way in right to left), and while one is open, moving to another opens it at once. Each menu's items are Menu's.
3100
+
3101
+ ```ts
3102
+ import { Menubar } from "@primecoderin/fast-ui-react";
3103
+ ```
3104
+
3105
+ | Prop | Type | Default | Description |
3106
+ | --- | --- | --- | --- |
3107
+ | `children` * | `ReactNode` | | The menus: one MenubarMenu each. |
3108
+ | `aria-label` * | `string` | | Accessible name of the bar, e.g. "Application". |
3109
+ | `className` | `string` | | Extra classes on the root element, merged last so they win over the defaults. |
3110
+
3111
+ Tested examples: `stories/patterns/menubar.stories.tsx`
3112
+
3113
+ #### MenubarMenu
3114
+
3115
+ One menu of a Menubar.
3116
+
3117
+ ```ts
3118
+ import { MenubarMenu } from "@primecoderin/fast-ui-react";
3119
+ ```
3120
+
3121
+ | Prop | Type | Default | Description |
3122
+ | --- | --- | --- | --- |
3123
+ | `label` * | `string` | | The button on the bar that opens the menu. |
3124
+ | `children` * | `ReactNode` | | The menu's items: MenuItem, MenuSeparator, MenuSubmenu and the rest of Menu's parts. |
3125
+
3126
+
3127
+ #### MultiSelect
3128
+
3129
+ A select for several options. The chosen ones are chips in the box, each with a button that removes it, and the box grows onto more lines as chips are added. Typing filters the list, the arrow keys and Enter add an option and the list stays open for the next; Backspace in the empty input removes the last chip.
3130
+
3131
+ ```ts
3132
+ import { MultiSelect } from "@primecoderin/fast-ui-react";
3133
+ ```
3134
+
3135
+ | Prop | Type | Default | Description |
3136
+ | --- | --- | --- | --- |
3137
+ | `options` * | `readonly ComboboxOption[]` | | |
3138
+ | `value` * | `readonly string[]` | | The `value`s of the chosen options, in the order they were chosen. |
3139
+ | `onValueChange` * | `(value: string[]) => void` | | Called with the `value`s of the chosen options. |
3140
+ | `labels` * | `MultiSelectLabels` | | Every text it shows or announces, in the user's language (the library has no built-in text). |
3141
+ | `placeholder` | `string` | | |
3142
+ | `disabled` | `boolean` | `false` | Not interactive, and shown as disabled. |
3143
+ | `invalid` | `boolean` | `false` | Draws the box red and marks the input invalid for assistive technology. |
3144
+ | `required` | `boolean` | `false` | Marks the input required for assistive technology; the label shows the asterisk. |
3145
+ | `size` | `FieldSize` | `"medium"` | "small" is the compact density. |
3146
+ | `contentBefore` | `ReactNode` | | A decorative icon at the start of the box. |
3147
+ | `name` | `string` | | The field's name in a submitted form. |
3148
+ | `id` | `string` | | For a `<label htmlFor>` that names the input. |
3149
+ | `aria-label` | `string` | | The accessible name of the input and of its list of options, for a control with no label element of its own. Give this or `aria-labelledby`. |
3150
+ | `aria-labelledby` | `string` | | The id of the element that names the input and its list of options, such as a field's label. |
3151
+ | `onBlur` | `(() => void)` | | The control was left. |
3152
+ | `inputRef` | `Ref<HTMLInputElement>` | | The `<input>`, for a form library to focus the first invalid field. |
3153
+
3154
+ Tested examples: `stories/patterns/multi-select.stories.tsx`
3155
+
3156
+ #### NavigationMenu
3157
+
3158
+ The top navigation of a site: links, and buttons that open a panel of more links. The panels open on hover and on click, and the arrow keys move between the items and into a panel; Escape closes one. For navigation down the side of the page, see SideNav.
3159
+
3160
+ ```ts
3161
+ import { NavigationMenu } from "@primecoderin/fast-ui-react";
3162
+ ```
3163
+
3164
+ | Prop | Type | Default | Description |
3165
+ | --- | --- | --- | --- |
3166
+ | `items` * | `readonly NavigationMenuItem[]` | | |
3167
+ | `aria-label` * | `string` | | Accessible name of the navigation, e.g. "Main". |
3168
+ | `className` | `string` | | Extra classes on the root element, merged last so they win over the defaults. |
3169
+
3170
+ Tested examples: `stories/patterns/navigation-menu.stories.tsx`
3171
+
3172
+ #### NumberField
3173
+
3174
+ A number input with a button at each end to step it. Typing is free and checked on leaving (a number out of `min` and `max` snaps back), the up and down arrow keys step, and `format` and `locale` write the number the way the user reads it. The number reads left to right in a right-to-left language too, while the buttons follow the page. Inside a FormNumberField it is labelled and described by the field.
3175
+
3176
+ ```ts
3177
+ import { NumberField } from "@primecoderin/fast-ui-react";
3178
+ ```
3179
+
3180
+ | Prop | Type | Default | Description |
3181
+ | --- | --- | --- | --- |
3182
+ | `value` * | `number \| null` | | The number, or null for an empty field. |
3183
+ | `onValueChange` * | `(value: number \| null) => void` | | Called with the new number as the person types or steps, and with null when the field is emptied. |
3184
+ | `labels` * | `NumberFieldLabels` | | Every text it shows or announces, in the user's language (the library has no built-in text). |
3185
+ | `min` | `number` | | |
3186
+ | `max` | `number` | | |
3187
+ | `step` | `number` | `1` | What the buttons and the up and down arrow keys change. Default 1. |
3188
+ | `largeStep` | `number` | | What Shift with the arrow keys (or Page Up and Page Down) change. Default 10. |
3189
+ | `format` | `NumberFormatOptions` | | How the number is written: `{ style: "currency", currency: "USD" }`, `{ maximumFractionDigits: 1 }`. |
3190
+ | `locale` | `LocalesArgument` | | The locale that writes and reads the number. The page's if omitted. |
3191
+ | `placeholder` | `string` | | |
3192
+ | `disabled` | `boolean` | `false` | Not interactive, and shown as disabled. |
3193
+ | `readOnly` | `boolean` | `false` | |
3194
+ | `invalid` | `boolean` | `false` | Draws the box red and marks the input invalid for assistive technology. |
3195
+ | `required` | `boolean` | `false` | Marks the input required for assistive technology; the label shows the asterisk. |
3196
+ | `size` | `FieldSize` | `"medium"` | "small" is the compact density. |
3197
+ | `contentBefore` | `ReactNode` | | A decorative icon or unit at the start of the box. |
3198
+ | `name` | `string` | | The field's name in a submitted form. |
3199
+ | `id` | `string` | | For a `<label htmlFor>` that names the input. |
3200
+ | `aria-label` | `string` | | The accessible name of the input, for a number with no label element of its own. |
3201
+ | `aria-labelledby` | `string` | | The id of the element that names the input, such as a field's label. |
3202
+ | `onBlur` | `(() => void)` | | The field was left. |
3203
+ | `inputRef` | `Ref<HTMLInputElement>` | | The `<input>`, for a form library to focus the first invalid field. |
3204
+ | `className` | `string` | | Extra classes on the root element, merged last so they win over the defaults. |
3205
+
3206
+ Tested examples: `stories/patterns/number-field.stories.tsx`
3207
+
3208
+ #### Pagination
3209
+
3210
+ Previous, page numbers, next, a page-size select and a "Showing 1–20 of 250" summary.
3211
+
3212
+ ```ts
3213
+ import { Pagination } from "@primecoderin/fast-ui-react";
3214
+ ```
3215
+
3216
+ | Prop | Type | Default | Description |
3217
+ | --- | --- | --- | --- |
3218
+ | `page` * | `number` | | The current page, counting from 1. |
3219
+ | `pageSize` * | `number` | | |
3220
+ | `totalItems` * | `number` | | |
3221
+ | `onPageChange` * | `(page: number) => void` | | |
3222
+ | `labels` * | `PaginationLabels` | | Every text it shows or announces, in the user's language (the library has no built-in text). |
3223
+ | `onPageSizeChange` | `((pageSize: number) => void)` | | With `pageSizeOptions`, shows a page-size select. |
3224
+ | `pageSizeOptions` | `readonly number[]` | | |
3225
+
3226
+ Tested examples: `stories/foundations/branding.stories.tsx`, `stories/patterns/pagination.stories.tsx`
3227
+
3228
+ #### PhoneField
3229
+
3230
+ A phone number: a searchable calling-code picker and a digits-only number in one box, holding the number in E.164. The box is always left to right: numbers read that way in a right-to-left language too. A number pasted with its calling code ("+44 7700 900123") sets the code as well as the digits. It is controlled: it shows `value` and reports each change through `onValueChange`; clearing the digits keeps the calling code shown. Bound to react-hook-form, it is FormPhoneField.
3231
+
3232
+ ```ts
3233
+ import { PhoneField } from "@primecoderin/fast-ui-react";
3234
+ ```
3235
+
3236
+ | Prop | Type | Default | Description |
3237
+ | --- | --- | --- | --- |
3238
+ | `label` * | `string` | | The visible label. |
3239
+ | `value` * | `string` | | The number in E.164: the calling code and the digits with nothing between, e.g. "+12025550123" (`joinPhone` and `splitPhone` convert it). An empty string for none. |
3240
+ | `onValueChange` * | `(value: string) => void` | | Called with the new number in E.164, or "" when the digits are cleared. |
3241
+ | `countries` * | `readonly PhoneCountry[]` | | |
3242
+ | `defaultDialCode` * | `string` | | The calling code shown while no number has been entered. |
3243
+ | `labels` * | `PhoneFieldLabels` | | Every text it shows or announces, in the user's language (the library has no built-in text). |
3244
+ | `name` | `string` | | The field's name in a submitted form. |
3245
+ | `placeholder` | `string` | | |
3246
+ | `maxDigits` | `number` | `13` | The most digits the number takes. |
3247
+ | `hint` | `string` | | |
3248
+ | `errorMessage` | `string` | | The validation message, in the user's language: shown in red under the field, which it marks invalid. |
3249
+ | `invalid` | `boolean` | `false` | Marks the field invalid without a message to show. |
3250
+ | `required` | `boolean` | | |
3251
+ | `disabled` | `boolean` | `false` | Not interactive, and shown as disabled. |
3252
+ | `size` | `FieldSize` | `"medium"` | |
3253
+ | `orientation` | `FieldOrientation` | | |
3254
+ | `onBlur` | `(() => void)` | | The calling code or the number was left. |
3255
+ | `inputRef` | `Ref<HTMLInputElement>` | | The number's `<input>`, e.g. for a form library to focus the first invalid field. |
3256
+
3257
+ Tested examples: `stories/patterns/form-fields/phone-field.stories.tsx`
3258
+
3259
+ #### RadioGroupField
3260
+
3261
+ A labelled radio group with the design system's hint and error. It is controlled: it checks the option whose `value` is `value` and reports a choice through `onValueChange`. Bound to react-hook-form, it is FormRadioGroupField.
3262
+
3263
+ ```ts
3264
+ import { RadioGroupField } from "@primecoderin/fast-ui-react";
3265
+ ```
3266
+
3267
+ | Prop | Type | Default | Description |
3268
+ | --- | --- | --- | --- |
3269
+ | `label` * | `string` | | The visible label. |
3270
+ | `options` * | `readonly RadioOption[]` | | |
3271
+ | `value` * | `string` | | The chosen option's `value`; an empty string for none. |
3272
+ | `onValueChange` * | `(value: string) => void` | | Called with the chosen option's `value`. |
3273
+ | `name` | `string` | | The field's name in a submitted form. |
3274
+ | `hint` | `string` | | |
3275
+ | `errorMessage` | `string` | | The validation message, in the user's language: shown in red under the group, which it marks invalid. |
3276
+ | `invalid` | `boolean` | `false` | Marks the group invalid without a message to show. |
3277
+ | `required` | `boolean` | `false` | |
3278
+ | `disabled` | `boolean` | `false` | Not interactive, and shown as disabled. |
3279
+ | `orientation` | `FieldOrientation` | `"vertical"` | Label above the group (default) or in a column beside it. |
3280
+ | `layout` | `"vertical" \| "horizontal"` | `"vertical"` | Lay the options out in a column (default) or a row. |
3281
+ | `onBlur` | `(() => void)` | | An option was left. |
3282
+ | `inputRef` | `Ref<HTMLInputElement>` | | The group's hidden input, e.g. for a form library to focus the first invalid field. |
3283
+
3284
+ Tested examples: `stories/patterns/form-fields/radio-group-field.stories.tsx`
3285
+
3286
+ #### ResizablePanels
3287
+
3288
+ Panels with dividers between them that the person drags to give one more room and the next less. The dividers are focusable separators with a value, so the arrow keys move them too (1%, or 10% with Shift), and Home and End take the panel before to its least and most. Side by side, the panels run the way the page reads. Give the container a height.
3289
+
3290
+ ```ts
3291
+ import { ResizablePanels } from "@primecoderin/fast-ui-react";
3292
+ ```
3293
+
3294
+ | Prop | Type | Default | Description |
3295
+ | --- | --- | --- | --- |
3296
+ | `panels` * | `readonly ResizablePanel[]` | | |
3297
+ | `labels` * | `ResizablePanelsLabels` | | Every text it shows or announces, in the user's language (the library has no built-in text). |
3298
+ | `orientation` | `"vertical" \| "horizontal"` | `"horizontal"` | Side by side (default) or one above the other. |
3299
+ | `sizes` | `readonly number[]` | | The sizes in percent, one for each panel, adding up to 100. Leave it out to let the panels keep their own. |
3300
+ | `onSizesChange` | `((sizes: number[]) => void)` | | Called with the sizes as a divider moves. |
3301
+ | `aria-label` | `string` | | What the panels are, e.g. "Mail". A group's name. |
3302
+ | `className` | `string` | | Extra classes on the root element, merged last so they win over the defaults. |
3303
+
3304
+ Tested examples: `stories/patterns/resizable-panels.stories.tsx`
3305
+
3306
+ #### SearchInput
3307
+
3308
+ Figma's search input: a magnifier at the start and, once there is text, a clear button at the end. It is the box every input uses (`fieldControl`), so it hovers, focuses and disables like them and lines up beside a FormTextField in a filter bar. Controlled; the caller debounces.
3309
+
3310
+ ```ts
3311
+ import { SearchInput } from "@primecoderin/fast-ui-react";
3312
+ ```
3313
+
3314
+ | Prop | Type | Default | Description |
3315
+ | --- | --- | --- | --- |
3316
+ | `value` * | `string` | | The search text. |
3317
+ | `onValueChange` * | `(value: string) => void` | | Called with the whole text as each key is pressed, and with "" when the clear button empties it. Debounce it yourself. |
3318
+ | `aria-label` * | `string` | | Accessible name of the input. |
3319
+ | `clearLabel` * | `string` | | Accessible name of the clear button that appears once there is text. |
3320
+ | `placeholder` | `string` | | Shown while the input is empty, e.g. "Search projects". It does not name the input: give `aria-label`. |
3321
+ | `size` | `FieldSize` | `"medium"` | The box's height: "small" 32px, "medium" 42px (the default), "large" 46px, as the other fields. |
3322
+ | `disabled` | `boolean` | `false` | Greys the box out; the input cannot be focused and the clear button is not shown. |
3323
+ | `className` | `string` | | Classes for the box around the input, merged last. |
3324
+
3325
+ Tested examples: `stories/patterns/search-input.stories.tsx`
3326
+
3327
+ #### SelectField
3328
+
3329
+ A labelled select with the design system's hint and error. It is controlled: it shows the option whose `value` is `value` and reports a choice through `onValueChange`. Bound to react-hook-form, it is FormSelectField.
3330
+
3331
+ ```ts
3332
+ import { SelectField } from "@primecoderin/fast-ui-react";
3333
+ ```
3334
+
3335
+ | Prop | Type | Default | Description |
3336
+ | --- | --- | --- | --- |
3337
+ | `label` * | `string` | | The visible label. |
3338
+ | `options` * | `readonly SelectOption[]` | | |
3339
+ | `value` * | `string` | | The chosen option's `value`; an empty string for none, which shows the placeholder. |
3340
+ | `onValueChange` * | `(value: string) => void` | | Called with the chosen option's `value`. |
3341
+ | `name` | `string` | | The field's name in a submitted form. |
3342
+ | `placeholder` | `string` | | |
3343
+ | `hint` | `string` | | |
3344
+ | `errorMessage` | `string` | | The validation message, in the user's language: shown in red under the field, which it marks invalid. |
3345
+ | `invalid` | `boolean` | `false` | Marks the field invalid without a message to show. |
3346
+ | `required` | `boolean` | | |
3347
+ | `disabled` | `boolean` | `false` | Not interactive, and shown as disabled. |
3348
+ | `size` | `FieldSize` | `"medium"` | "small" is the compact density. |
3349
+ | `orientation` | `FieldOrientation` | | Label above the control (default) or in a column beside it. |
3350
+ | `hideLabel` | `boolean` | `false` | Keep the label for assistive technology only, e.g. a select in a table row. |
3351
+ | `contentBefore` | `ReactNode` | | A decorative icon at the start of the box. |
3352
+ | `onBlur` | `(() => void)` | | The select was left. |
3353
+ | `inputRef` | `Ref<HTMLInputElement>` | | The select's hidden input, e.g. for a form library to focus the first invalid field. |
3354
+
3355
+ Tested examples: `stories/patterns/form-fields/select-field.stories.tsx`
3356
+
3357
+ #### SideNav
3358
+
3359
+ The navigation down the side of an app: sections of items with glyphs, the page the person is on highlighted, groups that open a list under them, and a collapsed form that is only icons. It is a `<nav>`; the current item is `aria-current="page"`. Put it in AppShell, which gives it a column and turns it into a drawer on a narrow screen.
3360
+
3361
+ ```ts
3362
+ import { SideNav } from "@primecoderin/fast-ui-react";
3363
+ ```
3364
+
3365
+ | Prop | Type | Default | Description |
3366
+ | --- | --- | --- | --- |
3367
+ | `sections` * | `readonly SideNavSection[]` | | |
3368
+ | `aria-label` * | `string` | | Accessible name of the navigation, e.g. "Main". |
3369
+ | `current` | `string` | | The `id` of the item for the page the person is on: it is highlighted and gets `aria-current="page"`. |
3370
+ | `collapsed` | `boolean` | `false` | Show only the icons: a narrow bar, each item named by a tooltip (and, for a screen reader, by its label). A group's list does not fit there, so choosing a group calls `onExpandRequest`. |
3371
+ | `onExpandRequest` | `(() => void)` | | Called when a group is chosen in the collapsed bar: expand the bar. |
3372
+ | `onNavigate` | `(() => void)` | | Called after an item is chosen, e.g. to close a drawer the navigation sits in. |
3373
+ | `className` | `string` | | Extra classes on the root element, merged last so they win over the defaults. |
3374
+
3375
+ Tested examples: `stories/patterns/side-nav.stories.tsx`
3376
+
3377
+ #### Stat
3378
+
3379
+ One figure with its label, and optionally a line of context, an icon and a trend. On its own it is a card; inside a `StatGroup` it is one of the group's items, drawn as the group's variant asks.
3380
+
3381
+ ```ts
3382
+ import { Stat } from "@primecoderin/fast-ui-react";
3383
+ ```
3384
+
3385
+ | Prop | Type | Default | Description |
3386
+ | --- | --- | --- | --- |
3387
+ | `label` * | `string` | | The visible label. |
3388
+ | `value` * | `ReactNode` | | The figure, formatted by the caller. |
3389
+ | `description` | `string` | | A line of context under the figure, e.g. "this month". |
3390
+ | `icon` | `ReactNode` | | A glyph in a tile beside the label. A strip shows none. |
3391
+ | `tone` | `IconTileTone` | | The icon tile's colour. |
3392
+ | `trend` | `StatTrend` | | |
3393
+ | `className` | `string` | | Extra classes on the root element, merged last so they win over the defaults. |
3394
+
3395
+ Tested examples: `stories/foundations/branding.stories.tsx`, `stories/patterns/stat.stories.tsx`
3396
+
3397
+ #### StatGroup
3398
+
3399
+ A named list of `Stat`s in a row, as separate cards (`cards`) or one card split into cells (`strip`). The items stack on a narrow screen. <StatGroup aria-label="Order summary"> <Stat label="Orders" value={128} description="this month" icon={<ShoppingCart />} /> <Stat label="Failed" value={4} icon={<CircleAlert />} tone="error" /> </StatGroup>
3400
+
3401
+ ```ts
3402
+ import { StatGroup } from "@primecoderin/fast-ui-react";
3403
+ ```
3404
+
3405
+ | Prop | Type | Default | Description |
3406
+ | --- | --- | --- | --- |
3407
+ | `aria-label` * | `string` | | Accessible name of the list, e.g. "Order summary". |
3408
+ | `children` * | `ReactNode` | | The `Stat`s. |
3409
+ | `variant` | `StatGroupVariant` | `"cards"` | |
3410
+ | `className` | `string` | | Extra classes on the root element, merged last so they win over the defaults. |
3411
+
3412
+ Tested examples: `stories/foundations/branding.stories.tsx`
3413
+
3414
+ #### Stepper
3415
+
3416
+ The steps of a process and where the person is in it: done, current, ahead. An ordered list, so a screen reader announces "step 2 of 4"; the current step is `aria-current="step"` and a step that is done says so through `labels.completed`. With `onStepClick` the steps that are done are buttons that go back.
3417
+
3418
+ ```ts
3419
+ import { Stepper } from "@primecoderin/fast-ui-react";
3420
+ ```
3421
+
3422
+ | Prop | Type | Default | Description |
3423
+ | --- | --- | --- | --- |
3424
+ | `steps` * | `readonly StepperStep[]` | | |
3425
+ | `current` * | `number` | | The index of the step the person is on: those before it are done, those after it are ahead. |
3426
+ | `labels` * | `StepperLabels` | | Every text it shows or announces, in the user's language (the library has no built-in text). |
3427
+ | `aria-label` * | `string` | | Accessible name of the list, e.g. "Checkout progress". |
3428
+ | `orientation` | `"vertical" \| "horizontal"` | `"horizontal"` | A row (default) or a column. |
3429
+ | `onStepClick` | `((index: number) => void)` | | Makes the steps that are done buttons, so the person can go back to one. Called with its index. |
3430
+ | `className` | `string` | | Extra classes on the root element, merged last so they win over the defaults. |
3431
+
3432
+ Tested examples: `stories/patterns/stepper.stories.tsx`
3433
+
3434
+ #### SwitchField
3435
+
3436
+ A switch with its label: a settings row, the label at the start and the switch at the far end. It is controlled: it shows `checked` and reports a change through `onCheckedChange`. Bound to react-hook-form, it is FormSwitchField.
3437
+
3438
+ ```ts
3439
+ import { SwitchField } from "@primecoderin/fast-ui-react";
3440
+ ```
3441
+
3442
+ | Prop | Type | Default | Description |
3443
+ | --- | --- | --- | --- |
3444
+ | `label` * | `string` | | The visible label. |
3445
+ | `checked` * | `boolean` | | Whether it is checked. Controlled: the caller keeps this state. |
3446
+ | `onCheckedChange` * | `(checked: boolean) => void` | | Called with the new state when the person flips the switch. |
3447
+ | `name` | `string` | | The field's name in a submitted form. |
3448
+ | `hideLabel` | `boolean` | `false` | Show the switch alone, with the label kept for assistive technology. For a layout that draws the label itself, e.g. in a label column. |
3449
+ | `disabled` | `boolean` | `false` | Not interactive, and shown as disabled. |
3450
+ | `invalid` | `boolean` | `false` | Marks the switch invalid for assistive technology. |
3451
+ | `onBlur` | `(() => void)` | | The switch was left. |
3452
+ | `inputRef` | `Ref<HTMLInputElement>` | | The switch's hidden input, e.g. for a form library to focus the first invalid field. |
3453
+
3454
+ Tested examples: `stories/patterns/form-fields/switch-field.stories.tsx`
3455
+
3456
+ #### TagGroup
3457
+
3458
+ A named list of removable tags: light brand-tinted pills, each a button that removes its tag, and an optional "Clear all". The applied filters of a list, the recipients of a message, chosen labels. Renders nothing when there are no items. A remove button or Clear all that had the keyboard focus takes it away with itself, so once the app has removed the tag the focus moves on: to the tag now in its place, to the one before when it was the last, and to `emptyFocusRef` when none is left.
3459
+
3460
+ ```ts
3461
+ import { TagGroup } from "@primecoderin/fast-ui-react";
3462
+ ```
3463
+
3464
+ | Prop | Type | Default | Description |
3465
+ | --- | --- | --- | --- |
3466
+ | `items` * | `readonly TagGroupItem[]` | | The tags, in order. |
3467
+ | `aria-label` * | `string` | | Accessible name of the list, e.g. "Active filters". |
3468
+ | `onRemove` * | `(id: string) => void` | | Called with a tag's id when its remove button is used. |
3469
+ | `labels` * | `TagGroupLabels` | | The remove buttons' names and the "Clear all" text. |
3470
+ | `onClearAll` | `(() => void)` | | Called by the "Clear all" button, shown when this and `labels.clearAll` are given. |
3471
+ | `emptyFocusRef` | `RefObject<HTMLElement \| null>` | | The element that takes the keyboard focus when the last tag goes (removed, or by Clear all), e.g. the field or button that adds tags. The group renders nothing once it is empty, so without this the focus is lost to the page, as it is whenever the focused element goes away. |
3472
+ | `className` | `string` | | Classes for the outer element, e.g. a margin. |
3473
+
3474
+ Tested examples: `stories/patterns/tag-group.stories.tsx`
3475
+
3476
+ #### TagsInput
3477
+
3478
+ An input that turns what is typed into tags: Enter or a separator (a comma) ends a tag, a tag is removed with the button on it or with Backspace in the empty input, and text left in the input when it is left becomes a tag. For a choice from a fixed list, see MultiSelect.
3479
+
3480
+ ```ts
3481
+ import { TagsInput } from "@primecoderin/fast-ui-react";
3482
+ ```
3483
+
3484
+ | Prop | Type | Default | Description |
3485
+ | --- | --- | --- | --- |
3486
+ | `value` * | `readonly string[]` | | The tags, in the order they were added. |
3487
+ | `onValueChange` * | `(value: string[]) => void` | | Called with the new list of tags. |
3488
+ | `labels` * | `TagsInputLabels` | | Every text it shows or announces, in the user's language (the library has no built-in text). |
3489
+ | `separators` | `readonly string[]` | `[","]` | The characters that end a tag as they are typed or pasted, besides Enter. Default `[","]`. Pasted text is split at them, so pasting "a, b, c" adds three tags. |
3490
+ | `allowDuplicates` | `boolean` | `false` | Let the same tag be added twice. By default a tag already in the list is not added again. |
3491
+ | `maxTags` | `number` | | The most tags the list takes; the input stops adding past it. |
3492
+ | `isValidTag` | `((tag: string) => boolean)` | | Returns false for a tag that must not be added (an email address that is not one); the text stays in the input. |
3493
+ | `placeholder` | `string` | | |
3494
+ | `disabled` | `boolean` | `false` | Not interactive, and shown as disabled. |
3495
+ | `invalid` | `boolean` | `false` | Draws the box red and marks the input invalid for assistive technology. |
3496
+ | `required` | `boolean` | `false` | Marks the input required for assistive technology; the label shows the asterisk. |
3497
+ | `size` | `FieldSize` | `"medium"` | "small" is the compact density. |
3498
+ | `id` | `string` | | For a `<label htmlFor>` that names the input. |
3499
+ | `aria-label` | `string` | | The accessible name of the input, for a control with no label element of its own. |
3500
+ | `aria-labelledby` | `string` | | The id of the element that names the input, such as a field's label. |
3501
+ | `aria-describedby` | `string` | | The ids of the field's message and hint, read after the name. |
3502
+ | `onBlur` | `(() => void)` | | The control was left. Text typed and not yet a tag becomes one first. |
3503
+ | `inputRef` | `Ref<HTMLInputElement>` | | The `<input>`, for a form library to focus the first invalid field. |
3504
+
3505
+ Tested examples: `stories/patterns/tags-input.stories.tsx`
3506
+
3507
+ #### TextAreaField
3508
+
3509
+ A labelled multi-line input with the design system's hint and error. It is controlled: it shows `value` and reports each change through `onValueChange`. Bound to react-hook-form, it is FormTextAreaField.
3510
+
3511
+ ```ts
3512
+ import { TextAreaField } from "@primecoderin/fast-ui-react";
3513
+ ```
3514
+
3515
+ | Prop | Type | Default | Description |
3516
+ | --- | --- | --- | --- |
3517
+ | `label` * | `string` | | The visible label. |
3518
+ | `value` * | `string` | | The text in the field. |
3519
+ | `onValueChange` * | `(value: string) => void` | | Called with the new text as the person types. |
3520
+ | `name` | `string` | | The field's name in a submitted form. |
3521
+ | `hint` | `string` | | |
3522
+ | `errorMessage` | `string` | | The validation message, in the user's language: shown in red under the field, which it marks invalid. |
3523
+ | `invalid` | `boolean` | `false` | Marks the field invalid without a message to show. |
3524
+ | `required` | `boolean` | | |
3525
+ | `disabled` | `boolean` | `false` | Not interactive, and shown as disabled. |
3526
+ | `placeholder` | `string` | | |
3527
+ | `maxLength` | `number` | | |
3528
+ | `rows` | `number` | | |
3529
+ | `autoComplete` | `string` | | |
3530
+ | `size` | `FieldSize` | `"medium"` | "small" is the compact density. |
3531
+ | `resize` | `"none" \| "vertical" \| "horizontal" \| "both"` | `"vertical"` | Which way the user can drag the corner to resize. Defaults to vertical. |
3532
+ | `orientation` | `FieldOrientation` | | Label above the control (default) or in a column beside it. |
3533
+ | `onBlur` | `(() => void)` | | The text area was left. |
3534
+ | `inputRef` | `Ref<HTMLTextAreaElement>` | | The `<textarea>`, e.g. for a form library to focus the first invalid field. |
3535
+
3536
+ Tested examples: `stories/patterns/form-fields/text-area-field.stories.tsx`
3537
+
3538
+ #### TextField
3539
+
3540
+ A labelled text input with the design system's hint, error and confirmation. It is controlled: it shows `value` and reports each change through `onValueChange`. Bound to react-hook-form, it is FormTextField.
3541
+
3542
+ ```ts
3543
+ import { TextField } from "@primecoderin/fast-ui-react";
3544
+ ```
3545
+
3546
+ | Prop | Type | Default | Description |
3547
+ | --- | --- | --- | --- |
3548
+ | `label` * | `string` | | The visible label. |
3549
+ | `value` * | `string` | | The text in the field. |
3550
+ | `onValueChange` * | `(value: string) => void` | | Called with the new text as the person types. A change `acceptInput` refuses never arrives. |
3551
+ | `hint` | `string` | | |
3552
+ | `errorMessage` | `string` | | The validation message, in the user's language: shown in red under the field, which it marks invalid. |
3553
+ | `invalid` | `boolean` | `false` | Marks the field invalid without a message to show. |
3554
+ | `successMessage` | `string` | | Shown in green, with a check, while the field is valid: a confirmation such as "Name is available". The caller decides when it applies; FormTextField shows it once the field has been left with a valid value. |
3555
+ | `required` | `boolean` | | |
3556
+ | `size` | `FieldSize` | `"medium"` | "small" is the compact density; "large" is for sign-in style screens. |
3557
+ | `orientation` | `FieldOrientation` | | Label above the control (default) or in a column beside it. |
3558
+ | `hideLabel` | `boolean` | `false` | Keep the label out of the layout and give it to assistive technology only. For inputs whose meaning is clear from a placeholder or their neighbours. |
3559
+ | `contentBefore` | `ReactNode` | | Content inside the box, before and after the text. Decorative icons, units. |
3560
+ | `contentAfter` | `ReactNode` | | |
3561
+ | `passwordToggleLabels` | `PasswordToggleLabels` | | Adds a show/hide button when type is "password". Texts come from the caller. |
3562
+ | `acceptInput` | `((value: string) => boolean)` | | Keystroke filter: a change is ignored when this returns false for the new value, so the field never holds invalid text (e.g. numeric masks). |
3563
+ | `inputRef` | `Ref<HTMLInputElement>` | | The `<input>`, e.g. for a form library to focus the first invalid field. |
3564
+
3565
+ Tested examples: `stories/patterns/form-fields/text-field.stories.tsx`
3566
+
3567
+ #### Timeline
3568
+
3569
+ Events in the order they happened, joined by a line, each with a dot, a title, the time and a description. An ordered list, so a screen reader counts the events. The caller sorts the events.
3570
+
3571
+ ```ts
3572
+ import { Timeline } from "@primecoderin/fast-ui-react";
3573
+ ```
3574
+
3575
+ | Prop | Type | Default | Description |
3576
+ | --- | --- | --- | --- |
3577
+ | `events` * | `readonly TimelineEvent[]` | | The events in the order they are shown: newest first or oldest first is the caller's. |
3578
+ | `aria-label` * | `string` | | Accessible name of the list, e.g. "Order history". |
3579
+ | `className` | `string` | | Extra classes on the root element, merged last so they win over the defaults. |
3580
+
3581
+ Tested examples: `stories/patterns/timeline.stories.tsx`
3582
+
3583
+ #### Toolbar
3584
+
3585
+ A row of controls that is one stop in the Tab order: Tab enters it, the arrow keys move between the buttons, and Tab leaves it. For formatting, view and editing controls (a text editor's bold, italic, link), where Tab through twenty buttons would be a burden.
3586
+
3587
+ ```ts
3588
+ import { Toolbar } from "@primecoderin/fast-ui-react";
3589
+ ```
3590
+
3591
+ | Prop | Type | Default | Description |
3592
+ | --- | --- | --- | --- |
3593
+ | `children` * | `ReactNode` | | The content. |
3594
+ | `aria-label` * | `string` | | Accessible name of the toolbar, e.g. "Text formatting". |
3595
+ | `orientation` | `"vertical" \| "horizontal"` | `"horizontal"` | A row (default) or a column. |
3596
+ | `className` | `string` | | Extra classes on the root element, merged last so they win over the defaults. |
3597
+
3598
+ Tested examples: `stories/patterns/toolbar.stories.tsx`
3599
+
3600
+ #### ToolbarButton
3601
+
3602
+ A button in a Toolbar.
3603
+
3604
+ ```ts
3605
+ import { ToolbarButton } from "@primecoderin/fast-ui-react";
3606
+ ```
3607
+
3608
+ | Prop | Type | Default | Description |
3609
+ | --- | --- | --- | --- |
3610
+ | `children` | `ReactNode` | | The label. Leave it out for a glyph alone, and give `aria-label`. |
3611
+ | `icon` | `ReactNode` | | A glyph before the label. |
3612
+ | `onClick` | `(() => void)` | | |
3613
+ | `pressed` | `boolean` | | For a button that stays on (bold): whether it is on. It sets `aria-pressed`. Leave it out for an action. |
3614
+ | `disabled` | `boolean` | | Not interactive, and shown as disabled. |
3615
+ | `aria-label` | `string` | | The accessible name, for a button with no text of its own. |
3616
+
3617
+
3618
+ #### ToolbarSeparator
3619
+
3620
+ A thin rule between groups of buttons in a Toolbar.
3621
+
3622
+ ```ts
3623
+ import { ToolbarSeparator } from "@primecoderin/fast-ui-react";
3624
+ ```
3625
+
3626
+ This component takes no props.
3627
+
3628
+
3629
+ #### Tour
3630
+
3631
+ A guided walk through the page: one step at a time points at a part of it with a ring and a card, and the card's buttons go back and on. The page is dimmed around the ring but not blocked, and Escape ends the tour. The focus starts on the card's Next button; on each later step it moves to the step's title, so a screen reader reads the new step. The app decides when to show it (a first visit) and remembers that it has. A step whose target is not on the page is not shown, so a tour should only open once its targets are there.
3632
+
3633
+ ```ts
3634
+ import { Tour } from "@primecoderin/fast-ui-react";
3635
+ ```
3636
+
3637
+ | Prop | Type | Default | Description |
3638
+ | --- | --- | --- | --- |
3639
+ | `steps` * | `readonly TourStep[]` | | |
3640
+ | `open` * | `boolean` | | Whether it is open. Controlled: the caller keeps this state. |
3641
+ | `onOpenChange` * | `(open: boolean) => void` | | Called with `false` when the tour ends: the close button, the last step's button, or Escape. |
3642
+ | `step` * | `number` | | The index of the step on show. |
3643
+ | `onStepChange` * | `(step: number) => void` | | Called with the index of the step the buttons go to. |
3644
+ | `labels` * | `TourLabels` | | Every text it shows or announces, in the user's language (the library has no built-in text). |
3645
+
3646
+ Tested examples: `stories/patterns/tour.stories.tsx`
3647
+
3648
+ #### TransferList
3649
+
3650
+ Two lists with the items between them moved by buttons: pick from what is available into what is chosen. Tick items in either list and press the arrow; the double arrows move every item that can move. For a few options, a MultiSelect is quicker; this is for long lists where seeing both sides matters.
3651
+
3652
+ ```ts
3653
+ import { TransferList } from "@primecoderin/fast-ui-react";
3654
+ ```
3655
+
3656
+ | Prop | Type | Default | Description |
3657
+ | --- | --- | --- | --- |
3658
+ | `items` * | `readonly TransferListItem[]` | | Every item, in either list. Each item is in the second list when its `id` is in `value`, else in the first. |
3659
+ | `value` * | `readonly string[]` | | The `id`s of the items in the second list, in the order they were added. |
3660
+ | `onValueChange` * | `(value: string[]) => void` | | Called with the `id`s of the items in the second list. |
3661
+ | `labels` * | `TransferListLabels` | | The headings, the buttons' names and the count. |
3662
+ | `aria-label` | `string` | | Accessible name of the whole control, e.g. "Permissions". |
3663
+ | `aria-labelledby` | `string` | | The id of the element that names the control, such as a field's label. |
3664
+ | `aria-describedby` | `string` | | The ids of the field's message and hint, read after the name. |
3665
+ | `disabled` | `boolean` | `false` | Turns off every box and button. |
3666
+ | `listHeight` | `number` | `240` | The height of each list in pixels; a longer list scrolls. Default 240. |
3667
+ | `className` | `string` | | Extra classes for the control. Merged last. |
3668
+
3669
+ Tested examples: `stories/patterns/transfer-list.stories.tsx`
3670
+
3671
+ #### TreeSelect
3672
+
3673
+ A searchable single-select for two-level lists such as an organization and its departments. Children are listed indented beneath their parent, and each child's option is described by its parent's name, so a screen reader that reads the options one by one says which parent a child is under. Typing keeps a parent that matches itself or through any child, and shows all of a matching parent's children, or only the matching children otherwise.
3674
+
3675
+ ```ts
3676
+ import { TreeSelect } from "@primecoderin/fast-ui-react";
3677
+ ```
3678
+
3679
+ | Prop | Type | Default | Description |
3680
+ | --- | --- | --- | --- |
3681
+ | `options` * | `readonly TreeSelectOption[]` | | |
3682
+ | `value` * | `string \| null` | | The current value. Controlled: the caller keeps this state. |
3683
+ | `onValueChange` * | `(id: string) => void` | | Called with the new value when the user picks one; set `value` from it. |
3684
+ | `noMatchesLabel` * | `string` | | Shown when the typed text matches nothing. |
3685
+ | `onBlur` | `(() => void)` | | |
3686
+ | `placeholder` | `string` | | |
3687
+ | `disabled` | `boolean` | `false` | Not interactive, and shown as disabled. |
3688
+ | `invalid` | `boolean` | `false` | Draws the box red and marks the input invalid for assistive technology. |
3689
+ | `required` | `boolean` | `false` | Marks the input required for assistive technology; the label shows the asterisk. |
3690
+ | `resultsLabel` | `((count: number) => string)` | | The number of options listed for the typed text, parents kept for a matching child included, as a screen reader announces it (politely, as it changes): `(count) => `${count} results``. Nothing is announced if omitted. |
3691
+ | `size` | `FieldSize` | `"medium"` | "small" is the compact density. |
3692
+ | `contentBefore` | `ReactNode` | | A decorative icon at the start of the box. |
3693
+ | `id` | `string` | | For a `<label htmlFor>` that names the input. |
3694
+ | `aria-label` | `string` | | The accessible name of the input and of its list of options, for a combobox with no label element of its own. Give this or `aria-labelledby`: a `<label htmlFor>` alone names the input but not the list. |
3695
+ | `aria-labelledby` | `string` | | The id of the element that names the input and its list of options, such as a field's label. |
3696
+
3697
+ Tested examples: `stories/patterns/tree-select.stories.tsx`
3698
+
3699
+ #### TreeView
3700
+
3701
+ A tree of items that open and close: folders and files, a hierarchy of categories. A tree is one stop in the Tab order; the arrow keys do the rest: Up and Down move through what is showing, the key toward the end edge opens a branch (and, on an open one, goes to its first child), the key toward the start edge closes it (and, on a closed one, goes to its parent), Home and End go to the first and last, Enter or Space chooses, and typing the start of a label goes to the next item that has it. A click chooses an item and opens or closes a branch; a disabled item can be reached but not chosen, opened or closed. For picking one value from a list, see TreeSelect.
3702
+
3703
+ ```ts
3704
+ import { TreeView } from "@primecoderin/fast-ui-react";
3705
+ ```
3706
+
3707
+ | Prop | Type | Default | Description |
3708
+ | --- | --- | --- | --- |
3709
+ | `items` * | `readonly TreeViewItem[]` | | The items at the top level, each with its own `children`. |
3710
+ | `aria-label` * | `string` | | Accessible name of the tree, e.g. "Files". |
3711
+ | `selected` | `string \| null` | `null` | The `id` of the chosen item, or null for none. |
3712
+ | `onSelectedChange` | `((id: string) => void)` | | Called with the `id` of the item the person chooses. |
3713
+ | `expanded` | `readonly string[]` | | The `id`s of the open branches. Leave it out to let the tree keep its own. |
3714
+ | `defaultExpanded` | `readonly string[]` | `[]` | The `id`s of the branches that start open, when the tree keeps its own. |
3715
+ | `onExpandedChange` | `((expanded: string[]) => void)` | | Called with the `id`s of the open branches. |
3716
+ | `className` | `string` | | Extra classes for the tree. Merged last. |
3717
+
3718
+ Tested examples: `stories/patterns/tree-view.stories.tsx`
3719
+
3720
+ ## Form fields bound to react-hook-form: `@primecoderin/fast-ui-react/forms`
3721
+
3722
+ ### Patterns
3723
+
3724
+ #### FormAutocompleteField
3725
+
3726
+ An Autocomplete in a field, bound to a react-hook-form string field holding the text.
3727
+
3728
+ ```ts
3729
+ import { FormAutocompleteField } from "@primecoderin/fast-ui-react/forms";
3730
+ ```
3731
+
3732
+ | Prop | Type | Default | Description |
3733
+ | --- | --- | --- | --- |
3734
+ | `control` * | `Control<TValues>` | | The react-hook-form `control` from `useForm()`. |
3735
+ | `name` * | `Path<TValues>` | | The field's name in the react-hook-form values. |
3736
+ | `label` * | `string` | | The visible label. |
3737
+ | `suggestions` * | `readonly string[]` | | The suggestions: the ones that contain the typed text are listed. |
3738
+ | `hint` | `string` | | |
3739
+ | `orientation` | `FieldOrientation` | | Label above the control (default) or in a column beside it. |
3740
+ | `rules` | `Omit<RegisterOptions<TValues, Path<TValues>>, "disabled" \| "valueAsNumber" \| "valueAsDate" \| "setValueAs">` | | react-hook-form validation rules, for forms that do not use a schema resolver. |
3741
+ | `formatError` | `((message: string) => string)` | | Turns a stored schema message (an i18n key) into display text. |
3742
+ | `size` | `FieldSize` | `"medium"` | "small" is the compact density. |
3743
+ | `disabled` | `boolean` | `false` | Not interactive, and shown as disabled. |
3744
+ | `placeholder` | `string` | | |
3745
+ | `required` | `boolean` | | Marks the input required for assistive technology; the label shows the asterisk. |
3746
+ | `noMatchesLabel` | `string` | | Shown when the typed text matches no suggestion. If omitted the list is hidden while nothing matches. |
3747
+ | `resultsLabel` | `((count: number) => string)` | | The number of suggestions the typed text matches, as a screen reader announces it (politely, as it changes): `(count) => `${count} suggestions``. Nothing is announced if omitted. |
3748
+ | `contentBefore` | `ReactNode` | | A decorative icon at the start of the box. |
3749
+
3750
+ Tested examples: `stories/patterns/form-fields/form-autocomplete-field.stories.tsx`
3751
+
3752
+ #### FormCascaderField
3753
+
3754
+ A Cascader in a field, bound to a react-hook-form field holding the path: an array of the `value` of each step.
3755
+
3756
+ ```ts
3757
+ import { FormCascaderField } from "@primecoderin/fast-ui-react/forms";
3758
+ ```
3759
+
3760
+ | Prop | Type | Default | Description |
3761
+ | --- | --- | --- | --- |
3762
+ | `control` * | `Control<TValues>` | | The react-hook-form `control` from `useForm()`. |
3763
+ | `name` * | `Path<TValues>` | | The field's name in the react-hook-form values. |
3764
+ | `label` * | `string` | | The visible label. |
3765
+ | `labels` * | `CascaderLabels` | | Every text it shows or announces, in the user's language (the library has no built-in text). |
3766
+ | `options` * | `readonly CascaderOption[]` | | |
3767
+ | `hint` | `string` | | |
3768
+ | `required` | `boolean` | | |
3769
+ | `orientation` | `FieldOrientation` | | Label above the control (default) or in a column beside it. |
3770
+ | `hideLabel` | `boolean` | `false` | Keep the label for assistive technology only. |
3771
+ | `rules` | `Omit<RegisterOptions<TValues, Path<TValues>>, "disabled" \| "valueAsNumber" \| "valueAsDate" \| "setValueAs">` | | react-hook-form validation rules, for forms that do not use a schema resolver. |
3772
+ | `formatError` | `((message: string) => string)` | | Turns a stored schema message (an i18n key) into display text. |
3773
+ | `size` | `FieldSize` | `"medium"` | |
3774
+ | `disabled` | `boolean` | `false` | Not interactive, and shown as disabled. |
3775
+ | `placeholder` | `string` | | Shown on the button while nothing is chosen. `labels.choose` if omitted. |
3776
+ | `separator` | `string` | | Written between the labels of the path on the button. Default " / ". |
3777
+
3778
+ Tested examples: `stories/patterns/form-fields/form-cascader-field.stories.tsx`
3779
+
3780
+ #### FormCheckboxField
3781
+
3782
+ A CheckboxField bound to a boolean react-hook-form field, with consistent error display.
3783
+
3784
+ ```ts
3785
+ import { FormCheckboxField } from "@primecoderin/fast-ui-react/forms";
3786
+ ```
3787
+
3788
+ | Prop | Type | Default | Description |
3789
+ | --- | --- | --- | --- |
3790
+ | `control` * | `Control<TValues>` | | The react-hook-form `control` from `useForm()`. |
3791
+ | `name` * | `Path<TValues>` | | The field's name in the react-hook-form values. |
3792
+ | `label` * | `string` | | The visible label. |
3793
+ | `rules` | `Omit<RegisterOptions<TValues, Path<TValues>>, "disabled" \| "valueAsNumber" \| "valueAsDate" \| "setValueAs">` | | react-hook-form validation rules, for forms that do not use a schema resolver (e.g. `{ required: "namespace:key" }`): the message is shown as the field's error, through `formatError`. |
3794
+ | `formatError` | `((message: string) => string)` | | Turns a stored schema message (an i18n key) into display text. |
3795
+ | `onCheckedChange` | `((checked: boolean) => void)` | | Called after the value changes. |
3796
+ | `size` | `"medium" \| "large"` | `"medium"` | "large" is a 20px box (the default is 17px). |
3797
+ | `disabled` | `boolean` | `false` | Not interactive, and shown as disabled. |
3798
+ | `hint` | `string` | | |
3799
+
3800
+ Tested examples: `stories/patterns/form-fields/form-checkbox-field.stories.tsx`
3801
+
3802
+ #### FormColorField
3803
+
3804
+ A ColorPicker in a field, bound to a react-hook-form string field holding the colour as "#rrggbb" (or "" for none).
3805
+
3806
+ ```ts
3807
+ import { FormColorField } from "@primecoderin/fast-ui-react/forms";
3808
+ ```
3809
+
3810
+ | Prop | Type | Default | Description |
3811
+ | --- | --- | --- | --- |
3812
+ | `control` * | `Control<TValues>` | | The react-hook-form `control` from `useForm()`. |
3813
+ | `name` * | `Path<TValues>` | | The field's name in the react-hook-form values. |
3814
+ | `label` * | `string` | | The visible label. |
3815
+ | `labels` * | `ColorPickerLabels` | | Every text it shows or announces, in the user's language (the library has no built-in text). |
3816
+ | `hint` | `string` | | |
3817
+ | `required` | `boolean` | | |
3818
+ | `orientation` | `FieldOrientation` | | Label above the control (default) or in a column beside it. |
3819
+ | `hideLabel` | `boolean` | `false` | Keep the label for assistive technology only. |
3820
+ | `rules` | `Omit<RegisterOptions<TValues, Path<TValues>>, "disabled" \| "valueAsNumber" \| "valueAsDate" \| "setValueAs">` | | react-hook-form validation rules, for forms that do not use a schema resolver. |
3821
+ | `formatError` | `((message: string) => string)` | | Turns a stored schema message (an i18n key) into display text. |
3822
+ | `size` | `FieldSize` | `"medium"` | |
3823
+ | `disabled` | `boolean` | `false` | Not interactive, and shown as disabled. |
3824
+ | `placeholder` | `string` | | Shown on the button while there is no colour. `labels.choose` if omitted. |
3825
+ | `swatches` | `readonly string[]` | | Colours offered as one-click choices under the picker, as hex. |
3826
+
3827
+ Tested examples: `stories/patterns/form-fields/form-color-field.stories.tsx`
3828
+
3829
+ #### FormComboboxField
3830
+
3831
+ A Combobox in a field, bound to a react-hook-form string field holding the chosen option's `value`.
3832
+
3833
+ ```ts
3834
+ import { FormComboboxField } from "@primecoderin/fast-ui-react/forms";
3835
+ ```
3836
+
3837
+ | Prop | Type | Default | Description |
3838
+ | --- | --- | --- | --- |
3839
+ | `control` * | `Control<TValues>` | | The react-hook-form `control` from `useForm()`. |
3840
+ | `name` * | `Path<TValues>` | | The field's name in the react-hook-form values. |
3841
+ | `label` * | `string` | | The visible label. |
3842
+ | `options` * | `readonly ComboboxOption[]` | | |
3843
+ | `noMatchesLabel` * | `string` | | Shown when the typed text matches no option. |
3844
+ | `hint` | `string` | | |
3845
+ | `orientation` | `FieldOrientation` | | Label above the control (default) or in a column beside it. |
3846
+ | `rules` | `Omit<RegisterOptions<TValues, Path<TValues>>, "disabled" \| "valueAsNumber" \| "valueAsDate" \| "setValueAs">` | | react-hook-form validation rules, for forms that do not use a schema resolver. |
3847
+ | `formatError` | `((message: string) => string)` | | Turns a stored schema message (an i18n key) into display text. |
3848
+ | `size` | `FieldSize` | `"medium"` | "small" is the compact density. |
3849
+ | `disabled` | `boolean` | `false` | Not interactive, and shown as disabled. |
3850
+ | `placeholder` | `string` | | |
3851
+ | `required` | `boolean` | | Marks the input required for assistive technology; the label shows the asterisk. |
3852
+ | `resultsLabel` | `((count: number) => string)` | | The number of options the typed text matches, as a screen reader announces it (politely, as it changes): `(count) => `${count} results``. Nothing is announced if omitted. |
3853
+ | `contentBefore` | `ReactNode` | | A decorative icon at the start of the box. |
3854
+
3855
+ Tested examples: `stories/patterns/form-fields/form-combobox-field.stories.tsx`
3856
+
3857
+ #### FormDateRangeField
3858
+
3859
+ A DateRangePicker in a field, bound to a react-hook-form field holding `{ start, end }`, "yyyy-MM-dd" each.
3860
+
3861
+ ```ts
3862
+ import { FormDateRangeField } from "@primecoderin/fast-ui-react/forms";
3863
+ ```
3864
+
3865
+ | Prop | Type | Default | Description |
3866
+ | --- | --- | --- | --- |
3867
+ | `control` * | `Control<TValues>` | | The react-hook-form `control` from `useForm()`. |
3868
+ | `name` * | `Path<TValues>` | | The field's name in the react-hook-form values. |
3869
+ | `label` * | `string` | | The visible label. |
3870
+ | `hint` | `string` | | |
3871
+ | `required` | `boolean` | | |
3872
+ | `orientation` | `FieldOrientation` | | Label above the control (default) or in a column beside it. |
3873
+ | `hideLabel` | `boolean` | `false` | Keep the label for assistive technology only. |
3874
+ | `rules` | `Omit<RegisterOptions<TValues, Path<TValues>>, "disabled" \| "valueAsNumber" \| "valueAsDate" \| "setValueAs">` | | react-hook-form validation rules, for forms that do not use a schema resolver. The value is an object that is never empty, so `required` does not apply: use `validate`, e.g. `(range) => range.end !== "" \|\| "Pick both days"`. |
3875
+ | `formatError` | `((message: string) => string)` | | Turns a stored schema message (an i18n key) into display text. |
3876
+ | `size` | `FieldSize` | `"medium"` | |
3877
+ | `disabled` | `boolean` | `false` | Not interactive, and shown as disabled. |
3878
+ | `icon` | `ReactNode` | | Replaces the calendar glyph at the end of the field. |
3879
+ | `labels` | `DateRangePickerLabels` | | The texts of the field and its calendar. English if omitted. |
3880
+ | `placeholder` | `string` | | Shown while there is no range. `labels.select` if omitted. |
3881
+ | `min` | `string` | | The earliest and latest day that can be picked, "yyyy-MM-dd". |
3882
+ | `max` | `string` | | |
3883
+ | `locale` | `Locale` | | date-fns' locale for the names of months and days and the first day of the week. English, with weeks from Sunday, if omitted. |
3884
+
3885
+ Tested examples: `stories/patterns/form-fields/form-date-range-field.stories.tsx`
3886
+
3887
+ #### FormDateTimeField
3888
+
3889
+ A date, a date and time or a time, picked from a panel and bound to react-hook-form: the field value is the text a native input holds ("2026-10-24", "2026-10-24T14:05", "14:05"), so it takes the place of `FormTextField type="date"` (or "time") with the schema and the request code unchanged. See DateTimePicker for what the panel offers.
3890
+
3891
+ ```ts
3892
+ import { FormDateTimeField } from "@primecoderin/fast-ui-react/forms";
3893
+ ```
3894
+
3895
+ | Prop | Type | Default | Description |
3896
+ | --- | --- | --- | --- |
3897
+ | `control` * | `Control<TValues>` | | The react-hook-form `control` from `useForm()`. |
3898
+ | `name` * | `Path<TValues>` | | The field's name in the react-hook-form values. |
3899
+ | `label` * | `string` | | The visible label. |
3900
+ | `hint` | `string` | | |
3901
+ | `required` | `boolean` | | |
3902
+ | `disabled` | `boolean` | `false` | Not interactive, and shown as disabled. |
3903
+ | `size` | `FieldSize` | `"medium"` | "small" is the compact density. |
3904
+ | `orientation` | `FieldOrientation` | | Label above the control (default) or in a column beside it. |
3905
+ | `hideLabel` | `boolean` | `false` | Keep the label for assistive technology only, e.g. a time in a table row. |
3906
+ | `clearable` | `boolean` | | Offer Clear. By default a field that is not `required` can be cleared and one that is cannot. |
3907
+ | `rules` | `Omit<RegisterOptions<TValues, Path<TValues>>, "disabled" \| "valueAsNumber" \| "valueAsDate" \| "setValueAs">` | | react-hook-form validation rules, for forms that do not use a schema resolver. |
3908
+ | `formatError` | `((message: string) => string)` | | Turns a stored schema message (such as a translation key) into display text. |
3909
+ | `id` | `string` | | |
3910
+ | `icon` | `ReactNode` | | Replaces the calendar (or, for a time, clock) glyph at the end of the field. |
3911
+ | `display` | `"full" \| "dayMonth"` | | "dayMonth" shows a date as "24 October", for a date whose year does not matter (a season's first day). |
3912
+ | `labels` | `DateTimePickerLabels` | | The texts of the field and its panel, in the user's language. English if omitted. |
3913
+ | `placeholder` | `string` | | Shown while there is no value. `labels.select` if omitted. |
3914
+ | `mode` | `PickerKind` | | A day (default), a day and a time, or a time of day. |
3915
+ | `showSeconds` | `boolean` | | Show and set the seconds as well: "14:05:09". For a date and time or a time. |
3916
+ | `min` | `string` | | The earliest and latest value, written as the value is ("2026-10-24"; a date and time may be a day alone, which is that day's first or last moment). Days outside are greyed out and cannot be picked, and a time outside becomes the nearer limit. |
3917
+ | `max` | `string` | | |
3918
+ | `defaultTime` | `string` | | The time a day gets when it is picked and the value has none: "00:00" for the start of a range, "23:59" for its end. The time now if omitted. Seconds are dropped unless `showSeconds`. |
3919
+ | `showNow` | `boolean` | | Offer Today (a date) or Now. Default true. |
3920
+ | `locale` | `Locale` | | date-fns' locale for the names of months and days and the first day of the week (Monday for `de`), such as `he` from "date-fns/locale/he". English, with weeks from Sunday, if omitted. Dates are always written day first and times in 24 hours, whatever the locale. |
3921
+
3922
+ Tested examples: `stories/patterns/form-date-time-field.stories.tsx`
3923
+
3924
+ #### FormFileUploadField
3925
+
3926
+ A FileUpload in a field, bound to a react-hook-form field holding an array of `File`s.
3927
+
3928
+ ```ts
3929
+ import { FormFileUploadField } from "@primecoderin/fast-ui-react/forms";
3930
+ ```
3931
+
3932
+ | Prop | Type | Default | Description |
3933
+ | --- | --- | --- | --- |
3934
+ | `control` * | `Control<TValues>` | | The react-hook-form `control` from `useForm()`. |
3935
+ | `name` * | `Path<TValues>` | | The field's name in the react-hook-form values. |
3936
+ | `label` * | `string` | | The visible label. |
3937
+ | `labels` * | `FileUploadLabels` | | Every text it shows or announces, in the user's language (the library has no built-in text). |
3938
+ | `hint` | `string` | | |
3939
+ | `required` | `boolean` | | |
3940
+ | `orientation` | `FieldOrientation` | | Label above the control (default) or in a column beside it. |
3941
+ | `rules` | `Omit<RegisterOptions<TValues, Path<TValues>>, "disabled" \| "valueAsNumber" \| "valueAsDate" \| "setValueAs">` | | react-hook-form validation rules, for forms that do not use a schema resolver. |
3942
+ | `formatError` | `((message: string) => string)` | | Turns a stored schema message (an i18n key) into display text. |
3943
+ | `disabled` | `boolean` | `false` | Not interactive, and shown as disabled. |
3944
+ | `description` | `string` | | A line in the drop area under the button: the limits, e.g. "PNG or JPG, up to 5 MB". |
3945
+ | `locale` | `string` | | The locale that writes the sizes, a BCP 47 tag. If omitted, the runtime's default locale (the browser's, or the server's when rendered there), not the page's `lang`. |
3946
+ | `accept` | `string` | | The kinds of file it takes, as the file input writes them: `"image/*,.pdf"`. Anything if omitted. |
3947
+ | `multiple` | `boolean` | | Let several files be chosen. Otherwise a new choice replaces the one before, and of several files dropped at once the first that passes is taken and the others are reported to `onReject` as `count`. |
3948
+ | `maxSize` | `number` | | The largest a file may be, in bytes. |
3949
+ | `maxFiles` | `number` | | The most files the list takes. |
3950
+ | `onReject` | `((rejections: FileUploadRejection[]) => void)` | | Called with the files that were not added and why, so the app can tell the person in its own words. The files that were fine are added regardless. |
3951
+ | `statuses` | `ReadonlyMap<File, FileUploadStatus>` | | Progress and errors of the files, by file: the app sets them as it sends them. |
3952
+
3953
+ Tested examples: `stories/patterns/form-fields/form-file-upload-field.stories.tsx`
3954
+
3955
+ #### FormMentionsField
3956
+
3957
+ A MentionsInput in a field, bound to a react-hook-form string field holding the text.
3958
+
3959
+ ```ts
3960
+ import { FormMentionsField } from "@primecoderin/fast-ui-react/forms";
3961
+ ```
3962
+
3963
+ | Prop | Type | Default | Description |
3964
+ | --- | --- | --- | --- |
3965
+ | `control` * | `Control<TValues>` | | The react-hook-form `control` from `useForm()`. |
3966
+ | `name` * | `Path<TValues>` | | The field's name in the react-hook-form values. |
3967
+ | `label` * | `string` | | The visible label. |
3968
+ | `suggestions` * | `readonly MentionSuggestion[]` | | The people that can be mentioned. |
3969
+ | `hint` | `string` | | |
3970
+ | `orientation` | `FieldOrientation` | | Label above the control (default) or in a column beside it. |
3971
+ | `rules` | `Omit<RegisterOptions<TValues, Path<TValues>>, "disabled" \| "valueAsNumber" \| "valueAsDate" \| "setValueAs">` | | react-hook-form validation rules, for forms that do not use a schema resolver. |
3972
+ | `formatError` | `((message: string) => string)` | | Turns a stored schema message (an i18n key) into display text. |
3973
+ | `size` | `FieldSize` | `"medium"` | The field size, as the other inputs have it. Default `medium`. |
3974
+ | `disabled` | `boolean` | `false` | Makes the text area read only and greyed. |
3975
+ | `trigger` | `string` | | The character that starts a mention. Default "@". |
3976
+ | `rows` | `number` | | The height of the text area in lines. Default 4. |
3977
+ | `placeholder` | `string` | | Shown in the empty text area, e.g. "Type @ to mention someone". |
3978
+ | `required` | `boolean` | | Marks the text area required for assistive technology; the label shows the asterisk. |
3979
+ | `onMention` | `((suggestion: MentionSuggestion) => void)` | | Called with the person when one is chosen from the list. |
3980
+ | `maxSuggestions` | `number` | | The most suggestions listed. Default 6. |
3981
+
3982
+ Tested examples: `stories/patterns/form-fields/form-mentions-field.stories.tsx`
3983
+
3984
+ #### FormMultiSelectField
3985
+
3986
+ A MultiSelect in a field, bound to a react-hook-form field holding an array of the chosen options' `value`s.
3987
+
3988
+ ```ts
3989
+ import { FormMultiSelectField } from "@primecoderin/fast-ui-react/forms";
3990
+ ```
3991
+
3992
+ | Prop | Type | Default | Description |
3993
+ | --- | --- | --- | --- |
3994
+ | `control` * | `Control<TValues>` | | The react-hook-form `control` from `useForm()`. |
3995
+ | `name` * | `Path<TValues>` | | The field's name in the react-hook-form values. |
3996
+ | `label` * | `string` | | The visible label. |
3997
+ | `labels` * | `MultiSelectLabels` | | Every text it shows or announces, in the user's language (the library has no built-in text). |
3998
+ | `options` * | `readonly ComboboxOption[]` | | |
3999
+ | `hint` | `string` | | |
4000
+ | `orientation` | `FieldOrientation` | | Label above the control (default) or in a column beside it. |
4001
+ | `rules` | `Omit<RegisterOptions<TValues, Path<TValues>>, "disabled" \| "valueAsNumber" \| "valueAsDate" \| "setValueAs">` | | react-hook-form validation rules, for forms that do not use a schema resolver. |
4002
+ | `formatError` | `((message: string) => string)` | | Turns a stored schema message (an i18n key) into display text. |
4003
+ | `size` | `FieldSize` | `"medium"` | "small" is the compact density. |
4004
+ | `disabled` | `boolean` | `false` | Not interactive, and shown as disabled. |
4005
+ | `placeholder` | `string` | | |
4006
+ | `required` | `boolean` | | Marks the input required for assistive technology; the label shows the asterisk. |
4007
+ | `contentBefore` | `ReactNode` | | A decorative icon at the start of the box. |
4008
+
4009
+ Tested examples: `stories/patterns/form-fields/form-multi-select-field.stories.tsx`
4010
+
4011
+ #### FormNumberField
4012
+
4013
+ A NumberField in a field, bound to a react-hook-form field holding a number, or null while the field is empty.
4014
+
4015
+ ```ts
4016
+ import { FormNumberField } from "@primecoderin/fast-ui-react/forms";
4017
+ ```
4018
+
4019
+ | Prop | Type | Default | Description |
4020
+ | --- | --- | --- | --- |
4021
+ | `control` * | `Control<TValues>` | | The react-hook-form `control` from `useForm()`. |
4022
+ | `name` * | `Path<TValues>` | | The field's name in the react-hook-form values. |
4023
+ | `label` * | `string` | | The visible label. |
4024
+ | `labels` * | `NumberFieldLabels` | | Every text it shows or announces, in the user's language (the library has no built-in text). |
4025
+ | `hint` | `string` | | |
4026
+ | `orientation` | `FieldOrientation` | | Label above the control (default) or in a column beside it. |
4027
+ | `rules` | `Omit<RegisterOptions<TValues, Path<TValues>>, "disabled" \| "valueAsNumber" \| "valueAsDate" \| "setValueAs">` | | react-hook-form validation rules, for forms that do not use a schema resolver. |
4028
+ | `formatError` | `((message: string) => string)` | | Turns a stored schema message (an i18n key) into display text. |
4029
+ | `size` | `FieldSize` | `"medium"` | "small" is the compact density. |
4030
+ | `className` | `string` | | Extra classes on the root element, merged last so they win over the defaults. |
4031
+ | `disabled` | `boolean` | `false` | Not interactive, and shown as disabled. |
4032
+ | `readOnly` | `boolean` | | |
4033
+ | `placeholder` | `string` | | |
4034
+ | `min` | `number` | | |
4035
+ | `max` | `number` | | |
4036
+ | `locale` | `LocalesArgument` | | The locale that writes and reads the number. The page's if omitted. |
4037
+ | `required` | `boolean` | | Marks the input required for assistive technology; the label shows the asterisk. |
4038
+ | `contentBefore` | `ReactNode` | | A decorative icon or unit at the start of the box. |
4039
+ | `step` | `number` | | What the buttons and the up and down arrow keys change. Default 1. |
4040
+ | `largeStep` | `number` | | What Shift with the arrow keys (or Page Up and Page Down) change. Default 10. |
4041
+ | `format` | `NumberFormatOptions` | | How the number is written: `{ style: "currency", currency: "USD" }`, `{ maximumFractionDigits: 1 }`. |
4042
+
4043
+ Tested examples: `stories/patterns/form-fields/form-number-field.stories.tsx`
4044
+
4045
+ #### FormPhoneField
4046
+
4047
+ A PhoneField bound to a react-hook-form string field holding the number in E.164: the calling code and the digits with nothing between, e.g. "+12025550123" (`joinPhone` and `splitPhone` convert it). A searchable calling-code picker and a digits-only number share one box. The box is always left to right: numbers read that way in a right-to-left language too.
4048
+
4049
+ ```ts
4050
+ import { FormPhoneField } from "@primecoderin/fast-ui-react/forms";
4051
+ ```
4052
+
4053
+ | Prop | Type | Default | Description |
4054
+ | --- | --- | --- | --- |
4055
+ | `control` * | `Control<TValues>` | | The react-hook-form `control` from `useForm()`. |
4056
+ | `name` * | `Path<TValues>` | | The field's name in the react-hook-form values. |
4057
+ | `label` * | `string` | | The visible label. |
4058
+ | `labels` * | `PhoneFieldLabels` | | Every text it shows or announces, in the user's language (the library has no built-in text). |
4059
+ | `countries` * | `readonly PhoneCountry[]` | | |
4060
+ | `defaultDialCode` * | `string` | | The calling code shown while no number has been entered. |
4061
+ | `rules` | `Omit<RegisterOptions<TValues, Path<TValues>>, "disabled" \| "valueAsNumber" \| "valueAsDate" \| "setValueAs">` | | react-hook-form validation rules, for forms that do not use a schema resolver (e.g. `{ required: "namespace:key" }`): the message is shown as the field's error, through `formatError`. |
4062
+ | `formatError` | `((message: string) => string)` | | Turns a stored schema message (an i18n key) into display text. |
4063
+ | `size` | `FieldSize` | `"medium"` | |
4064
+ | `disabled` | `boolean` | `false` | Not interactive, and shown as disabled. |
4065
+ | `placeholder` | `string` | | |
4066
+ | `required` | `boolean` | | |
4067
+ | `hint` | `string` | | |
4068
+ | `orientation` | `FieldOrientation` | | |
4069
+ | `maxDigits` | `number` | `13` | The most digits the number takes. |
4070
+
4071
+ Tested examples: `stories/patterns/form-fields/form-phone-field.stories.tsx`
4072
+
4073
+ #### FormRadioGroupField
4074
+
4075
+ A RadioGroupField bound to react-hook-form. The field value is the chosen option's `value` string.
4076
+
4077
+ ```ts
4078
+ import { FormRadioGroupField } from "@primecoderin/fast-ui-react/forms";
4079
+ ```
4080
+
4081
+ | Prop | Type | Default | Description |
4082
+ | --- | --- | --- | --- |
4083
+ | `control` * | `Control<TValues>` | | The react-hook-form `control` from `useForm()`. |
4084
+ | `name` * | `Path<TValues>` | | The field's name in the react-hook-form values. |
4085
+ | `label` * | `string` | | The visible label. |
4086
+ | `options` * | `readonly RadioOption[]` | | |
4087
+ | `rules` | `Omit<RegisterOptions<TValues, Path<TValues>>, "disabled" \| "valueAsNumber" \| "valueAsDate" \| "setValueAs">` | | react-hook-form validation rules, for forms that do not use a schema resolver (e.g. `{ required: "namespace:key" }`): the message is shown as the field's error, through `formatError`. |
4088
+ | `formatError` | `((message: string) => string)` | | Turns a stored schema message (an i18n key) into display text. |
4089
+ | `disabled` | `boolean` | `false` | Not interactive, and shown as disabled. |
4090
+ | `required` | `boolean` | `false` | |
4091
+ | `hint` | `string` | | |
4092
+ | `orientation` | `FieldOrientation` | `"vertical"` | Label above the group (default) or in a column beside it. |
4093
+ | `layout` | `"vertical" \| "horizontal"` | `"vertical"` | Lay the options out in a column (default) or a row. |
4094
+
4095
+ Tested examples: `stories/patterns/form-fields/form-radio-group-field.stories.tsx`
4096
+
4097
+ #### FormRatingField
4098
+
4099
+ A Rating in a field, bound to a react-hook-form field holding a number from 0 (none) to the number of stars.
4100
+
4101
+ ```ts
4102
+ import { FormRatingField } from "@primecoderin/fast-ui-react/forms";
4103
+ ```
4104
+
4105
+ | Prop | Type | Default | Description |
4106
+ | --- | --- | --- | --- |
4107
+ | `control` * | `Control<TValues>` | | The react-hook-form `control` from `useForm()`. |
4108
+ | `name` * | `Path<TValues>` | | The field's name in the react-hook-form values. |
4109
+ | `label` * | `string` | | The visible label. |
4110
+ | `getValueLabel` * | `(value: number, max: number) => string` | | What a rating of `value` out of `max` is called, e.g. `(n, max) => "3 of 5 stars"`. It names each star and the shown rating. |
4111
+ | `hint` | `string` | | |
4112
+ | `required` | `boolean` | | The label shows the asterisk and the group is announced as required. Validation is the form's (`rules`). |
4113
+ | `orientation` | `FieldOrientation` | | Label above the control (default) or in a column beside it. |
4114
+ | `rules` | `Omit<RegisterOptions<TValues, Path<TValues>>, "disabled" \| "valueAsNumber" \| "valueAsDate" \| "setValueAs">` | | react-hook-form validation rules, for forms that do not use a schema resolver. |
4115
+ | `formatError` | `((message: string) => string)` | | Turns a stored schema message (an i18n key) into display text. |
4116
+ | `size` | `"small" \| "medium" \| "large"` | | The stars' size: small 16px, medium 20px (the default), large 26px. Small and medium stars that can be chosen each sit in a 24px box, the least size of a target, so they stand further apart than read-only ones. |
4117
+ | `disabled` | `boolean` | `false` | Dims the stars, which cannot be chosen or focused. |
4118
+ | `max` | `number` | | How many stars. Default 5. |
4119
+ | `clearable` | `boolean` | | Pressing the chosen star again sets the rating back to 0. |
4120
+
4121
+ Tested examples: `stories/patterns/form-fields/form-rating-field.stories.tsx`
4122
+
4123
+ #### FormSelectField
4124
+
4125
+ A SelectField bound to react-hook-form. The field value is the selected option's `value` string.
4126
+
4127
+ ```ts
4128
+ import { FormSelectField } from "@primecoderin/fast-ui-react/forms";
4129
+ ```
4130
+
4131
+ | Prop | Type | Default | Description |
4132
+ | --- | --- | --- | --- |
4133
+ | `control` * | `Control<TValues>` | | The react-hook-form `control` from `useForm()`. |
4134
+ | `name` * | `Path<TValues>` | | The field's name in the react-hook-form values. |
4135
+ | `label` * | `string` | | The visible label. |
4136
+ | `options` * | `readonly SelectOption[]` | | |
4137
+ | `rules` | `Omit<RegisterOptions<TValues, Path<TValues>>, "disabled" \| "valueAsNumber" \| "valueAsDate" \| "setValueAs">` | | react-hook-form validation rules, for forms that do not use a schema resolver (e.g. `{ required: "namespace:key" }`): the message is shown as the field's error, through `formatError`. |
4138
+ | `formatError` | `((message: string) => string)` | | Turns a stored schema message (an i18n key) into display text. |
4139
+ | `size` | `FieldSize` | `"medium"` | "small" is the compact density. |
4140
+ | `disabled` | `boolean` | `false` | Not interactive, and shown as disabled. |
4141
+ | `placeholder` | `string` | | |
4142
+ | `required` | `boolean` | | |
4143
+ | `contentBefore` | `ReactNode` | | A decorative icon at the start of the box. |
4144
+ | `hint` | `string` | | |
4145
+ | `orientation` | `FieldOrientation` | | Label above the control (default) or in a column beside it. |
4146
+ | `hideLabel` | `boolean` | `false` | Keep the label for assistive technology only, e.g. a select in a table row. |
4147
+
4148
+ Tested examples: `stories/patterns/form-fields/form-select-field.stories.tsx`
4149
+
4150
+ #### FormSliderField
4151
+
4152
+ A Slider in a field, bound to a react-hook-form field holding a number, or an array of numbers for a range (a thumb for each; name them with `thumbLabels`). A field with no value starts at `min`.
4153
+
4154
+ ```ts
4155
+ import { FormSliderField } from "@primecoderin/fast-ui-react/forms";
4156
+ ```
4157
+
4158
+ | Prop | Type | Default | Description |
4159
+ | --- | --- | --- | --- |
4160
+ | `control` * | `Control<TValues>` | | The react-hook-form `control` from `useForm()`. |
4161
+ | `name` * | `Path<TValues>` | | The field's name in the react-hook-form values. |
4162
+ | `label` * | `string` | | The visible label. |
4163
+ | `hint` | `string` | | |
4164
+ | `orientation` | `FieldOrientation` | | Label above the control (default) or in a column beside it. |
4165
+ | `hideLabel` | `boolean` | `false` | Keep the label for assistive technology only. |
4166
+ | `rules` | `Omit<RegisterOptions<TValues, Path<TValues>>, "disabled" \| "valueAsNumber" \| "valueAsDate" \| "setValueAs">` | | react-hook-form validation rules, for forms that do not use a schema resolver. |
4167
+ | `formatError` | `((message: string) => string)` | | Turns a stored schema message (an i18n key) into display text. |
4168
+ | `disabled` | `boolean` | `false` | Greys the slider out; its thumbs cannot be moved or focused. |
4169
+ | `min` | `number` | `0` | The least value, at the start of the track (Home goes there). Default 0. |
4170
+ | `max` | `number` | | The greatest value, at the end of the track (End goes there). Default 100. |
4171
+ | `step` | `number` | | What one arrow key press changes. Default 1. |
4172
+ | `largeStep` | `number` | | What Page Up and Page Down (or Shift and an arrow) change. Default 10. |
4173
+ | `minStepsBetweenValues` | `number` | | The least distance between two thumbs of a range, in steps. |
4174
+ | `getValueText` | `((formattedValue: string, value: number, index: number) => string)` | | Writes a value as text for a screen reader, e.g. `(text) => `${text} km``. The number as formatted if omitted. |
4175
+ | `thumbLabels` | `readonly string[]` | | Names the thumbs of a range in order, e.g. ["Minimum price", "Maximum price"]. |
4176
+
4177
+ Tested examples: `stories/patterns/form-fields/form-slider-field.stories.tsx`
4178
+
4179
+ #### FormSwitchField
4180
+
4181
+ A SwitchField bound to a boolean react-hook-form field. With its label it is a settings row: the label at the start, the switch at the far end.
4182
+
4183
+ ```ts
4184
+ import { FormSwitchField } from "@primecoderin/fast-ui-react/forms";
4185
+ ```
4186
+
4187
+ | Prop | Type | Default | Description |
4188
+ | --- | --- | --- | --- |
4189
+ | `control` * | `Control<TValues>` | | The react-hook-form `control` from `useForm()`. |
4190
+ | `name` * | `Path<TValues>` | | The field's name in the react-hook-form values. |
4191
+ | `label` * | `string` | | The visible label. |
4192
+ | `rules` | `Omit<RegisterOptions<TValues, Path<TValues>>, "disabled" \| "valueAsNumber" \| "valueAsDate" \| "setValueAs">` | | react-hook-form validation rules, for forms that do not use a schema resolver (e.g. `{ validate: ... }`). A switch shows no message: a rule that fails marks the switch invalid for assistive technology only, so say why near it. |
4193
+ | `onCheckedChange` | `((checked: boolean) => void)` | | Called after the value changes, e.g. to clear the fields the switch controls. |
4194
+ | `disabled` | `boolean` | `false` | Not interactive, and shown as disabled. |
4195
+ | `hideLabel` | `boolean` | `false` | Show the switch alone, with the label kept for assistive technology. For a layout that draws the label itself, e.g. in a label column. |
4196
+
4197
+ Tested examples: `stories/patterns/form-fields/form-switch-field.stories.tsx`
4198
+
4199
+ #### FormTagsInputField
4200
+
4201
+ A TagsInput in a field, bound to a react-hook-form field holding an array of strings.
4202
+
4203
+ ```ts
4204
+ import { FormTagsInputField } from "@primecoderin/fast-ui-react/forms";
4205
+ ```
4206
+
4207
+ | Prop | Type | Default | Description |
4208
+ | --- | --- | --- | --- |
4209
+ | `control` * | `Control<TValues>` | | The react-hook-form `control` from `useForm()`. |
4210
+ | `name` * | `Path<TValues>` | | The field's name in the react-hook-form values. |
4211
+ | `label` * | `string` | | The visible label. |
4212
+ | `labels` * | `TagsInputLabels` | | Every text it shows or announces, in the user's language (the library has no built-in text). |
4213
+ | `hint` | `string` | | |
4214
+ | `orientation` | `FieldOrientation` | | Label above the control (default) or in a column beside it. |
4215
+ | `rules` | `Omit<RegisterOptions<TValues, Path<TValues>>, "disabled" \| "valueAsNumber" \| "valueAsDate" \| "setValueAs">` | | react-hook-form validation rules, for forms that do not use a schema resolver. |
4216
+ | `formatError` | `((message: string) => string)` | | Turns a stored schema message (an i18n key) into display text. |
4217
+ | `size` | `FieldSize` | `"medium"` | "small" is the compact density. |
4218
+ | `disabled` | `boolean` | `false` | Not interactive, and shown as disabled. |
4219
+ | `placeholder` | `string` | | |
4220
+ | `required` | `boolean` | | Marks the input required for assistive technology; the label shows the asterisk. |
4221
+ | `separators` | `readonly string[]` | | The characters that end a tag as they are typed or pasted, besides Enter. Default `[","]`. Pasted text is split at them, so pasting "a, b, c" adds three tags. |
4222
+ | `allowDuplicates` | `boolean` | | Let the same tag be added twice. By default a tag already in the list is not added again. |
4223
+ | `maxTags` | `number` | | The most tags the list takes; the input stops adding past it. |
4224
+ | `isValidTag` | `((tag: string) => boolean)` | | Returns false for a tag that must not be added (an email address that is not one); the text stays in the input. |
4225
+
4226
+ Tested examples: `stories/patterns/form-fields/form-tags-input-field.stories.tsx`
4227
+
4228
+ #### FormTextAreaField
4229
+
4230
+ A TextAreaField bound to react-hook-form, with consistent error display.
4231
+
4232
+ ```ts
4233
+ import { FormTextAreaField } from "@primecoderin/fast-ui-react/forms";
4234
+ ```
4235
+
4236
+ | Prop | Type | Default | Description |
4237
+ | --- | --- | --- | --- |
4238
+ | `control` * | `Control<TValues>` | | The react-hook-form `control` from `useForm()`. |
4239
+ | `name` * | `Path<TValues>` | | The field's name in the react-hook-form values. |
4240
+ | `label` * | `string` | | The visible label. |
4241
+ | `rules` | `Omit<RegisterOptions<TValues, Path<TValues>>, "disabled" \| "valueAsNumber" \| "valueAsDate" \| "setValueAs">` | | react-hook-form validation rules, for forms that do not use a schema resolver. |
4242
+ | `formatError` | `((message: string) => string)` | | Turns a stored schema message (an i18n key) into display text. |
4243
+ | `size` | `FieldSize` | `"medium"` | "small" is the compact density. |
4244
+ | `disabled` | `boolean` | `false` | Not interactive, and shown as disabled. |
4245
+ | `rows` | `number` | | |
4246
+ | `placeholder` | `string` | | |
4247
+ | `required` | `boolean` | | |
4248
+ | `autoComplete` | `string` | | |
4249
+ | `maxLength` | `number` | | |
4250
+ | `hint` | `string` | | |
4251
+ | `orientation` | `FieldOrientation` | | Label above the control (default) or in a column beside it. |
4252
+ | `resize` | `"none" \| "vertical" \| "horizontal" \| "both"` | `"vertical"` | Which way the user can drag the corner to resize. Defaults to vertical. |
4253
+
4254
+ Tested examples: `stories/patterns/form-fields/form-text-area-field.stories.tsx`
4255
+
4256
+ #### FormTextField
4257
+
4258
+ A TextField bound to react-hook-form, with consistent error display.
4259
+
4260
+ ```ts
4261
+ import { FormTextField } from "@primecoderin/fast-ui-react/forms";
4262
+ ```
4263
+
4264
+ | Prop | Type | Default | Description |
4265
+ | --- | --- | --- | --- |
4266
+ | `control` * | `Control<TValues>` | | The react-hook-form `control` from `useForm()`. |
4267
+ | `name` * | `Path<TValues>` | | The field's name in the react-hook-form values. |
4268
+ | `label` * | `string` | | The visible label. |
4269
+ | `successMessage` | `string` | | Shown in green, with a check, once the field has been left with a value that passes validation. For confirmations such as "Name is available". |
4270
+ | `rules` | `Omit<RegisterOptions<TValues, Path<TValues>>, "disabled" \| "valueAsNumber" \| "valueAsDate" \| "setValueAs">` | | react-hook-form validation rules, for forms that do not use a schema resolver (e.g. `{ required: "namespace:key" }`). |
4271
+ | `formatError` | `((message: string) => string)` | | Validation messages are i18n keys. This turns the stored message into display text; without it the message is shown as is. |
4272
+ | `size` | `FieldSize` | `"medium"` | "small" is the compact density; "large" is for sign-in style screens. |
4273
+ | `required` | `boolean` | | |
4274
+ | `contentBefore` | `ReactNode` | | Content inside the box, before and after the text. Decorative icons, units. |
4275
+ | `hint` | `string` | | |
4276
+ | `acceptInput` | `((value: string) => boolean)` | | Keystroke filter: a change is ignored when this returns false for the new value, so the field never holds invalid text (e.g. numeric masks). |
4277
+ | `passwordToggleLabels` | `PasswordToggleLabels` | | Adds a show/hide button when type is "password". Texts come from the caller. |
4278
+ | `contentAfter` | `ReactNode` | | |
4279
+ | `orientation` | `FieldOrientation` | | Label above the control (default) or in a column beside it. |
4280
+ | `hideLabel` | `boolean` | `false` | Keep the label out of the layout and give it to assistive technology only. For inputs whose meaning is clear from a placeholder or their neighbours. |
4281
+
4282
+ Tested examples: `stories/patterns/form-fields/form-text-field.stories.tsx`
4283
+
4284
+ #### FormTransferListField
4285
+
4286
+ A TransferList in a field, bound to a react-hook-form field holding an array of the `id`s of the chosen items.
4287
+
4288
+ ```ts
4289
+ import { FormTransferListField } from "@primecoderin/fast-ui-react/forms";
4290
+ ```
4291
+
4292
+ | Prop | Type | Default | Description |
4293
+ | --- | --- | --- | --- |
4294
+ | `control` * | `Control<TValues>` | | The react-hook-form `control` from `useForm()`. |
4295
+ | `name` * | `Path<TValues>` | | The field's name in the react-hook-form values. |
4296
+ | `label` * | `string` | | The visible label. |
4297
+ | `items` * | `readonly TransferListItem[]` | | Every item, in either list. Each item is in the second list when its `id` is in `value`, else in the first. |
4298
+ | `labels` * | `TransferListLabels` | | The headings, the buttons' names and the count. |
4299
+ | `hint` | `string` | | |
4300
+ | `required` | `boolean` | | |
4301
+ | `orientation` | `FieldOrientation` | | Label above the control (default) or in a column beside it. |
4302
+ | `rules` | `Omit<RegisterOptions<TValues, Path<TValues>>, "disabled" \| "valueAsNumber" \| "valueAsDate" \| "setValueAs">` | | react-hook-form validation rules, for forms that do not use a schema resolver. |
4303
+ | `formatError` | `((message: string) => string)` | | Turns a stored schema message (an i18n key) into display text. |
4304
+ | `disabled` | `boolean` | `false` | Turns off every box and button. |
4305
+ | `listHeight` | `number` | | The height of each list in pixels; a longer list scrolls. Default 240. |
4306
+
4307
+ Tested examples: `stories/patterns/form-fields/form-transfer-list-field.stories.tsx`
4308
+
4309
+ #### FormTreeSelectField
4310
+
4311
+ A TreeSelect in a field, bound to a react-hook-form field holding the chosen option's id (or null).
4312
+
4313
+ ```ts
4314
+ import { FormTreeSelectField } from "@primecoderin/fast-ui-react/forms";
4315
+ ```
4316
+
4317
+ | Prop | Type | Default | Description |
4318
+ | --- | --- | --- | --- |
4319
+ | `control` * | `Control<TValues>` | | The react-hook-form `control` from `useForm()`. |
4320
+ | `name` * | `Path<TValues>` | | The field's name in the react-hook-form values. |
4321
+ | `label` * | `string` | | The visible label. |
4322
+ | `options` * | `readonly TreeSelectOption[]` | | |
4323
+ | `noMatchesLabel` * | `string` | | |
4324
+ | `resultsLabel` | `((count: number) => string)` | | The number of options listed for the typed text, as a screen reader announces it. Nothing is announced if omitted. |
4325
+ | `placeholder` | `string` | | |
4326
+ | `required` | `boolean` | | |
4327
+ | `disabled` | `boolean` | `false` | Not interactive, and shown as disabled. |
4328
+ | `size` | `FieldSize` | `"medium"` | "small" is the compact density. |
4329
+ | `orientation` | `FieldOrientation` | | Label above the control (default) or in a column beside it. |
4330
+ | `contentBefore` | `ReactNode` | | A decorative icon at the start of the box. |
4331
+ | `rules` | `Omit<RegisterOptions<TValues, Path<TValues>>, "disabled" \| "valueAsNumber" \| "valueAsDate" \| "setValueAs">` | | react-hook-form validation rules, for forms that do not use a schema resolver. |
4332
+ | `formatError` | `((message: string) => string)` | | Turns a stored schema message (an i18n key) into display text. |
4333
+
4334
+ Tested examples: `stories/patterns/form-fields/form-tree-select-field.stories.tsx`
4335
+
4336
+ ## Charts: `@primecoderin/fast-ui-react/charts`
4337
+
4338
+ ### Patterns
4339
+
4340
+ #### AreaChart
4341
+
4342
+ Filled areas over a shared x axis: a volume over time, or with `stacked` how a total divides into parts. The colours are the chart tokens, and the top edge of each area after the first is dashed or dotted in its own way (the legend shows the same). The data is also given to a screen reader as a table.
4343
+
4344
+ ```ts
4345
+ import { AreaChart } from "@primecoderin/fast-ui-react/charts";
4346
+ ```
4347
+
4348
+ | Prop | Type | Default | Description |
4349
+ | --- | --- | --- | --- |
4350
+ | `data` * | `readonly Readonly<Record<string, string \| number \| null>>[]` | | The rows to draw, in x order. With none the chart draws its axes only, and its data table has no rows. |
4351
+ | `xKey` * | `string` | | The key of the x value in each datum: a month, a date, a category. |
4352
+ | `series` * | `readonly ChartSeries[]` | | The measures to draw, one line, area or bar group each. Five is the most the colours can tell apart. |
4353
+ | `aria-label` * | `string` | | What the chart shows, e.g. "Orders per month". It names the chart and its data table. |
4354
+ | `stacked` | `boolean` | `false` | Stack the series on top of each other, so the top edge is their total. Otherwise each is drawn from the axis. |
4355
+ | `curve` | `"step" \| "linear" \| "monotone"` | `"monotone"` | How the edge runs between points: straight, smoothed (`monotone`, default) or in steps. |
4356
+ | `xLabel` | `string` | | What the x values are called, for the data table a screen reader reads: "Month". The `xKey` if omitted. |
4357
+ | `height` | `number` | `240` | The height of the plot in pixels. Default 240. The width is the container's. |
4358
+ | `formatX` | `((value: string \| number) => string)` | | Writes an x value on the axis, in the tooltip and in the data table. |
4359
+ | `formatValue` | `((value: number) => string)` | | Writes a number on the value axis, in the tooltip and in the data table: `(n) => `${n} kr``. |
4360
+ | `hideLegend` | `boolean` | `false` | Leave out the legend under the chart (for one series, whose name the heading says). |
4361
+ | `hideGrid` | `boolean` | `false` | Leave out the grid lines. |
4362
+ | `className` | `string` | | Extra classes for the chart's box. Merged last. |
4363
+
4364
+ Tested examples: `stories/patterns/charts/area-chart.stories.tsx`
4365
+
4366
+ #### BarChart
4367
+
4368
+ Bars for each x value: a comparison between categories, or with `stacked` how each total divides into parts. The colours are the chart tokens and the data is also given to a screen reader as a table. Unlike the lines of a LineChart, the bars of several series differ only by colour and by their place in each group.
4369
+
4370
+ ```ts
4371
+ import { BarChart } from "@primecoderin/fast-ui-react/charts";
4372
+ ```
4373
+
4374
+ | Prop | Type | Default | Description |
4375
+ | --- | --- | --- | --- |
4376
+ | `data` * | `readonly Readonly<Record<string, string \| number \| null>>[]` | | The rows to draw, in x order. With none the chart draws its axes only, and its data table has no rows. |
4377
+ | `xKey` * | `string` | | The key of the x value in each datum: a month, a date, a category. |
4378
+ | `series` * | `readonly ChartSeries[]` | | The measures to draw, one line, area or bar group each. Five is the most the colours can tell apart. |
4379
+ | `aria-label` * | `string` | | What the chart shows, e.g. "Orders per month". It names the chart and its data table. |
4380
+ | `stacked` | `boolean` | `false` | Stack the series into one bar for each x value, so the bar's height is their total. Otherwise they stand side by side. |
4381
+ | `xLabel` | `string` | | What the x values are called, for the data table a screen reader reads: "Month". The `xKey` if omitted. |
4382
+ | `height` | `number` | `240` | The height of the plot in pixels. Default 240. The width is the container's. |
4383
+ | `formatX` | `((value: string \| number) => string)` | | Writes an x value on the axis, in the tooltip and in the data table. |
4384
+ | `formatValue` | `((value: number) => string)` | | Writes a number on the value axis, in the tooltip and in the data table: `(n) => `${n} kr``. |
4385
+ | `hideLegend` | `boolean` | `false` | Leave out the legend under the chart (for one series, whose name the heading says). |
4386
+ | `hideGrid` | `boolean` | `false` | Leave out the grid lines. |
4387
+ | `className` | `string` | | Extra classes for the chart's box. Merged last. |
4388
+
4389
+ Tested examples: `stories/patterns/charts/bar-chart.stories.tsx`
4390
+
4391
+ #### DonutChart
4392
+
4393
+ A ring divided into slices: how a whole splits into a few parts (five or fewer read well). The legend gives each slice's name and value, and the data is also given to a screen reader as a table. The colours are the chart tokens, so it follows the theme.
4394
+
4395
+ ```ts
4396
+ import { DonutChart } from "@primecoderin/fast-ui-react/charts";
4397
+ ```
4398
+
4399
+ | Prop | Type | Default | Description |
4400
+ | --- | --- | --- | --- |
4401
+ | `slices` * | `readonly DonutSlice[]` | | The slices, in the order they go round the ring. With none nothing is drawn, and the data table has no rows. |
4402
+ | `aria-label` * | `string` | | What the chart shows, e.g. "Orders by status". It names the chart and its data table. |
4403
+ | `nameLabel` * | `string` | | The heading of the data table's column of slice names, e.g. "Status". |
4404
+ | `valueLabel` * | `string` | | The heading of the data table's column of values, e.g. "Orders". |
4405
+ | `formatValue` | `((value: number) => string)` | | Writes a value in the legend, the tooltip and the data table. |
4406
+ | `centerLabel` | `ReactNode` | | In the hole: a total, a score. It is hidden from a screen reader, so the data table must say the same. |
4407
+ | `size` | `number` | `220` | The size of the ring in pixels. Default 220. |
4408
+ | `hideLegend` | `boolean` | `false` | Leave out the legend under the chart. |
4409
+ | `className` | `string` | | Extra classes for the chart's box. Merged last. |
4410
+
4411
+ Tested examples: `stories/patterns/charts/donut-chart.stories.tsx`
4412
+
4413
+ #### GaugeChart
4414
+
4415
+ A dial with a half circle for the arc: where one value stands between a minimum and a maximum (load, quota used, a score). It is a `role="meter"`, so a screen reader hears the name, the value and the range, and the arc is drawn by the eye only. The colour can follow bands, so a value turns from green to red as it climbs. The arc always fills from the left, like any dial, whatever the page's direction. It is a plain SVG.
4416
+
4417
+ ```ts
4418
+ import { GaugeChart } from "@primecoderin/fast-ui-react/charts";
4419
+ ```
4420
+
4421
+ | Prop | Type | Default | Description |
4422
+ | --- | --- | --- | --- |
4423
+ | `value` * | `number` | | The value to show. A value outside the range is drawn at the nearer end, and the meter's value (`aria-valuenow`) is held in the range too (a value that is not a number counts as the minimum), while its text (`aria-valuetext`) still says the value as it is. |
4424
+ | `aria-label` * | `string` | | What it measures, e.g. "CPU load". It names the gauge for a screen reader, which hears it as a meter with its value, minimum and maximum. |
4425
+ | `min` | `number` | `0` | The least the gauge can show. Default 0. |
4426
+ | `max` | `number` | `100` | The most the gauge can show. Default 100. |
4427
+ | `formatValue` | `((value: number) => string)` | | Writes a number: in the middle of the gauge, at its ends and in what a screen reader hears. `(n) => `${n}%``. |
4428
+ | `bands` | `readonly GaugeBand[]` | | Colours by value, from the lowest: `[{ upTo: 60, color: "var(--fast-tone-success-solid)" }, ...]`. The arc takes the colour of the band the value is in, so it turns amber and then red as the value climbs. |
4429
+ | `color` | `string` | | The arc's colour when there are no bands: a CSS colour or variable. The first chart token if omitted. |
4430
+ | `label` | `ReactNode` | | Under the value, in the middle: what it is, e.g. "CPU load". Hidden from a screen reader, which has `aria-label`. |
4431
+ | `showRange` | `boolean` | `false` | Show the minimum and the maximum under the ends of the arc. |
4432
+ | `size` | `number` | `200` | The width in pixels; the height is a little over half. Default 200. |
4433
+ | `className` | `string` | | Extra classes for the gauge. Merged last. |
4434
+
4435
+ Tested examples: `stories/patterns/charts/gauge-chart.stories.tsx`
4436
+
4437
+ #### LineChart
4438
+
4439
+ Lines over a shared x axis: a trend over time, a few measures side by side. The colours are the chart tokens, so it follows the theme and a tenant's branding, and each line after the first is dashed or dotted in its own way (the legend shows the same), so the lines differ by more than colour. The drawing is for the eyes; a screen reader gets the data as a table. It is an SVG, drawn by Recharts, and fills the width of its container.
4440
+
4441
+ ```ts
4442
+ import { LineChart } from "@primecoderin/fast-ui-react/charts";
4443
+ ```
4444
+
4445
+ | Prop | Type | Default | Description |
4446
+ | --- | --- | --- | --- |
4447
+ | `data` * | `readonly Readonly<Record<string, string \| number \| null>>[]` | | The rows to draw, in x order. With none the chart draws its axes only, and its data table has no rows. |
4448
+ | `xKey` * | `string` | | The key of the x value in each datum: a month, a date, a category. |
4449
+ | `series` * | `readonly ChartSeries[]` | | The measures to draw, one line, area or bar group each. Five is the most the colours can tell apart. |
4450
+ | `aria-label` * | `string` | | What the chart shows, e.g. "Orders per month". It names the chart and its data table. |
4451
+ | `curve` | `"step" \| "linear" \| "monotone"` | `"linear"` | How the line runs between points: straight (default), smoothed (`monotone`) or in steps. |
4452
+ | `showDots` | `boolean` | `false` | Mark each point with a dot. Default off; the dot under the pointer always shows. |
4453
+ | `xLabel` | `string` | | What the x values are called, for the data table a screen reader reads: "Month". The `xKey` if omitted. |
4454
+ | `height` | `number` | `240` | The height of the plot in pixels. Default 240. The width is the container's. |
4455
+ | `formatX` | `((value: string \| number) => string)` | | Writes an x value on the axis, in the tooltip and in the data table. |
4456
+ | `formatValue` | `((value: number) => string)` | | Writes a number on the value axis, in the tooltip and in the data table: `(n) => `${n} kr``. |
4457
+ | `hideLegend` | `boolean` | `false` | Leave out the legend under the chart (for one series, whose name the heading says). |
4458
+ | `hideGrid` | `boolean` | `false` | Leave out the grid lines. |
4459
+ | `className` | `string` | | Extra classes for the chart's box. Merged last. |
4460
+
4461
+ Tested examples: `stories/patterns/charts/line-chart.stories.tsx`
4462
+
4463
+ #### Sparkline
4464
+
4465
+ A tiny line chart with no axes or labels, to sit in a stat card or a table row and show a trend at a glance. It is a plain SVG, not Recharts, so it costs next to nothing to put in every row. It is an image to a screen reader, named by `aria-label`.
4466
+
4467
+ ```ts
4468
+ import { Sparkline } from "@primecoderin/fast-ui-react/charts";
4469
+ ```
4470
+
4471
+ | Prop | Type | Default | Description |
4472
+ | --- | --- | --- | --- |
4473
+ | `values` * | `readonly number[]` | | The numbers, in order, oldest first. Two or more draw a line; the line is scaled to fit the box. |
4474
+ | `aria-label` * | `string` | | What it says, in words, since the line itself has no numbers: "Sales, last 7 days: rising, 12 percent". A screen reader reads this as the sparkline's name. |
4475
+ | `color` | `string` | | A CSS colour or variable. The first chart token if omitted. |
4476
+ | `variant` | `"line" \| "area"` | `"line"` | A line (default), or a line with the area under it filled. |
4477
+ | `width` | `number` | `96` | Width in pixels. Default 96. |
4478
+ | `height` | `number` | `32` | Height in pixels. Default 32. |
4479
+ | `className` | `string` | | Extra classes on the root element, merged last so they win over the defaults. |
4480
+
4481
+ Tested examples: `stories/patterns/charts/sparkline.stories.tsx`
4482
+
4483
+ ## Rich text editor: `@primecoderin/fast-ui-react/editor`
4484
+
4485
+ ### Patterns
4486
+
4487
+ #### RichTextEditor
4488
+
4489
+ A text editor for formatted text: a toolbar of bold, italic, a heading, lists and a link over a writing area, with the usual shortcuts: Ctrl or Cmd with B, I and Z, Ctrl or Cmd with K to open the link field, and Shift+Enter for a line break. The value is HTML. The editor writes only those elements and drops the rest of what is pasted, but a request to the app's server can carry any HTML, so the app cleans the value before it shows one person's text to another. It is built on TipTap, so the app installs the TipTap packages to use it.
4490
+
4491
+ ```ts
4492
+ import { RichTextEditor } from "@primecoderin/fast-ui-react/editor";
4493
+ ```
4494
+
4495
+ | Prop | Type | Default | Description |
4496
+ | --- | --- | --- | --- |
4497
+ | `value` * | `string` | | The text as HTML. An empty string for none. The editor writes paragraphs, headings (levels 2 and 3), bulleted and numbered lists, bold, italic, links and line breaks (Shift+Enter). Anything else in a value it is given or in pasted HTML is dropped (its text is kept), and a link keeps only its address, with `rel="noopener noreferrer nofollow"`. |
4498
+ | `onValueChange` * | `(value: string) => void` | | Called with the HTML as it is edited, or "" while the document is empty. |
4499
+ | `labels` * | `RichTextEditorLabels` | | The texts of the toolbar and the link field. |
4500
+ | `disabled` | `boolean` | `false` | Makes the text read only: the toolbar is off and the writing area says it is disabled. |
4501
+ | `invalid` | `boolean` | `false` | Draws the box red and marks the editor invalid for assistive technology. |
4502
+ | `required` | `boolean` | `false` | Marks the editor required for assistive technology; the label shows the asterisk. |
4503
+ | `minHeight` | `number` | `160` | The height of the writing area at least, in pixels. Default 160. |
4504
+ | `aria-label` | `string` | | What names the editor when there is no visible label. |
4505
+ | `aria-labelledby` | `string` | | The id of the element that names the editor, such as a field's label. |
4506
+ | `aria-describedby` | `string` | | The ids of the field's message and hint, read after the name. |
4507
+ | `onBlur` | `(() => void)` | | The editor was left (focus moved out of the writing area). |
4508
+ | `editorRef` | `Ref<HTMLDivElement>` | | The editor's box, for a form library to find the first invalid field. |
4509
+ | `className` | `string` | | Extra classes for the editor's box. Merged last. |
4510
+
4511
+ Tested examples: `stories/patterns/rich-text-editor.stories.tsx`
4512
+
4513
+ ## Rich text form field: `@primecoderin/fast-ui-react/editor-forms`
4514
+
4515
+ ### Patterns
4516
+
4517
+ #### FormRichTextField
4518
+
4519
+ A RichTextEditor in a field, bound to a react-hook-form string field holding the text as HTML.
4520
+
4521
+ ```ts
4522
+ import { FormRichTextField } from "@primecoderin/fast-ui-react/editor-forms";
4523
+ ```
4524
+
4525
+ | Prop | Type | Default | Description |
4526
+ | --- | --- | --- | --- |
4527
+ | `control` * | `Control<TValues>` | | The react-hook-form `control` from `useForm()`. |
4528
+ | `name` * | `Path<TValues>` | | The field's name in the react-hook-form values. |
4529
+ | `label` * | `string` | | The visible label. |
4530
+ | `labels` * | `RichTextEditorLabels` | | The texts of the toolbar and the link field. |
4531
+ | `hint` | `string` | | |
4532
+ | `orientation` | `FieldOrientation` | | Label above the control (default) or in a column beside it. |
4533
+ | `rules` | `Omit<RegisterOptions<TValues, Path<TValues>>, "disabled" \| "valueAsNumber" \| "valueAsDate" \| "setValueAs">` | | react-hook-form validation rules, for forms that do not use a schema resolver. |
4534
+ | `formatError` | `((message: string) => string)` | | Turns a stored schema message (an i18n key) into display text. |
4535
+ | `disabled` | `boolean` | `false` | Makes the text read only: the toolbar is off and the writing area says it is disabled. |
4536
+ | `required` | `boolean` | | Marks the editor required for assistive technology; the label shows the asterisk. |
4537
+ | `minHeight` | `number` | | The height of the writing area at least, in pixels. Default 160. |
4538
+
4539
+ Tested examples: `stories/patterns/form-fields/form-rich-text-field.stories.tsx`
4540
+
4541
+ ## Hooks, functions and constants
4542
+
4543
+ | Export | Kind | Entry | What it is |
4544
+ | --- | --- | --- | --- |
4545
+ | `applyTenantBranding` | function | `main` | Applies a tenant's branding to the page, or restores the default teal when given `null`. |
4546
+ | `applyTheme` | function | `main` | Applies a theme to the page, or removes the one applied when given `null`. |
4547
+ | `applyThemeMode` | function | `main` | Applies a theme to the page. |
4548
+ | `applyThemePreference` | function | `main` | Applies a theme preference. |
4549
+ | `BRANDING_STYLE_ID` | constant | `main` | The id of the <style> element that holds a tenant's branding (`applyTenantBranding`, the provider's `branding`). |
4550
+ | `cn` | function | `main` | Joins class names and resolves Tailwind conflicts, the later one winning: `cn("px-4 py-2", isCompact && "px-2", className)`. |
4551
+ | `createTheme` | function | `main` | Makes a theme: the primary colour (`branding`) and any of the design tokens, for both themes or for one. |
4552
+ | `createTooltipGroup` | function | `main` | Many triggers, one tooltip: for a table of metrics where every figure explains itself on hover and a tooltip each would mean hundreds of them. |
4553
+ | `ENGLISH_RANGE_LABELS` | constant | `main` | The texts used when a picker is given none. |
4554
+ | `FAST_ICONS` | constant | `main` | The shared icons of the design foundation, grouped by common navigation, actions and status roles. |
4555
+ | `fieldControl` | function | `main` | The box around a text input, a text area or a select trigger. |
4556
+ | `fieldInput` | constant | `main` | The `<input>` inside a control box: no chrome of its own, it fills the box. |
4557
+ | `formatFileSize` | function | `main` | A file's size the way a person reads it: "12 byte", "3.4 kB", "1.2 MB" in the user's language (the unit names come from the browser's Intl, so nothing here needs translating). |
4558
+ | `getChartPalette` | function | `main` | |
4559
+ | `getInitials` | function | `main` | The initials of a name's first and last words, e.g. "Jane Ann Doe" → "JD". |
4560
+ | `heatmapGradient` | function | `main` | The heatmap's colours as a CSS gradient for its legend, low to high in the reading direction. |
4561
+ | `hexToHsv` | function | `main` | The hue, saturation and brightness of a hex colour; null if `hex` is not one. |
4562
+ | `hsvToHex` | function | `main` | The hex colour ("#rrggbb") of a hue, saturation and brightness; each is kept within its range. |
4563
+ | `joinPhone` | function | `main` | Joins a calling code ("+972") and the digits ("541234567") into E.164: "+972541234567". |
4564
+ | `matchesAccept` | function | `main` | Whether a file matches an `accept` list as the file input writes it: extensions (".png"), exact types ("image/png") and wildcards ("image/*"), separated by commas. |
4565
+ | `parseHex` | function | `main` | A hex colour written the way it is stored: "#rrggbb" in lower case, from "#6D28D9", "6d28d9", "#6d2" (each digit doubled) or "6d2". |
4566
+ | `QRCode` | function | `main` | A QR code for a link or a short text, drawn as SVG (crisp at any size and in print). |
4567
+ | `readInternationalPhone` | function | `main` | Reads text pasted into a phone number's digits. |
4568
+ | `restoreThemeAttribute` | function | `main` | Puts the page's `data-theme` back to `theme`, the value it had before (`null`: no attribute), at once and without a cross-fade. |
4569
+ | `splitPhone` | function | `main` | Splits an E.164 number into its calling code and digits. |
4570
+ | `THEME_STYLE_ID` | constant | `main` | The id of the <style> element that holds the theme (`createTheme`, the provider's `theme`). |
4571
+ | `toErrorText` | function | `main` | Validation messages are stored as i18n keys (the design system has no i18n), so the caller supplies `formatError` to turn one into display text. |
4572
+ | `TOKEN_NAMES` | constant | `main` | The design tokens: each is the CSS variable `--fast-<name>`. |
4573
+ | `useAppToast` | hook | `main` | Raises toasts through the app-wide toaster hosted by DesignSystemProvider. |