@slashsuite/ui-react 0.12.0 → 0.13.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 (388) hide show
  1. package/MIGRATING.md +386 -8
  2. package/README.md +101 -44
  3. package/agent-docs/components/app-shell.md +139 -0
  4. package/agent-docs/components/article-layout.md +140 -0
  5. package/agent-docs/components/audio.md +42 -0
  6. package/agent-docs/components/avatar-stack.md +64 -0
  7. package/agent-docs/components/avatar.md +76 -0
  8. package/agent-docs/components/badge.md +62 -0
  9. package/agent-docs/components/body-text.md +169 -0
  10. package/agent-docs/components/bottom-sheet.md +105 -0
  11. package/agent-docs/components/breadcrumbs.md +66 -0
  12. package/agent-docs/components/bullet-list.md +54 -0
  13. package/agent-docs/components/button.md +135 -0
  14. package/agent-docs/components/call-to-action.md +59 -0
  15. package/agent-docs/components/callout.md +87 -0
  16. package/agent-docs/components/card-grid.md +116 -0
  17. package/agent-docs/components/card.md +128 -0
  18. package/agent-docs/components/cart-button.md +63 -0
  19. package/agent-docs/components/centered-layout.md +90 -0
  20. package/agent-docs/components/chat-composer.md +49 -0
  21. package/agent-docs/components/chat-message.md +61 -0
  22. package/agent-docs/components/chat-thread.md +49 -0
  23. package/agent-docs/components/checkbox.md +81 -0
  24. package/agent-docs/components/cluster.md +108 -0
  25. package/agent-docs/components/code-example.md +48 -0
  26. package/agent-docs/components/code.md +72 -0
  27. package/agent-docs/components/colour-scheme-toggle.md +98 -0
  28. package/agent-docs/components/colour-swatch.md +41 -0
  29. package/agent-docs/components/combobox.md +88 -0
  30. package/agent-docs/components/confirm-dialog.md +98 -0
  31. package/agent-docs/components/container.md +51 -0
  32. package/agent-docs/components/copy-button.md +63 -0
  33. package/agent-docs/components/copy-line.md +55 -0
  34. package/agent-docs/components/date-field.md +106 -0
  35. package/agent-docs/components/date-range-picker.md +108 -0
  36. package/agent-docs/components/date-time-field.md +73 -0
  37. package/agent-docs/components/detail-layout.md +147 -0
  38. package/agent-docs/components/dialog.md +132 -0
  39. package/agent-docs/components/disclosure.md +70 -0
  40. package/agent-docs/components/divider.md +62 -0
  41. package/agent-docs/components/docs-layout.md +164 -0
  42. package/agent-docs/components/drawer.md +137 -0
  43. package/agent-docs/components/embed-frame.md +48 -0
  44. package/agent-docs/components/empty-state.md +70 -0
  45. package/agent-docs/components/field-dialog.md +98 -0
  46. package/agent-docs/components/field.md +71 -0
  47. package/agent-docs/components/fieldset.md +82 -0
  48. package/agent-docs/components/file-drop.md +52 -0
  49. package/agent-docs/components/flow-diagram.md +87 -0
  50. package/agent-docs/components/form-layout.md +144 -0
  51. package/agent-docs/components/form-row.md +93 -0
  52. package/agent-docs/components/full-bleed-layout.md +114 -0
  53. package/agent-docs/components/headings.md +107 -0
  54. package/agent-docs/components/hero.md +68 -0
  55. package/agent-docs/components/icon-button.md +90 -0
  56. package/agent-docs/components/icon.md +59 -0
  57. package/agent-docs/components/image.md +74 -0
  58. package/agent-docs/components/input.md +84 -0
  59. package/agent-docs/components/kbd.md +38 -0
  60. package/agent-docs/components/key-value-list.md +84 -0
  61. package/agent-docs/components/lightbox.md +97 -0
  62. package/agent-docs/components/list-layout.md +152 -0
  63. package/agent-docs/components/list-row.md +119 -0
  64. package/agent-docs/components/loading.md +69 -0
  65. package/agent-docs/components/markdown.md +51 -0
  66. package/agent-docs/components/media-tile.md +101 -0
  67. package/agent-docs/components/menu.md +110 -0
  68. package/agent-docs/components/meta-list.md +69 -0
  69. package/agent-docs/components/morph.md +134 -0
  70. package/agent-docs/components/navigation-progress.md +56 -0
  71. package/agent-docs/components/number-field.md +75 -0
  72. package/agent-docs/components/outline-region.md +74 -0
  73. package/agent-docs/components/page-fade.md +117 -0
  74. package/agent-docs/components/page-header.md +93 -0
  75. package/agent-docs/components/pagination.md +64 -0
  76. package/agent-docs/components/pill.md +105 -0
  77. package/agent-docs/components/popover.md +63 -0
  78. package/agent-docs/components/price.md +49 -0
  79. package/agent-docs/components/product-tile.md +78 -0
  80. package/agent-docs/components/progress-bar.md +66 -0
  81. package/agent-docs/components/promo-banner.md +46 -0
  82. package/agent-docs/components/prose-layout.md +87 -0
  83. package/agent-docs/components/prose.md +41 -0
  84. package/agent-docs/components/radio-group.md +77 -0
  85. package/agent-docs/components/scroll-strip.md +48 -0
  86. package/agent-docs/components/segmented-control.md +135 -0
  87. package/agent-docs/components/select.md +70 -0
  88. package/agent-docs/components/show.md +120 -0
  89. package/agent-docs/components/side-column.md +74 -0
  90. package/agent-docs/components/sidebar-layout.md +134 -0
  91. package/agent-docs/components/site-footer.md +63 -0
  92. package/agent-docs/components/site-search.md +79 -0
  93. package/agent-docs/components/slider.md +59 -0
  94. package/agent-docs/components/sortable-list.md +112 -0
  95. package/agent-docs/components/split-bar.md +54 -0
  96. package/agent-docs/components/stack.md +197 -0
  97. package/agent-docs/components/stacked-bar.md +91 -0
  98. package/agent-docs/components/stat-tile.md +69 -0
  99. package/agent-docs/components/state-machine.md +95 -0
  100. package/agent-docs/components/status-pages.md +112 -0
  101. package/agent-docs/components/stepper.md +54 -0
  102. package/agent-docs/components/steps.md +74 -0
  103. package/agent-docs/components/sticky-bar.md +51 -0
  104. package/agent-docs/components/switch.md +79 -0
  105. package/agent-docs/components/table-of-contents.md +78 -0
  106. package/agent-docs/components/table.md +384 -0
  107. package/agent-docs/components/tabs.md +178 -0
  108. package/agent-docs/components/text-link.md +110 -0
  109. package/agent-docs/components/textarea.md +53 -0
  110. package/agent-docs/components/timeline.md +79 -0
  111. package/agent-docs/components/toast.md +91 -0
  112. package/agent-docs/components/trend-chart.md +61 -0
  113. package/agent-docs/components/video.md +49 -0
  114. package/agent-docs/llms.txt +174 -0
  115. package/dist/AppShell.d.ts +25 -9
  116. package/dist/AppShell.js +67 -33
  117. package/dist/AppShellMenu.d.ts +31 -18
  118. package/dist/AppShellMenu.js +72 -45
  119. package/dist/ArticleLayout.d.ts +36 -0
  120. package/dist/ArticleLayout.js +27 -0
  121. package/dist/Audio.d.ts +16 -0
  122. package/dist/Audio.js +11 -0
  123. package/dist/Badge.d.ts +2 -1
  124. package/dist/Badge.js +3 -2
  125. package/dist/BottomSheet.d.ts +17 -6
  126. package/dist/BottomSheet.js +62 -11
  127. package/dist/Breadcrumbs.d.ts +8 -6
  128. package/dist/Breadcrumbs.js +17 -7
  129. package/dist/Button.d.ts +1 -0
  130. package/dist/Button.js +4 -3
  131. package/dist/CallToAction.d.ts +25 -0
  132. package/dist/CallToAction.js +17 -0
  133. package/dist/Callout.d.ts +2 -2
  134. package/dist/Callout.js +2 -2
  135. package/dist/Card.d.ts +88 -31
  136. package/dist/Card.js +55 -92
  137. package/dist/CardBody.d.ts +2 -0
  138. package/dist/CardBody.js +33 -3
  139. package/dist/CardGrid.d.ts +32 -4
  140. package/dist/CardGrid.js +42 -8
  141. package/dist/CardParts.d.ts +7 -1
  142. package/dist/CardParts.js +7 -2
  143. package/dist/CartButton.d.ts +33 -0
  144. package/dist/CartButton.js +18 -0
  145. package/dist/ChatComposer.d.ts +10 -4
  146. package/dist/ChatComposer.js +35 -13
  147. package/dist/Checkbox.d.ts +21 -3
  148. package/dist/Checkbox.js +66 -20
  149. package/dist/Chevron.js +1 -1
  150. package/dist/Cluster.d.ts +28 -15
  151. package/dist/Cluster.js +21 -4
  152. package/dist/Code.d.ts +15 -3
  153. package/dist/Code.js +23 -3
  154. package/dist/CodeBlock.d.ts +4 -4
  155. package/dist/CodeBlock.js +2 -2
  156. package/dist/CodeBody.d.ts +1 -1
  157. package/dist/CodeBody.js +4 -10
  158. package/dist/CodeExample.d.ts +1 -1
  159. package/dist/CodeExample.js +3 -2
  160. package/dist/ColourSchemeToggle.d.ts +21 -5
  161. package/dist/ColourSchemeToggle.js +15 -9
  162. package/dist/ColourSwatch.d.ts +15 -0
  163. package/dist/ColourSwatch.js +14 -0
  164. package/dist/Combobox.d.ts +42 -0
  165. package/dist/Combobox.js +43 -0
  166. package/dist/ConfirmDialog.d.ts +40 -0
  167. package/dist/ConfirmDialog.js +36 -0
  168. package/dist/Container.d.ts +3 -3
  169. package/dist/Container.js +1 -1
  170. package/dist/CopyButton.d.ts +8 -2
  171. package/dist/CopyButton.js +38 -28
  172. package/dist/CopyLine.d.ts +4 -2
  173. package/dist/CopyLine.js +4 -4
  174. package/dist/DateCalendar.d.ts +2 -0
  175. package/dist/DateCalendar.js +11 -9
  176. package/dist/DateField.d.ts +52 -21
  177. package/dist/DateField.js +73 -37
  178. package/dist/DateFieldCalendar.d.ts +12 -8
  179. package/dist/DateFieldCalendar.js +37 -18
  180. package/dist/DateRangePicker.d.ts +23 -3
  181. package/dist/DateRangePicker.js +10 -8
  182. package/dist/DateTimeField.d.ts +31 -0
  183. package/dist/DateTimeField.js +19 -0
  184. package/dist/Dialog.d.ts +42 -6
  185. package/dist/Dialog.js +50 -12
  186. package/dist/Disclosure.js +9 -1
  187. package/dist/DocsLayout.d.ts +13 -5
  188. package/dist/DocsLayout.js +11 -9
  189. package/dist/Drawer.d.ts +22 -7
  190. package/dist/Drawer.js +89 -8
  191. package/dist/EmbedFrame.d.ts +36 -0
  192. package/dist/EmbedFrame.js +18 -0
  193. package/dist/Field.d.ts +41 -4
  194. package/dist/Field.js +61 -25
  195. package/dist/FieldDialog.d.ts +8 -3
  196. package/dist/FieldDialog.js +19 -9
  197. package/dist/Fieldset.d.ts +3 -3
  198. package/dist/Fieldset.js +7 -9
  199. package/dist/FileDrop.js +2 -1
  200. package/dist/FlowDiagram.d.ts +92 -0
  201. package/dist/FlowDiagram.js +100 -0
  202. package/dist/FormRow.d.ts +6 -4
  203. package/dist/FormRow.js +11 -9
  204. package/dist/Hero.d.ts +30 -7
  205. package/dist/Hero.js +23 -9
  206. package/dist/Icon.d.ts +1 -1
  207. package/dist/Icon.js +1 -1
  208. package/dist/IconButton.js +1 -1
  209. package/dist/Image.d.ts +33 -9
  210. package/dist/Image.js +61 -16
  211. package/dist/Input.d.ts +1 -1
  212. package/dist/Input.js +4 -4
  213. package/dist/InputShell.d.ts +7 -0
  214. package/dist/InputShell.js +18 -3
  215. package/dist/KeyValueList.d.ts +2 -2
  216. package/dist/Lightbox.js +5 -3
  217. package/dist/ListRow.d.ts +4 -5
  218. package/dist/ListRow.js +36 -26
  219. package/dist/Mark.d.ts +10 -0
  220. package/dist/Mark.js +9 -0
  221. package/dist/Markdown.d.ts +18 -4
  222. package/dist/Markdown.js +176 -37
  223. package/dist/MediaTile.d.ts +9 -3
  224. package/dist/MediaTile.js +8 -4
  225. package/dist/Menu.d.ts +19 -8
  226. package/dist/Menu.js +13 -11
  227. package/dist/MetaList.d.ts +4 -3
  228. package/dist/MetaList.js +12 -4
  229. package/dist/Morph.d.ts +15 -1
  230. package/dist/Morph.js +70 -22
  231. package/dist/NavigationProgress.d.ts +2 -2
  232. package/dist/NavigationProgress.js +7 -5
  233. package/dist/NumberField.d.ts +66 -0
  234. package/dist/NumberField.js +68 -0
  235. package/dist/OutlineRegion.d.ts +41 -10
  236. package/dist/OutlineRegion.js +31 -6
  237. package/dist/PageFade.d.ts +9 -5
  238. package/dist/PageFade.js +39 -8
  239. package/dist/PageLayouts.d.ts +15 -5
  240. package/dist/PageLayouts.js +3 -3
  241. package/dist/Pill.d.ts +9 -4
  242. package/dist/Pill.js +15 -6
  243. package/dist/Popover.d.ts +31 -0
  244. package/dist/Popover.js +43 -0
  245. package/dist/Price.d.ts +21 -0
  246. package/dist/Price.js +34 -0
  247. package/dist/ProductTile.d.ts +36 -0
  248. package/dist/ProductTile.js +31 -0
  249. package/dist/ProgressBar.js +4 -2
  250. package/dist/PromoBanner.d.ts +25 -0
  251. package/dist/PromoBanner.js +16 -0
  252. package/dist/RadioGroup.d.ts +18 -8
  253. package/dist/RadioGroup.js +42 -18
  254. package/dist/ScrollStrip.d.ts +1 -1
  255. package/dist/ScrollStrip.js +1 -1
  256. package/dist/SearchInput.d.ts +17 -2
  257. package/dist/SearchInput.js +72 -13
  258. package/dist/SegmentedField.d.ts +15 -0
  259. package/dist/SegmentedField.js +15 -0
  260. package/dist/Select.js +5 -4
  261. package/dist/Show.d.ts +1 -1
  262. package/dist/Show.js +1 -1
  263. package/dist/SideColumn.d.ts +42 -15
  264. package/dist/SideColumn.js +45 -19
  265. package/dist/SiteFooter.d.ts +3 -3
  266. package/dist/SiteFooter.js +4 -3
  267. package/dist/SiteSearch.d.ts +57 -27
  268. package/dist/SiteSearch.js +13 -93
  269. package/dist/Slider.d.ts +27 -0
  270. package/dist/Slider.js +58 -0
  271. package/dist/SortableList.d.ts +19 -35
  272. package/dist/SortableList.js +36 -88
  273. package/dist/Stack.d.ts +4 -4
  274. package/dist/StackedBar.d.ts +13 -4
  275. package/dist/StackedBar.js +12 -7
  276. package/dist/StateMachine.d.ts +65 -0
  277. package/dist/StateMachine.js +113 -0
  278. package/dist/StatusPages.d.ts +28 -10
  279. package/dist/StatusPages.js +10 -10
  280. package/dist/Stepper.d.ts +21 -0
  281. package/dist/Stepper.js +33 -0
  282. package/dist/Steps.js +4 -3
  283. package/dist/Switch.d.ts +3 -3
  284. package/dist/Switch.js +18 -14
  285. package/dist/Table.d.ts +32 -9
  286. package/dist/Table.js +50 -20
  287. package/dist/TableCells.d.ts +24 -21
  288. package/dist/TableCells.js +68 -27
  289. package/dist/TableEditCell.d.ts +1 -1
  290. package/dist/TableOfContents.d.ts +34 -0
  291. package/dist/TableOfContents.js +23 -0
  292. package/dist/Tabs.d.ts +31 -16
  293. package/dist/Tabs.js +97 -22
  294. package/dist/TextLink.d.ts +18 -5
  295. package/dist/TextLink.js +19 -6
  296. package/dist/Textarea.d.ts +12 -1
  297. package/dist/Textarea.js +15 -2
  298. package/dist/ToastRegion.d.ts +17 -9
  299. package/dist/ToastRegion.js +70 -13
  300. package/dist/Tooltip.d.ts +10 -2
  301. package/dist/Tooltip.js +32 -11
  302. package/dist/Video.d.ts +19 -4
  303. package/dist/Video.js +15 -5
  304. package/dist/cardContext.d.ts +7 -0
  305. package/dist/cardContext.js +14 -0
  306. package/dist/cardControl.d.ts +15 -0
  307. package/dist/cardControl.js +32 -0
  308. package/dist/cardForm.d.ts +39 -0
  309. package/dist/cardForm.js +81 -0
  310. package/dist/cardWait.js +2 -1
  311. package/dist/colourScheme.d.ts +12 -2
  312. package/dist/colourScheme.js +32 -6
  313. package/dist/control.d.ts +30 -8
  314. package/dist/control.js +74 -7
  315. package/dist/copyScript.d.ts +7 -8
  316. package/dist/copyScript.js +8 -9
  317. package/dist/cx.d.ts +22 -3
  318. package/dist/cx.js +22 -3
  319. package/dist/dateLocale.d.ts +17 -0
  320. package/dist/dateLocale.js +30 -0
  321. package/dist/density.d.ts +15 -1
  322. package/dist/density.js +27 -8
  323. package/dist/emptySlot.d.ts +1 -0
  324. package/dist/fieldAnnounce.d.ts +11 -0
  325. package/dist/fieldAnnounce.js +36 -0
  326. package/dist/fieldControl.d.ts +7 -2
  327. package/dist/fieldControl.js +6 -2
  328. package/dist/fieldWait.d.ts +3 -3
  329. package/dist/fieldWait.js +3 -4
  330. package/dist/flowLayout.d.ts +68 -0
  331. package/dist/flowLayout.js +105 -0
  332. package/dist/fromXState.d.ts +73 -0
  333. package/dist/fromXState.js +110 -0
  334. package/dist/icons.d.ts +1 -1
  335. package/dist/icons.js +15 -0
  336. package/dist/index.d.ts +37 -11
  337. package/dist/index.js +24 -2
  338. package/dist/isoDate.d.ts +8 -1
  339. package/dist/isoDate.js +20 -1
  340. package/dist/labelWords.d.ts +16 -7
  341. package/dist/labelWords.js +14 -12
  342. package/dist/listRowProps.d.ts +17 -15
  343. package/dist/modal.d.ts +5 -0
  344. package/dist/modal.js +21 -1
  345. package/dist/navFold.js +6 -3
  346. package/dist/optionCard.d.ts +18 -0
  347. package/dist/optionCard.js +16 -0
  348. package/dist/scrollBody.d.ts +16 -0
  349. package/dist/scrollBody.js +15 -0
  350. package/dist/scrollEdges.d.ts +7 -0
  351. package/dist/scrollEdges.js +39 -5
  352. package/dist/scrollStop.d.ts +6 -2
  353. package/dist/scrollStop.js +24 -8
  354. package/dist/shownDate.d.ts +28 -10
  355. package/dist/shownDate.js +41 -22
  356. package/dist/siteSearchBody.d.ts +34 -0
  357. package/dist/siteSearchBody.js +117 -0
  358. package/dist/size.d.ts +7 -1
  359. package/dist/sortableDrop.d.ts +44 -0
  360. package/dist/sortableDrop.js +78 -0
  361. package/dist/sortableSlide.d.ts +9 -0
  362. package/dist/sortableSlide.js +70 -0
  363. package/dist/sortableTitle.d.ts +10 -0
  364. package/dist/sortableTitle.js +48 -0
  365. package/dist/stateMachineDots.d.ts +45 -0
  366. package/dist/stateMachineDots.js +162 -0
  367. package/dist/stickyColumn.d.ts +2 -2
  368. package/dist/stickyColumn.js +2 -2
  369. package/dist/switcher.d.ts +10 -5
  370. package/dist/switcher.js +7 -5
  371. package/dist/tableColumns.d.ts +17 -0
  372. package/dist/tableColumns.js +30 -2
  373. package/dist/tableEmpty.js +5 -5
  374. package/dist/tableRow.d.ts +26 -2
  375. package/dist/tableRow.js +23 -1
  376. package/dist/tableSort.d.ts +10 -5
  377. package/dist/tableSort.js +15 -4
  378. package/dist/target.d.ts +12 -0
  379. package/dist/target.js +12 -0
  380. package/dist/textBox.js +1 -1
  381. package/dist/truncated.d.ts +31 -0
  382. package/dist/truncated.js +51 -0
  383. package/dist/typography.d.ts +19 -11
  384. package/dist/typography.js +11 -13
  385. package/dist/useFlowLayout.d.ts +27 -0
  386. package/dist/useFlowLayout.js +119 -0
  387. package/package.json +7 -3
  388. package/skills/uislash/SKILL.md +20 -0
@@ -0,0 +1,90 @@
1
+ ## IconButton
2
+
3
+ Group: Actions
4
+
5
+ When to use: An action with a familiar icon and no room for a word: delete, settings, alerts.
6
+
7
+ ### The one right way
8
+ `label` names the button for a screen reader and shows as its tooltip; the icon is only decoration.
9
+ ```tsx
10
+ import { IconButton } from "@slashsuite/ui-react";
11
+
12
+ <IconButton label="Delete quote" tone="danger" variant="ghost" icon="close" />
13
+ ```
14
+
15
+ ### Do
16
+ - Always give the `label`: it is the accessible name and the tooltip, and the icon is only decoration.
17
+ - `variant="ghost"` is the quiet one for a row or a toolbar; `tone="danger"` is for delete and clear.
18
+ - `size` is `sm` (26px) inside a row or a chip, `md` (default, 38px, the height of a `Button`) or `lg` beside a large `Button`.
19
+ - An unread count is `count`, never part of the label; it is not shown at 0. The icon is `icon`, a name from the `Icon` set, never a child.
20
+ - Going to another page is `href` (through the app's `LinkProvider`), which draws the same button as a link.
21
+ - Say why it cannot be pressed with `disabledReason`: the reason becomes its tooltip in place of the label.
22
+ - An action that needs a word is a `Button`.
23
+ - A row of several icon buttons is a `Menu`: one main action in view, the rest behind it.
24
+
25
+ ### Don't
26
+ A `Button` holding a glyph has no accessible name, no tooltip and the wrong box; an icon-only action is an `IconButton`.
27
+ ```tsx
28
+ import { Button } from "@slashsuite/ui-react";
29
+
30
+ <Button variant="ghost" tone="danger" size="sm">
31
+ <span aria-hidden="true">x</span>
32
+ </Button>
33
+ ```
34
+
35
+ A count typed into the label shows only in the tooltip, so a sighted user never sees it on the button.
36
+ ```tsx
37
+ import { IconButton } from "@slashsuite/ui-react";
38
+
39
+ <IconButton label="Alerts (3)" icon="bell" />
40
+
41
+ ```
42
+
43
+ A button that sets `location` loses middle-click, the status-bar URL and crawlability.
44
+ ```tsx
45
+ import { IconButton } from "@slashsuite/ui-react";
46
+
47
+ <IconButton
48
+ label="Settings"
49
+ variant="ghost"
50
+ onClick={() => location.assign("#settings")}
51
+ icon="settings"
52
+ />
53
+ ```
54
+
55
+ A bare `disabled` drops it from the tab order and gives no reason.
56
+ ```tsx
57
+ import { IconButton } from "@slashsuite/ui-react";
58
+
59
+ <IconButton label="Delete quote" tone="danger" icon="close" disabled />
60
+ ```
61
+
62
+ ### Accessibility
63
+ - `label` is set as `aria-label`, and shows as a tooltip above the button on hover and on keyboard focus (the native `title` in a browser without CSS anchor positioning); with a `count` it reads `Alerts, 3`. The tooltip repeats the name, so it is hidden from a screen reader.
64
+ - The badge itself is `aria-hidden`, so the count is read once, through the name.
65
+ - As a button it defaults to `type="button"`; with `href` it is a real link, and `external` opens a new tab with `rel="noreferrer"`.
66
+ - `disabledReason` sets `aria-disabled` and keeps the button in the tab order; a click, Enter and Space do nothing, and the reason shows as a tooltip on hover, keyboard focus and a tap, read out as its description (the native `title` without CSS anchor positioning).
67
+ - It has the component's focus ring.
68
+
69
+ ### Props
70
+ ### IconButton
71
+ A square button holding one icon from the `Icon` set (`icon`). `label` is its accessible name and tooltip. `variant="ghost"` drops the border for a quiet action in a row or a toolbar; `size` matches the height of a `Button` of the same size (`sm` 26px, `md` 38px, `lg` 46px; a responsive `{ base, md }` changes at 48rem) and with no `size` it takes its container's; `tone="danger"` is red, for delete and clear; `count` pins a red count to the corner; `disabledReason` blocks it and shows why. Defaults to `type="button"`. `href` makes it a link instead (the app's router link through `LinkProvider` for an in-app path, else a plain `<a>`; `external` opens a new tab), with the same look.
72
+ - count: number. A red count on the top corner at the end edge, for unread alerts. Not shown at 0; the name carries it for a screen reader, "Alerts, 3".
73
+ - disabledReason: string. Why the button cannot be pressed: it dims and is blocked (`aria-disabled`; a click, Enter and
74
+ Space do nothing) while it stays in the tab order, and the reason is its tooltip on hover,
75
+ keyboard focus and a tap, read out as its description. The name stays `label`.
76
+ - external: boolean. Opens in a new tab: adds `target="_blank"` and `rel="noreferrer"`.
77
+ - href: string. Makes the button a link to this URL; an in-app path goes through the app's `LinkProvider`.
78
+ - icon: "page" | "grid" | "search" | "alert" | "table" | "type" | "diff" | "baseline" | "review" | "ci" | "self-host" | "privacy" | "capture" | "branch" | "theme" | "speed" | "chevron-right" | "chevron-down" | "close" | "external-link" | "settings" | "bell" | "check" | "plus" | "minus" | "more" | "window" | "card" | "pointer" | "field" | "compass" | "briefcase" | "cart" | "pause" | "play" (required). The one icon it holds, from the `Icon` set, at the button's size.
79
+ - label: string (required). The button's accessible name and its tooltip, shown on hover and on keyboard focus.
80
+ - size: Size | ResponsiveSize (default md). The button's height, matching a `Button` or `Input` of the same size. Left out, it takes the
81
+ size of the `Card`, `ListRow` or `Table` it sits in, else `md`. `{ base: "md", md: "lg" }`
82
+ changes size at the `md` breakpoint (48rem), in CSS.
83
+
84
+ Give it the same value as a responsive `Button` beside it.
85
+ - tone: "neutral" | "danger" (default neutral). `danger` is red, for delete and clear.
86
+ - variant: "outline" | "ghost" (default outline). `outline` has a border; `ghost` has none, until the hover fill.
87
+
88
+ ### Types
89
+ - IconButtonTone: `"neutral" | "danger"`. An IconButton's tones: `neutral` (the default) and `danger`.
90
+ - IconButtonVariant: `"outline" | "ghost"`. An IconButton's look: `outline` with a border, or `ghost` with none until hover.
@@ -0,0 +1,59 @@
1
+ ## Icon
2
+
3
+ Group: Actions
4
+
5
+ When to use: A glyph beside text or inside a control: a flag in a row, a camera in a Button, or a feature icon (`name` at `feature` size) that stands for an idea.
6
+
7
+ ### The one right way
8
+ A bare `<svg>` goes in an `Icon`, which sizes and tones it, and a Button beside text needs nothing more.
9
+ ```tsx
10
+ import { Button, Icon } from "@slashsuite/ui-react";
11
+
12
+ <Button variant="outline">
13
+ <Icon>
14
+ <svg viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.6">
15
+ <path d="M3 6.5h3l1.5-2h5L14 6.5h3v9H3Z" strokeLinejoin="round" />
16
+ <circle cx="10" cy="11" r="2.75" />
17
+ </svg>
18
+ </Icon>
19
+ Capture
20
+ </Button>
21
+ ```
22
+
23
+ ### Do
24
+ - `name` picks one of the library's icons, all on one grid and one stroke: `diff`, `baseline`, `review`, `ci`, `self-host`, `privacy`, `capture`, `branch`, `theme`, `speed`, `search`, `chevron-right`, `chevron-down`, `close`, `external-link`, `settings`, `bell`, `check`, `alert`, `plus`, `minus`, `more`, `grid`, `window`, `type`, `card`, `pointer`, `field`, `table`, `compass`, `page`, `briefcase`, `cart`, `pause` and `play`. Each is named for its idea or action, not a product. Prefer one to drawing your own.
25
+ - For a glyph the set lacks, put a bare `<svg>` (with a `viewBox`, no size or colour classes) in an `Icon`; it fills the box.
26
+ - `size` is `sm` (14px), `md` (16px, the default), `lg` (20px) or `feature` (32px), for an icon that stands for an idea on its own. A feature card takes its icon through `Card`'s `icon`.
27
+ - `tone` is a text tone: `neutral`, `muted`, `accent`, `info`, `positive`, `warn` or `danger`. Left out, the icon takes the colour of the text around it, so draw the glyph with `currentColor`.
28
+ - An icon that is a button is an `IconButton`.
29
+
30
+ ### Don't
31
+ A bare `<svg>` with its own size and colour is a one-off: each one picks its own size and colour, and none follows the theme's muted text.
32
+ ```tsx
33
+ import { Button } from "@slashsuite/ui-react";
34
+
35
+ <Button variant="outline">
36
+ <svg viewBox="0 0 20 20" fill="none" stroke="#5ec8ff" strokeWidth="1.6" width="18" height="18">
37
+ <path d="M3 6.5h3l1.5-2h5L14 6.5h3v9H3Z" strokeLinejoin="round" />
38
+ <circle cx="10" cy="11" r="2.75" />
39
+ </svg>
40
+ Capture
41
+ </Button>
42
+ ```
43
+
44
+ ### Accessibility
45
+ - An Icon is decorative and `aria-hidden` by default: the text beside it says what it means.
46
+ - An icon that carries meaning on its own takes a `label`, which makes it `role="img"` with that name.
47
+
48
+ ### Props
49
+ ### Icon
50
+ One inline icon, sized to a fixed box (sm 14px, md 16px, lg 20px, `feature` 32px) and drawn in `currentColor`, so it takes the text colour around it unless a `tone` says otherwise. `name` picks one of the library's own icons, all drawn on one grid with one stroke: feature ideas (`diff`, `baseline`, `review`, `ci`, `self-host`, `privacy`, `capture`, `branch`, `theme`, `speed`, `search`) and UI glyphs (`chevron-right`, `chevron-down`, `close`, `external-link`, `settings`, `bell`, `check`, `alert`, `plus`, `more`) and the ideas the docs sections stand for (`grid`, `window`, `type`, `card`, `pointer`, `field`, `table`, `compass`, `page`, `briefcase`); without a name, a bare `<svg>` child fills the box. It is decorative (`aria-hidden`) by default; a `label` makes it an image with that name, for an icon that carries meaning no text beside it says.
51
+ - children: ReactNode. The `<svg>`, drawn in `currentColor`; it fills the box.
52
+ - id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
53
+ - label: string. Names the icon (`role="img"`). Without one the icon is hidden from assistive tech.
54
+ - name: "page" | "grid" | "search" | "alert" | "table" | "type" | "diff" | "baseline" | "review" | "ci" | "self-host" | "privacy" | "capture" | "branch" | "theme" | "speed" | "chevron-right" | "chevron-down" | "close" | "external-link" | "settings" | "bell" | "check" | "plus" | "minus" | "more" | "window" | "card" | "pointer" | "field" | "compass" | "briefcase" | "cart" | "pause" | "play". One of the library's icons, named for the idea it stands for.
55
+ - size: Size | ResponsiveSize | "feature" (default md). The box: sm 14px, md 16px (the default), lg 20px, `feature` 32px for an icon that stands for an idea on its own (a feature card). `{ base, md }` (sm, md, lg) changes at the `md` breakpoint (48rem), as the icon in a Button of that size does.
56
+ - tone: "muted" | "neutral" | "info" | "positive" | "warn" | "danger" | "accent". A text tone. Left out, the icon takes the colour of the text around it.
57
+
58
+ ### Types
59
+ - IconName: `"baseline" | "diff" | "review" | "ci" | "self-host" | "privacy" | "capture" | "branch" | "theme" | "speed" | "search" | "chevron-right" | "chevron-down" | "close" | "external-link" | "settings" | "bell" | "check" | "alert" | "plus" | "minus" | "more" | "grid" | "window" | "type" | "card" | "pointer" | "field" | "table" | "compass" | "page" | "briefcase" | "cart" | "pause" | "play"`. The names of the icon set: feature ideas, then UI glyphs, then the ideas the docs sections stand for.
@@ -0,0 +1,74 @@
1
+ ## Image
2
+
3
+ Group: Content
4
+
5
+ When to use: Showing a picture that your app serves: a screenshot, a QR code, a product shot.
6
+
7
+ ### Use instead
8
+ - MediaTile (media-tile.md): The picture is a thing: it has a label, opens, or can be removed.
9
+ - Avatar (avatar.md): The picture is a person.
10
+ - OutlineRegion (outline-region.md): Areas of the picture are marked: a `RegionFrame`.
11
+ - ColourSwatch (colour-swatch.md): What is shown is one colour, with its hex value.
12
+
13
+ ### The one right way
14
+ A picture that must be seen whole, such as a QR code or a logo, is `fit="contain"`.
15
+ ```tsx
16
+ import { Image } from "@slashsuite/ui-react";
17
+
18
+ <Image src={sampleCode} alt="Pairing code" aspect="3:4" width="md" fit="contain" />
19
+ ```
20
+
21
+ ### Do
22
+ - `src` is your own picture, a local path or a data URL, and `alt` says what it shows. The corners are rounded and a hairline frames it on the inset surface. It loads lazily; give `priority` to the one picture at the top of the page, so it loads first.
23
+ - `aspect` is the shape it is cropped to: `square`, `4:3` (the default), `3:2`, `16:10`, `16:9`, the portrait `3:4` and `9:16`, or `natural`. The shape is reserved before the picture loads, so the page does not jump. `natural` is the exception: the picture keeps its own proportions, with nothing cropped, and the space is not reserved until it loads.
24
+ - `fit="cover"` (the default) fills the shape and crops what overflows, from the centre, or from the top with `crop="top"` for a page screenshot. `fit="contain"` shows the whole picture, for a QR code or a logo that must not lose its edges.
25
+ - `mat` is `white` or `page`, with padding, and shows all of the picture. A QR code, a barcode or a logo takes `mat="white"`: it is white in every theme, dark ones included, so a code scans off a dark page. A screenshot on a page takes `mat="page"`, the page's own tone. Leave it out for a photo, not a mat.
26
+ - `width` is `sm` (96px), `md` (160px), `lg` (256px) or `xl` (448px), each a cap that a narrower parent still wins over, or `full` (the default) for the parent's width.
27
+ - `href` makes the picture a link that opens the full file in a new tab, named by `alt`: a screenshot a reader wants to see at full size.
28
+ - With no `src`, or one that fails to load, a placeholder of the same size with a picture mark takes its place. A new `src` tries again.
29
+ - A person's photo is an `Avatar`; a clickable thumbnail with a label is a `MediaTile`; a video is a `Video`.
30
+
31
+ ### Don't
32
+ `cover` crops to the shape: it cuts the corners off a code, which then cannot be scanned.
33
+ ```tsx
34
+ import { Image } from "@slashsuite/ui-react";
35
+
36
+ <Image src={sampleCode} alt="Pairing code" aspect="16:9" width="md" fit="cover" />
37
+ ```
38
+
39
+ ### Accessibility
40
+ - An `<img>` named by `alt`. The placeholder is a `role="img"` with the same `alt`, so a missing picture is still announced.
41
+ - With `href` it is a link named by `alt` that opens in a new tab, with the focus ring from the component.
42
+ - An empty `alt` marks the picture as decoration: it is hidden from a screen reader, placeholder included. Do that only when the text beside it says the same thing.
43
+
44
+ ### Props
45
+ ### Image
46
+ A picture in a fixed shape: `aspect` reserves the space before it loads, so the page does not jump, and `fit` crops it to the shape or shows all of it. The corners are rounded and the frame has a hairline. If the picture is missing or fails to load, a same-sized placeholder with a picture mark stands in, still named by `alt`. `mat` sets it on a padded mat: `white` for a code or a logo, `page` for a screenshot. `href` links it to its full size in a new tab. It loads lazily unless it is the `priority` picture. A user's photo is an `Avatar`; a clickable thumbnail with a label is a `MediaTile`. While `loading` with no `src` yet it is a bone of the same shape, not the placeholder, which means there is no picture.
47
+ - alt: string (required). What the picture shows. An empty string marks it as decoration, hidden from a screen reader.
48
+ - aspect: "square" | "4:3" | "3:2" | "16:10" | "16:9" | "3:4" | "9:16" | "natural" (default 4:3). The shape it is cropped to: `square`, `4:3`, `3:2`, `16:9`, or the portrait `3:4` and `9:16`.
49
+ `natural` keeps the picture's own proportions instead, so nothing is cropped or letterboxed;
50
+ the space is not reserved before it loads.
51
+ - crop: "center" | "top" (default center). Where `fit="cover"` crops from: `center` keeps the middle of the picture, `top` keeps its top
52
+ edge, for a screenshot whose header is the part to see.
53
+ - fit: "cover" | "contain" (default cover). `cover` fills the shape and crops what overflows; `contain` shows the whole picture, with the
54
+ rest of the shape left empty (a QR code, a logo).
55
+ - href: string. Makes the picture a link to its full size, opened in a new tab (`target="_blank"`,
56
+ `rel="noreferrer"`), named by `alt`.
57
+ - id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
58
+ - loading: boolean. The data is not here yet: an empty slot draws a bone of its shape, a filled one draws as usual.
59
+ Left out, the part takes the nearest loading layout's or part's; `false` opts it out inside one.
60
+ - loadingLabel: string (default Loading). What a screen reader hears while this part is loading, when its own `loading` is set.
61
+ - mat: "page" | "white". Sets the picture on a padded mat and shows the whole of it, as `fit="contain"`, whatever `fit`
62
+ says. `white` is white in every theme, dark ones included, so a QR code, a barcode or a logo
63
+ reads off a dark page. `page` is a ground a step below the page in each theme, for a
64
+ screenshot. Left out, there is no mat.
65
+ - priority: boolean (default false). Marks the picture that is the page's largest one in the first view (its LCP): it loads at once
66
+ with a high fetch priority. Every other picture loads lazily, when it nears the viewport.
67
+ - src: string. The picture, a local path or a data URL. It is never loaded for you: this is the app's own
68
+ image. Left out, or if it fails to load, the picture is replaced by a placeholder.
69
+ - width: "sm" | "md" | "lg" | "xl" | "full" (default full). `sm` 96px, `md` 160px, `lg` 256px and `xl` 448px set the width, capped at the parent's; `full`
70
+ fills the parent.
71
+
72
+ ### Types
73
+ - ImageAspect: `"square" | "4:3" | "3:2" | "16:10" | "16:9" | "3:4" | "9:16" | "natural"`. The shapes an image is cropped or letterboxed to, or `natural`: no shape of its own, so the picture keeps its own proportions.
74
+ - ImageWidth: `Size | "xl" | "full"`. How wide an image is: `full` fills its parent; the others are 96, 160, 256 or 448px, capped at the parent's width.
@@ -0,0 +1,84 @@
1
+ ## Input
2
+
3
+ Group: Forms
4
+
5
+ When to use: A short piece of text: a name, an amount, a search term.
6
+
7
+ ### The one right way
8
+ An amount is a `prefix` for the currency and `numeric`, which lines the digits up and brings up the number keypad.
9
+ ```tsx
10
+ import { Input } from "@slashsuite/ui-react";
11
+
12
+ <Input prefix="R" numeric width="md" aria-label="Amount" defaultValue="49.90" />
13
+ ```
14
+
15
+ ### Do
16
+ - Put an `Input` in a `Field`. Without one, name it with `aria-label`.
17
+ - A search box is `type="search"` with an `icon`; the clear button appears by itself.
18
+ - `prefix` is short text inside the border before the value, such as a currency symbol. It is for a plain field, not one with an `icon` or `type="search"`.
19
+ - A figure is `numeric`: an amount is `<Input prefix="R" numeric />` in a `Field`, and a count or a whole number is `<Input numeric inputMode="numeric" />`. It right-aligns the digits in tabular figures and brings up the number keypad. A unit other than a currency goes in the `label` ("UIF rate (%)").
20
+ - `size="sm"` is for a dense form or a table row, `size="lg"` for a sign-in or search form that stands alone; `md` is the default.
21
+ - A field beside a `Button` that changes size with the screen takes the same responsive size, `size={{ base: "lg", md: "md" }}`, so the two stay one height at both widths.
22
+ - `width` is `full` by default; `xs`, `sm`, `md` and `lg` are fixed widths for a short value; `fill` grows to the room beside other items in a row; `auto` is as wide as the browser makes it.
23
+ - A paragraph is a `Textarea`; a choice from a list is a `Select`; a date is a `DateField`.
24
+
25
+ ### Don't
26
+ - Do not use `type="number"` for an amount or a count a person types: the browser drops "1 250" and "12,400.00", the mouse wheel changes the value under a scrolling page, and the spinner arrows sit where the figure should end.
27
+
28
+ A currency typed into the placeholder is gone as soon as the person types, and nothing keeps the digits aligned.
29
+ ```tsx
30
+ import { Input } from "@slashsuite/ui-react";
31
+
32
+ <Input placeholder="R 0.00" width="md" aria-label="Amount" />
33
+
34
+ ```
35
+
36
+ `type="number"` drops "1 250", puts spinner arrows where the figure should end, and lets the mouse wheel change the value as the page scrolls.
37
+ ```tsx
38
+ import { Field, Input } from "@slashsuite/ui-react";
39
+
40
+ <Field label="Quantity">
41
+ <Input type="number" width="xs" defaultValue="12" />
42
+ </Field>
43
+ ```
44
+
45
+ A plain text input used for search has no icon and no way to clear it.
46
+ ```tsx
47
+ import { Input } from "@slashsuite/ui-react";
48
+
49
+ <Input aria-label="Search shops" placeholder="Search by name or suburb…" />
50
+ ```
51
+
52
+ ### Accessibility
53
+ - An `Input` is a native `<input>`: it takes `type`, `inputMode`, `autoComplete`, `required`, `disabled` and the `aria-*` and `data-*` props.
54
+ - A `type="search"` field shows a clear button while it has a value, named "Clear search" or by `clearLabel`; it is hidden when the field is disabled or read-only. Escape clears it too, and in a `Dialog` only the second Escape, in the empty field, closes the dialog.
55
+ - The `icon` is decorative and hidden from assistive tech.
56
+ - A `numeric` field is a text field with a number keypad (`inputMode="decimal"` unless you pass your own), so it is read and kept exactly as typed.
57
+ - In a `Field`, the `Field` around it gives it its label and its hint or error as `aria-describedby`, and an error marks it `aria-invalid` with a red edge.
58
+ - The focus ring comes from the component.
59
+
60
+ ### Props
61
+ ### Input
62
+ A text input. `icon` names a leading icon inside the field (`icon="search"`). `prefix` puts short text inside the border before the value, such as a currency symbol; it is for a plain field, not with an `icon` or `type="search"`. `numeric` is a field for a figure: an amount (`<Input prefix="R" numeric />`) or a count (`numeric inputMode="numeric"`). It right-aligns the value in tabular figures and brings up the phone's number keypad (`inputMode="decimal"` unless you pass your own), and stays a text field, so "1 250" is kept as typed; never use `type="number"` for a figure a person types. `type="search"` drops the browser's own search look and shows a clear button at the trailing edge while the field has a value, named by `clearLabel`, and Escape clears it. The `ref` reaches the `<input>`.
63
+ - clearLabel: string (default Clear search). The name of a `type="search"` field's clear button, for an app in another language.
64
+ - disabled: boolean (native). Disables the field; say why in its `Field` hint.
65
+ - icon: "page" | "grid" | "search" | "alert" | "table" | "type" | "diff" | "baseline" | "review" | "ci" | "self-host" | "privacy" | "capture" | "branch" | "theme" | "speed" | "chevron-right" | "chevron-down" | "close" | "external-link" | "settings" | "bell" | "check" | "plus" | "minus" | "more" | "window" | "card" | "pointer" | "field" | "compass" | "briefcase" | "cart" | "pause" | "play". A leading icon inside the field, by name (`search`). Not with `prefix`.
66
+ - name: string (native). The key the value posts under in a form.
67
+ - numeric: boolean (default false). A field for a figure (an amount, a count): the value right-aligned in tabular figures, and
68
+ `inputMode="decimal"` unless you pass your own (`numeric` for a whole number). It stays a
69
+ text field, so the value is kept as typed; parsing it is yours. Ignored on `type="search"`.
70
+ - placeholder: string (native). A hint shown while the field is empty; never the label.
71
+ - prefix: string. Short text inside the border before the value (a currency symbol). For a plain field: not with `icon` or `type="search"`.
72
+ - ref: Ref<HTMLInputElement>. The `<input>` itself, for focus control.
73
+ - required: boolean (native). The form will not submit while the field is empty.
74
+ - size: Size | ResponsiveSize (default md). `sm` is compact, `text-sm` with less padding, for dense forms and table rows; `md` is `text-base`;
75
+ `lg` is `text-lg` with more padding, for a hero form. Under an `AppShell density="compact"` each
76
+ is one type step down, and on a touch screen a field is never under 16px.
77
+ `{ base: "md", md: "lg" }` changes size at the `md` breakpoint (48rem), in CSS, as a `Button`'s
78
+ does: give the field and the buttons in its row the same value, so the row stays aligned.
79
+ - type: string (native). The kind of value: `"text"`, `"email"`, `"search"`, `"password"` and the rest.
80
+ - width: "sm" | "md" | "lg" | "auto" | "xs" | "fill" | "full" (default full). `full` (default) fills the parent; `fill` grows to fill the room left in a row beside other items (it can shrink to nothing, so buttons stay on the line); `xs`, `sm`, `md`, `lg` are fixed; `auto` adds no width class, so the control is as wide as the browser makes it.
81
+
82
+ ### Types
83
+ - ControlSize: `"sm" | "md" | "lg"`. A control's size: the library's one `Size` scale.
84
+ - ControlWidth: `"sm" | "md" | "lg" | "xs" | "full" | "fill" | "auto"`. `full` fills the parent (the default); `fill` grows to the space left in a flex row; `auto` adds no width class, so the control is as wide as the browser makes it; the rest are fixed.
@@ -0,0 +1,38 @@
1
+ ## Kbd
2
+
3
+ Group: Text
4
+
5
+ When to use: A key or a shortcut the reader presses: `Esc`, `?`, `⌘S`.
6
+
7
+ ### The one right way
8
+ `Kbd` is a key the reader presses: in a sentence, or as the shortcut on a button.
9
+ ```tsx
10
+ import { Kbd, Text } from "@slashsuite/ui-react";
11
+
12
+ <Text>
13
+ Press <Kbd>Esc</Kbd> to close this list, or <Kbd>⌘S</Kbd> to save.
14
+ </Text>
15
+ ```
16
+
17
+ ### Do
18
+ - Use `Kbd` for a key the reader presses, in a sentence or as the shortcut on a `Button`.
19
+ - A command or a name is `Code`, never `Kbd`.
20
+
21
+ ### Don't
22
+ A command is `Code`, not a key. `Kbd` draws a keycap, which says "press this".
23
+ ```tsx
24
+ import { Kbd, Text } from "@slashsuite/ui-react";
25
+
26
+ <Text>
27
+ Run <Kbd>bun install</Kbd> to install.
28
+ </Text>
29
+ ```
30
+
31
+ ### Accessibility
32
+ - `Kbd` renders a `<kbd>` element, which marks the text as keyboard input.
33
+ - Its border takes the colour of the text around it, so it reads on plain text and on a filled button.
34
+
35
+ ### Props
36
+ ### Kbd
37
+ A keyboard key. Its border takes the surrounding text colour, so it reads on a filled button and on plain text.
38
+ - id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
@@ -0,0 +1,84 @@
1
+ ## KeyValueList
2
+
3
+ Group: Content
4
+
5
+ When to use: A set of facts about one thing: size, status, dates, shortcut keys.
6
+
7
+ ### Use instead
8
+ - Table (table.md): Many records with the same columns, to read across and compare.
9
+ - ListRow (list-row.md): The items are things to open, not the fields of one record.
10
+ - MetaList (meta-list.md): A few short facts inline, with no labels to line up.
11
+
12
+ ### The one right way
13
+ Label and value pairs are a `KeyValueList`: one row per fact, the label muted, the value in tabular figures.
14
+ ```tsx
15
+ import { KeyValue, KeyValueList } from "@slashsuite/ui-react";
16
+
17
+ <KeyValueList>
18
+ <KeyValue label="Size">1280×720</KeyValue>
19
+ <KeyValue label="Changed pixels">0.4%</KeyValue>
20
+ <KeyValue label="Captured">2 min ago</KeyValue>
21
+ </KeyValueList>
22
+ ```
23
+
24
+ ### Do
25
+ - Put a `KeyValue` with a `label` for each fact; the value is its children.
26
+ - `align="end"` is the default: each label at the left and its value right-aligned. `align="start"` puts every value left-aligned in one column beside the labels, which suits long values.
27
+ - A value can be any content, such as a `Kbd` for a shortcut.
28
+ - `total` closes a column of amounts: a firm rule above it and strong text. `tone` (`muted`, `positive`, `warn`, `danger`, `info`) colours the value on any row; a total that does not reconcile is `total tone="warn"`. Say it in words too, with a sign or "off", since colour alone does not.
29
+
30
+ ### Don't
31
+ - Do not build the rows by hand from a `Cluster`; a grid of records is a `Table`.
32
+
33
+ Rows built by hand from a `Cluster` and `Text` drift from the list's label colour and figures. Use `KeyValueList`.
34
+ ```tsx
35
+ import { Cluster, Stack, Text } from "@slashsuite/ui-react";
36
+
37
+ <Stack gap="xs">
38
+ <Cluster justify="between">
39
+ <Text as="span">Size</Text>
40
+ <Text as="span">1280×720</Text>
41
+ </Cluster>
42
+ <Cluster justify="between">
43
+ <Text as="span">Changed pixels</Text>
44
+ <Text as="span">0.4%</Text>
45
+ </Cluster>
46
+ </Stack>
47
+ ```
48
+
49
+ Long values at the default `align="end"` push against the right edge in a ragged column. Long values take `align="start"`.
50
+ ```tsx
51
+ import { KeyValue, KeyValueList } from "@slashsuite/ui-react";
52
+
53
+ <KeyValueList>
54
+ <KeyValue label="Branch">hc-145-docs-for-every-export</KeyValue>
55
+ <KeyValue label="Commit">83422a6</KeyValue>
56
+ <KeyValue label="Captured">2 min ago</KeyValue>
57
+ </KeyValueList>
58
+ ```
59
+
60
+ ### Accessibility
61
+ - `KeyValueList` is a `<dl>`; each `KeyValue` is a `<div>` holding a `<dt>` for the label and a `<dd>` for the value, so a screen reader announces them as terms and definitions.
62
+ - `id`, `data-*` and `aria-*` go on the list and on each row.
63
+
64
+ ### Props
65
+ ### KeyValueList
66
+ A definition list of label/value rows. By default each label is on the left and its value right-aligned. `align="start"` puts every value left-aligned in one column beside the labels, which are sized to the widest. While `loading` with no rows it draws three rows of bones.
67
+ - align: "end" | "start" (default end). `end` right-aligns each value; `start` puts every value left-aligned in one column beside the labels, sized to the widest.
68
+ - id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
69
+ - loading: boolean. The data is not here yet: an empty slot draws a bone of its shape, a filled one draws as usual.
70
+ Left out, the part takes the nearest loading layout's or part's; `false` opts it out inside one.
71
+ - loadingLabel: string (default Loading). What a screen reader hears while this part is loading, when its own `loading` is set.
72
+
73
+ ### KeyValue
74
+ One row of a KeyValueList: a label on the left, a tabular value on the right (or beside it, in an `align="start"` list). `total` makes it the sum row: a rule above, strong text. `tone` colours the value, on any row: a total that does not reconcile is `total tone="warn"`. While `loading`, a label or value not here yet is a bone.
75
+ - id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
76
+ - label: ReactNode (required). The term, on the left.
77
+ - loading: boolean. The data is not here yet: an empty slot draws a bone of its shape, a filled one draws as usual.
78
+ Left out, the part takes the nearest loading layout's or part's; `false` opts it out inside one.
79
+ - loadingLabel: string (default Loading). What a screen reader hears while this part is loading, when its own `loading` is set.
80
+ - tone: "muted" | "neutral" | "info" | "positive" | "warn" | "danger" | "accent". The meaning of the value, in the colours of a `Table` cell's `tone` (`TextTone`; `neutral`, the default, is the list's ink); the label keeps its ink. Colour alone does not say it, so the value or the label says it too: a sign, a word.
81
+ - total: boolean (default false). The sum the rows above add up to: a firm rule above it and the label and value in strong ink.
82
+
83
+ ### Types
84
+ - KeyValueAlign: `"end" | "start"`. Where a `KeyValueList`'s values sit: `end`, across from their labels, or `start`, under them.
@@ -0,0 +1,97 @@
1
+ ## Lightbox
2
+
3
+ Group: Feedback
4
+
5
+ When to use: Showing a photo or a video at full size, and stepping through a set of them.
6
+
7
+ ### Use instead
8
+ - MediaTile (media-tile.md): The pictures are shown in the page, as tiles to open.
9
+ - Dialog (dialog.md): A question or a form, not a picture.
10
+
11
+ ### The one right way
12
+ A photo or a video opens in a Lightbox: full screen, on its own dark scrim, with steps between items.
13
+ ```tsx
14
+ import { useState } from "react";
15
+ import { Button, Lightbox } from "@slashsuite/ui-react";
16
+
17
+ function Example() {
18
+ const [at, setAt] = useState<number | null>(null);
19
+ const photo = at === null ? undefined : sampleScenes[at];
20
+ return (
21
+ <>
22
+ <Button variant="outline" onClick={() => setAt(0)}>
23
+ View photos
24
+ </Button>
25
+ {at !== null && photo && (
26
+ <Lightbox
27
+ label={photo.alt}
28
+ title="Anna"
29
+ caption={photo.caption}
30
+ onClose={() => setAt(null)}
31
+ onPrevious={at > 0 ? () => setAt(at - 1) : undefined}
32
+ onNext={at < sampleScenes.length - 1 ? () => setAt(at + 1) : undefined}
33
+ >
34
+ <img src={photo.src} alt={photo.alt} />
35
+ </Lightbox>
36
+ )}
37
+ </>
38
+ );
39
+ }
40
+ ```
41
+
42
+ ### Do
43
+ - Render it only while it is open: `{open && <Lightbox … onClose={() => setOpen(false)} />}`. It opens itself on mount.
44
+ - Pass one `<img>` or `<video>` as its children, with no classes: the Lightbox scales it down to fit the screen and keeps its shape.
45
+ - `label` names it for a screen reader. `title` and `meta` are lines above the media (who posted it, and when); `caption` is the text under it.
46
+ - To step through a set, pass `onPrevious` and `onNext`: each shows its button and binds its arrow key. Leave `onPrevious` out on the first item and `onNext` on the last.
47
+ - The scrim is near-black with light text in every theme, light themes included, so a photo reads as it would in any viewer. It takes the dark colour scheme too, so a video's own controls are dark on it.
48
+ - It fades out on close while it is still in the DOM, so `onClose` is called once the fade has finished: put `setOpen(false)` there and nowhere else. Esc, the scrim and the close button close it that way already.
49
+
50
+ ### Don't
51
+ - Do not draw your own scrim for media; a question about a photo is a `Dialog`.
52
+
53
+ A Dialog is for a question: its panel boxes a photo in at a form's width, on the theme's light surface.
54
+ ```tsx
55
+ import { useState } from "react";
56
+ import { Button, Dialog } from "@slashsuite/ui-react";
57
+
58
+ function Example() {
59
+ const [open, setOpen] = useState(false);
60
+ const photo = sampleScenes[0];
61
+ return (
62
+ <>
63
+ <Button variant="outline" onClick={() => setOpen(true)}>
64
+ View photo
65
+ </Button>
66
+ {open && photo && (
67
+ <Dialog title="Anna" onClose={() => setOpen(false)}>
68
+ <img src={photo.src} alt={photo.alt} />
69
+ </Dialog>
70
+ )}
71
+ </>
72
+ );
73
+ }
74
+ ```
75
+
76
+ ### Accessibility
77
+ - A Lightbox is the browser's own `<dialog>` opened with `showModal()`: the page behind goes inert, focus stays inside it and Esc closes it.
78
+ - It is named by `label` through `aria-label`; give the `<img>` its own `alt`.
79
+ - The close, previous and next buttons are named Close, Previous and Next (`closeLabel`, `previousLabel` and `nextLabel` for another language), and keep a light focus ring that shows on the dark scrim in every theme.
80
+ - A click on the scrim around the media closes it; a click on the media or its text does not.
81
+ - Closing, or unmounting it, hands focus back to the element that opened it. The fade is switched off under `prefers-reduced-motion: reduce`.
82
+
83
+ ### Props
84
+ ### Lightbox
85
+ A full-screen photo or video viewer on the browser's own `<dialog>`: it is opened with `showModal()` on mount, so render it only while it is open. The page behind goes inert, Esc closes it and focus stays inside; a click on the scrim around the media and its text closes it too. The scrim stays near-black with light text in every theme. `onPrevious` and `onNext` add step buttons and the arrow keys.
86
+ - caption: ReactNode. Muted text on the scrim under the media.
87
+ - children: ReactNode (required). The media: one `<img>` or `<video>`, scaled down to fit the screen.
88
+ - closeLabel: string (default Close). The close button's name, for an app in another language.
89
+ - id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
90
+ - label: string (required). The viewer's accessible name, e.g. "Photo from Anna".
91
+ - meta: ReactNode. A muted line under the title, e.g. when.
92
+ - nextLabel: string (default Next). The next button's name.
93
+ - onClose: () => void (required). Called when the viewer closes: Esc, a click on the scrim or the close button.
94
+ - onNext: (() => void). Shows a next button and binds ArrowRight. Leave it out at the last item.
95
+ - onPrevious: (() => void). Shows a previous button and binds ArrowLeft. Leave it out at the first item.
96
+ - previousLabel: string (default Previous). The previous button's name.
97
+ - title: ReactNode. A line on the scrim above the media, e.g. who posted it.