@slashsuite/ui-react 0.11.3 → 0.12.1

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 (96) hide show
  1. package/README.md +14 -1
  2. package/agent-docs/components/app-shell.md +136 -0
  3. package/agent-docs/components/avatar-stack.md +64 -0
  4. package/agent-docs/components/avatar.md +76 -0
  5. package/agent-docs/components/badge.md +61 -0
  6. package/agent-docs/components/body-text.md +158 -0
  7. package/agent-docs/components/bottom-sheet.md +95 -0
  8. package/agent-docs/components/breadcrumbs.md +62 -0
  9. package/agent-docs/components/bullet-list.md +54 -0
  10. package/agent-docs/components/button.md +135 -0
  11. package/agent-docs/components/callout.md +86 -0
  12. package/agent-docs/components/card-grid.md +108 -0
  13. package/agent-docs/components/card.md +113 -0
  14. package/agent-docs/components/centered-layout.md +90 -0
  15. package/agent-docs/components/chat-composer.md +48 -0
  16. package/agent-docs/components/chat-message.md +61 -0
  17. package/agent-docs/components/chat-thread.md +49 -0
  18. package/agent-docs/components/checkbox.md +75 -0
  19. package/agent-docs/components/cluster.md +106 -0
  20. package/agent-docs/components/code-example.md +48 -0
  21. package/agent-docs/components/code.md +70 -0
  22. package/agent-docs/components/colour-scheme-toggle.md +92 -0
  23. package/agent-docs/components/container.md +50 -0
  24. package/agent-docs/components/copy-button.md +61 -0
  25. package/agent-docs/components/copy-line.md +54 -0
  26. package/agent-docs/components/date-field.md +103 -0
  27. package/agent-docs/components/date-range-picker.md +101 -0
  28. package/agent-docs/components/detail-layout.md +147 -0
  29. package/agent-docs/components/dialog.md +178 -0
  30. package/agent-docs/components/disclosure.md +66 -0
  31. package/agent-docs/components/divider.md +62 -0
  32. package/agent-docs/components/docs-layout.md +160 -0
  33. package/agent-docs/components/drawer.md +128 -0
  34. package/agent-docs/components/empty-state.md +67 -0
  35. package/agent-docs/components/field-dialog.md +97 -0
  36. package/agent-docs/components/field.md +68 -0
  37. package/agent-docs/components/fieldset.md +82 -0
  38. package/agent-docs/components/file-drop.md +52 -0
  39. package/agent-docs/components/form-layout.md +141 -0
  40. package/agent-docs/components/form-row.md +93 -0
  41. package/agent-docs/components/full-bleed-layout.md +116 -0
  42. package/agent-docs/components/headings.md +101 -0
  43. package/agent-docs/components/hero.md +59 -0
  44. package/agent-docs/components/icon-button.md +92 -0
  45. package/agent-docs/components/icon.md +66 -0
  46. package/agent-docs/components/image.md +64 -0
  47. package/agent-docs/components/input.md +83 -0
  48. package/agent-docs/components/kbd.md +38 -0
  49. package/agent-docs/components/key-value-list.md +81 -0
  50. package/agent-docs/components/lightbox.md +97 -0
  51. package/agent-docs/components/list-layout.md +154 -0
  52. package/agent-docs/components/list-row.md +116 -0
  53. package/agent-docs/components/loading.md +69 -0
  54. package/agent-docs/components/markdown.md +51 -0
  55. package/agent-docs/components/media-tile.md +97 -0
  56. package/agent-docs/components/menu.md +103 -0
  57. package/agent-docs/components/meta-list.md +69 -0
  58. package/agent-docs/components/morph.md +128 -0
  59. package/agent-docs/components/navigation-progress.md +56 -0
  60. package/agent-docs/components/outline-region.md +63 -0
  61. package/agent-docs/components/page-fade.md +116 -0
  62. package/agent-docs/components/page-header.md +93 -0
  63. package/agent-docs/components/pagination.md +64 -0
  64. package/agent-docs/components/pill.md +104 -0
  65. package/agent-docs/components/progress-bar.md +66 -0
  66. package/agent-docs/components/prose-layout.md +87 -0
  67. package/agent-docs/components/prose.md +41 -0
  68. package/agent-docs/components/radio-group.md +74 -0
  69. package/agent-docs/components/scroll-strip.md +48 -0
  70. package/agent-docs/components/segmented-control.md +133 -0
  71. package/agent-docs/components/select.md +65 -0
  72. package/agent-docs/components/show.md +120 -0
  73. package/agent-docs/components/side-column.md +70 -0
  74. package/agent-docs/components/sidebar-layout.md +134 -0
  75. package/agent-docs/components/site-footer.md +63 -0
  76. package/agent-docs/components/site-search.md +67 -0
  77. package/agent-docs/components/sortable-list.md +107 -0
  78. package/agent-docs/components/split-bar.md +54 -0
  79. package/agent-docs/components/stack.md +197 -0
  80. package/agent-docs/components/stacked-bar.md +88 -0
  81. package/agent-docs/components/stat-tile.md +69 -0
  82. package/agent-docs/components/status-pages.md +105 -0
  83. package/agent-docs/components/steps.md +74 -0
  84. package/agent-docs/components/sticky-bar.md +51 -0
  85. package/agent-docs/components/switch.md +79 -0
  86. package/agent-docs/components/table.md +373 -0
  87. package/agent-docs/components/tabs.md +180 -0
  88. package/agent-docs/components/text-link.md +105 -0
  89. package/agent-docs/components/textarea.md +51 -0
  90. package/agent-docs/components/timeline.md +79 -0
  91. package/agent-docs/components/toast.md +86 -0
  92. package/agent-docs/components/trend-chart.md +61 -0
  93. package/agent-docs/components/video.md +44 -0
  94. package/agent-docs/llms.txt +155 -0
  95. package/package.json +6 -3
  96. package/skills/uislash/SKILL.md +20 -0
@@ -0,0 +1,90 @@
1
+ ## CenteredLayout
2
+
3
+ Group: Page layouts
4
+
5
+ When to use: Sign-in, a landing page, or a not-found or error page.
6
+
7
+ ### The one right way
8
+ Sign-in, landing, not-found and error pages are one narrow card, centred.
9
+ ```tsx
10
+ import { Button, CenteredLayout, Field, Input } from "@slashsuite/ui-react";
11
+
12
+ <CenteredLayout title="Sign in" description="Use your Hack Cove account.">
13
+ <Field label="Email" htmlFor="do-page-email">
14
+ <Input id="do-page-email" type="email" placeholder="you@example.com" />
15
+ </Field>
16
+ <Button>Continue</Button>
17
+ </CenteredLayout>
18
+ ```
19
+
20
+ ### Full page
21
+ A whole sign-in page: the shell with its brand and nav, then one narrow card, centred.
22
+ ```tsx
23
+ import {
24
+ AppShell,
25
+ Button,
26
+ CenteredLayout,
27
+ Field,
28
+ Input,
29
+ Tabs,
30
+ } from "@slashsuite/ui-react";
31
+
32
+ <AppShell
33
+ brand={<a href="#">Hack Cove</a>}
34
+ nav={
35
+ <Tabs
36
+ label="Main"
37
+ items={[
38
+ { label: "Quotes", href: "#quotes", selected: true },
39
+ { label: "Clients", href: "#clients" },
40
+ ]}
41
+ />
42
+ }
43
+ >
44
+ <CenteredLayout title="Sign in" description="Use your Hack Cove account.">
45
+ <Field label="Email" htmlFor="full-page-email">
46
+ <Input id="full-page-email" type="email" placeholder="you@example.com" />
47
+ </Field>
48
+ <Button>Continue</Button>
49
+ </CenteredLayout>
50
+ </AppShell>
51
+ ```
52
+
53
+ ### Do
54
+ - Give it a `title` and a `description`; the `children` are the card's content: a `Field` or two and a `Button`.
55
+ - It is the one layout that does not share the start edge: it is centred, at a fixed offset from the top.
56
+ - A form inside the app is `FormLayout`, not this.
57
+ - The ready-made status pages (not found, forbidden, offline, error, maintenance) are already built on it.
58
+ - `mark` is drawn first in the card, above the title: a large status numeral, as the status pages draw. It is not a heading.
59
+
60
+ ### Don't
61
+ `FormLayout` is for a form inside the app: its wide column hangs off the left edge, which is wrong for a sign-in. Use `CenteredLayout`.
62
+ ```tsx
63
+ import { Button, Field, FormLayout, Input } from "@slashsuite/ui-react";
64
+
65
+ <FormLayout
66
+ title="Sign in"
67
+ description="Use your Hack Cove account."
68
+ actions={<Button type="submit">Continue</Button>}
69
+ >
70
+ <Field label="Email" htmlFor="dont-page-email">
71
+ <Input id="dont-page-email" type="email" placeholder="you@example.com" />
72
+ </Field>
73
+ </FormLayout>
74
+ ```
75
+
76
+ ### Accessibility
77
+ - The title is the page's `h1`.
78
+ - The card is a plain `div`, not a landmark; the shell's `main` holds it.
79
+ - Give each control a `Field`, so every input has a label.
80
+
81
+ ### Props
82
+ ### CenteredLayout
83
+ A narrow card (`max-w-md`) centred in the Container at a fixed offset from the top, for sign-in, landing, not-found and error pages. The one layout that does not share the start edge. While `loading` it owns the wait and passes it to everything inside, the header too.
84
+ - description: ReactNode. A muted line under the title.
85
+ - id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
86
+ - loading: boolean. The data is not here yet: an empty slot draws a bone of its shape, a filled one draws as usual.
87
+ Left out, the part takes the nearest loading layout's or part's; `false` opts it out inside one.
88
+ - loadingLabel: string (default Loading). What a screen reader hears while this part is loading, when its own `loading` is set.
89
+ - mark: ReactNode. Drawn first in the card, above the title, e.g. a large status numeral. Not a heading.
90
+ - title: ReactNode (required). The card's `h1`.
@@ -0,0 +1,48 @@
1
+ ## ChatComposer
2
+
3
+ Group: Content
4
+
5
+ When to use: The foot of a chat, under the `ChatThread`.
6
+
7
+ ### The one right way
8
+ While a reply arrives, `busy` keeps the box open and offers Stop.
9
+ ```tsx
10
+ import { ChatComposer } from "@slashsuite/ui-react";
11
+
12
+ <ChatComposer label="Message" busy onSend={() => undefined} onStop={() => undefined} />
13
+ ```
14
+
15
+ ### Do
16
+ - Give it a `label` and `onSend`. It keeps its own text and calls `onSend` with it trimmed, then clears the box.
17
+ - Enter sends and Shift+Enter is a newline. Empty or whitespace-only text does not send, and Send is disabled.
18
+ - `busy` is a reply on its way: the button is Stop and calls `onStop`, Enter does not send, and the reader can go on typing. With no `onStop`, Send stays disabled and no Stop is drawn.
19
+ - `disabled` is for a chat that cannot take a message at all; it disables the box and the button.
20
+ - `sendLabel` and `stopLabel` are the button's words, Send and Stop by default.
21
+
22
+ ### Don't
23
+ `disabled` during a reply takes the box away from a reader mid-thought, with no way to stop the reply.
24
+ ```tsx
25
+ import { ChatComposer } from "@slashsuite/ui-react";
26
+
27
+ <ChatComposer label="Message" disabled onSend={() => undefined} />
28
+
29
+ ```
30
+
31
+ ### Accessibility
32
+ - `label` is the box's name, in a visually hidden `<label>`.
33
+ - Enter during an IME composition commits the text and does not send.
34
+ - After Send is pressed the focus goes back to the box, since the button has just been disabled under it.
35
+
36
+ ### Props
37
+ ### ChatComposer
38
+ The box a message is typed into, with its button beside it. It keeps its own text. Enter sends the trimmed text and clears the box; Shift+Enter is a newline; empty or whitespace-only text does not send. While `busy` a reply is on its way: the button is Stop, Enter does not send, and typing carries on with the text kept for the next send.
39
+ - busy: boolean (default false). A reply is on its way: the button is Stop and Enter does not send. With no `onStop`, the button
40
+ stays a disabled Send and no Stop is drawn.
41
+ - disabled: boolean (default false). Disables the box and the button. For a chat that cannot take a message at all, not for a reply in flight: that is `busy`.
42
+ - id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
43
+ - label: string (required). The box's name for assistive tech; it is not drawn.
44
+ - onSend: (text: string) => void (required). Called with the trimmed text.
45
+ - onStop: (() => void). Called when the reader presses Stop.
46
+ - placeholder: string. The hint inside the empty box.
47
+ - sendLabel: string (default Send). The button's word, for sending.
48
+ - stopLabel: string (default Stop). The button's word, while `busy`.
@@ -0,0 +1,61 @@
1
+ ## ChatMessage
2
+
3
+ Group: Content
4
+
5
+ When to use: A message from a person or an assistant inside a `ChatThread`.
6
+
7
+ ### The one right way
8
+ A reply still arriving says so with `streaming`: the caret, and `aria-busy` for a screen reader.
9
+ ```tsx
10
+ import { ChatMessage } from "@slashsuite/ui-react";
11
+
12
+ <ChatMessage role="assistant" author="Helper" streaming>
13
+ Start by sweating the leeks in
14
+ </ChatMessage>
15
+ ```
16
+
17
+ ### Do
18
+ - `role` picks the side: `user` on the right, `assistant` on the left.
19
+ - `author` is required and is for a screen reader. To show a sender and a time, pass them, already formatted, as `meta`, the small line above the bubble.
20
+ - The children are the body and it does not call `Markdown` for you: pass plain text, which keeps its line breaks, or a `Markdown` or an `Image`.
21
+ - `actions` is a row under the bubble on the message's own side: copy, retry, a row of reaction `Pill`s. It is always in view, never only on hover.
22
+ - `streaming` marks a reply still arriving, with a caret after the body. With no children it draws the bubble with the caret alone: the pending state.
23
+
24
+ ### Don't
25
+ Dots typed into the body say nothing to a screen reader, and are read out as text when it is done.
26
+ ```tsx
27
+ import { ChatMessage } from "@slashsuite/ui-react";
28
+
29
+ <ChatMessage role="assistant" author="Helper">
30
+ Start by sweating the leeks in...
31
+ </ChatMessage>
32
+ ```
33
+
34
+ A button in the body reads as part of what was said, and is copied with it.
35
+ ```tsx
36
+ import { Button, ChatMessage, Text } from "@slashsuite/ui-react";
37
+
38
+ <ChatMessage role="assistant" author="Helper">
39
+ <Text>The pantry did not answer.</Text>
40
+ <Button size="sm" variant="ghost">
41
+ Retry
42
+ </Button>
43
+ </ChatMessage>
44
+ ```
45
+
46
+ ### Accessibility
47
+ - It is an `<article>`. `author` comes first in the DOM, visually hidden, because alignment tells a screen reader nothing.
48
+ - `streaming` sets `aria-busy`. The caret is `aria-hidden`, and it pulses only for a reader who has not asked for reduced motion.
49
+ - A message is not announced as it arrives: that is the `ChatThread`'s `announce`.
50
+
51
+ ### Props
52
+ ### ChatMessage
53
+ One message in a chat: a bubble on the sender's side, with an optional line above it and a row of actions under it. `children` is the body as the caller wants it (plain text, which keeps its line breaks, a `Markdown`, an `Image`). `streaming` marks a reply still arriving; with no children it draws the caret alone, the pending state.
54
+ - actions: ReactNode. A row under the bubble on the message's own side: copy, retry, a row of reaction `Pill`s.
55
+ - author: string (required). Who sent it, read first by a screen reader and drawn nowhere: alignment alone tells a screen reader nothing. Show a sender with `meta`.
56
+ - children: ReactNode. The body. It may be empty while `streaming`.
57
+ - id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
58
+ - meta: ReactNode. A small line above the bubble: a sender and a time, already formatted.
59
+ - role: "user" | "assistant" (required). Whose side it sits on: `user` on the right on the inset fill, `assistant` on the left on the surface.
60
+ - streaming: boolean (default false). The reply is still arriving: sets `aria-busy` and draws a caret after the body, which pulses
61
+ unless the reader asks for reduced motion.
@@ -0,0 +1,49 @@
1
+ ## ChatThread
2
+
3
+ Group: Content
4
+
5
+ When to use: Holding the messages and tool calls of a chat, an agent log or a message thread.
6
+
7
+ ### The one right way
8
+ Nothing to show yet is the thread's `empty`, which goes away with the first message.
9
+ ```tsx
10
+ import { ChatThread, EmptyState } from "@slashsuite/ui-react";
11
+
12
+ <ChatThread label="New chat" empty={<EmptyState title="No messages yet" level={3} />} />
13
+ ```
14
+
15
+ ### Do
16
+ - Name it with `label`. Its children are `ChatMessage`s and anything else that belongs in the conversation (a tool call is a bordered `Disclosure` whose `summary` names the tool and carries a `Pill` for how it went), in order, oldest first.
17
+ - It starts at the bottom and stays there as content grows, a streamed reply included. When the reader scrolls up it leaves them where they are; scrolling back to the bottom (within 32px) follows again. You write no scrolling of your own.
18
+ - `height` caps it: `sm`, `md` (default) or `lg`. `fill` takes the height of a parent that sets one, for a whole-page chat.
19
+ - `empty` is what it draws with no children, an `EmptyState`, at its full size.
20
+ - Set `announce` when a message is finished ("Helper replied"), not on each token.
21
+ - An approval is a `Callout` with `Button`s in its `actions`, placed in the thread, not a component of its own. So is a notice beside a message.
22
+ - It knows nothing about where messages come from: no fetch, no AI SDK. Map your own messages to its children.
23
+
24
+ ### Don't
25
+ A made-up message is not an empty state: a screen reader reads it as something somebody said.
26
+ ```tsx
27
+ import { ChatMessage, ChatThread } from "@slashsuite/ui-react";
28
+
29
+ <ChatThread label="New chat">
30
+ <ChatMessage role="assistant" author="Helper">
31
+ No messages yet
32
+ </ChatMessage>
33
+ </ChatThread>
34
+ ```
35
+
36
+ ### Accessibility
37
+ - The box is `role="region"` named by `label`, with `tabIndex={0}`, so a keyboard can reach it and scroll it with the arrow keys. Use a different `label` for each thread on a page.
38
+ - It is deliberately not `role="log"` and has no `aria-live`: a live region round streamed text reads every token aloud. `announce` goes in a visually hidden `aria-live="polite"` element beside the box.
39
+ - Following the bottom is instant, never a smooth scroll.
40
+
41
+ ### Props
42
+ ### ChatThread
43
+ The scrolling box of a chat: its children are the messages, tool cards and anything else, a gap apart. It follows the newest content unless the reader has scrolled up. It is a named region and a tab stop, so a keyboard can scroll it. It is deliberately not a live region, which would read every streamed token aloud: set `announce` when a message is finished.
44
+ - announce: string. Text a screen reader reads out politely when it changes. Set it when a message is finished, not on each token.
45
+ - empty: ReactNode. Drawn instead when there are no children: an `EmptyState`.
46
+ - height: "sm" | "md" | "lg" | "fill" (default md). The tallest it gets before it scrolls: `sm` 20rem, `md` 28rem, `lg` 40rem. `fill` takes the
47
+ height of a parent that sets one.
48
+ - id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
49
+ - label: string (required). Names the region.
@@ -0,0 +1,75 @@
1
+ ## Checkbox
2
+
3
+ Group: Forms
4
+
5
+ When to use: An on/off option the person ticks: a setting, a filter, a row to select.
6
+
7
+ ### The one right way
8
+ A yes or no is a `Checkbox` with its `label`: the whole label is the click target.
9
+ ```tsx
10
+ import { Checkbox } from "@slashsuite/ui-react";
11
+
12
+ <Checkbox label="Email me when a shop I follow posts" defaultChecked />
13
+
14
+ ```
15
+
16
+ ### Do
17
+ - Give a `Checkbox` a `label`; the whole label is the click target.
18
+ - In a table cell leave the `label` out, use `size="sm"` and name the box with `aria-label`. `size="lg"` matches a large `Input`.
19
+ - A `hint` is a muted line under the label for an option that needs a sentence, and an `error` replaces it in red. The box always sits on the label's first line.
20
+ - A setting that takes effect the moment it is flipped, usually by saving it, is a `Switch`. A `Checkbox` is ticked and then submitted with the form.
21
+ - Choosing one of several is a `RadioGroup`, a `Select` or a `SegmentedControl`, not a row of checkboxes.
22
+ - Several checkboxes for one question go in a `Fieldset`.
23
+ - Say why the box cannot change with `disabledReason`.
24
+
25
+ ### Don't
26
+ - Do not wrap a `Checkbox` in a `Field`; it is its own label.
27
+
28
+ A checkbox with the words beside it, not in it, names nothing: clicking the words does nothing.
29
+ ```tsx
30
+ import { Checkbox, Cluster, Text } from "@slashsuite/ui-react";
31
+
32
+ <Cluster gap="sm">
33
+ <Checkbox />
34
+ <Text>Email me when a shop I follow posts</Text>
35
+ </Cluster>
36
+ ```
37
+
38
+ Words beside a box in a table cell crowd the row and repeat the row's own name. Leave the `label` out and name the box with `aria-label`.
39
+ ```tsx
40
+ import { Checkbox } from "@slashsuite/ui-react";
41
+
42
+ <Checkbox label="Select row" />
43
+
44
+ ```
45
+
46
+ A bare `disabled` box drops out of the tab order and never says why.
47
+ ```tsx
48
+ import { Checkbox } from "@slashsuite/ui-react";
49
+
50
+ <Checkbox label="Email the team" disabled />
51
+
52
+ ```
53
+
54
+ ### Accessibility
55
+ - A native `<input type="checkbox">` inside a `<label>`, so clicking the text toggles it and the label is its name.
56
+ - A bare box has no name of its own: `aria-label` is required.
57
+ - A `hint` or an `error` is the box's `aria-describedby`, added to any you pass; an `error` is `role="alert"` and marks the box `aria-invalid`.
58
+ - `disabledReason` sets `aria-disabled` and keeps the box in the tab order; a click 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).
59
+ - The focus ring comes from the component.
60
+
61
+ ### Props
62
+ ### Checkbox
63
+ A checkbox with its label. It is a real `<input type="checkbox">`, drawn by the library (an empty outlined box, then a filled accent one with a check mark) so it reads the same in every theme and browser. Every prop but the label goes on the input, and `ref` reaches it. `size="sm"` is `text-xs` and a smaller box, for a dense row; `size="lg"` is `text-base` and a larger box. Leave `label` out for a bare box in a table cell, and name it with `aria-label`. The box sits on the label's first line, so a label that wraps reads from the box. `hint` is a muted line under the label that says more, like a `Field`'s; `error` replaces it with a red line (`role="alert"`) and makes the box `aria-invalid`. The note is the box's `aria-describedby`. `onChange` gets the new checked state; take `checked` with it, or `defaultChecked` alone. While `loading` the label is drawn and the box is a bone of its size.
64
+ - disabledReason: string. Why the box cannot be changed: it dims and is blocked (`aria-disabled`; a click and Space
65
+ change nothing) while it stays in the tab order, and the reason is its tooltip on hover,
66
+ keyboard focus and a tap, read out as its description.
67
+ - error: ReactNode. Replaces the hint with a red line (`role="alert"`) and makes the box `aria-invalid`.
68
+ - hint: ReactNode. A muted line under the label that says more. It is the box's `aria-describedby`.
69
+ - label: ReactNode. The text beside the box. Leave it out for a bare box (a table cell) and name it with `aria-label`.
70
+ - loading: boolean. The data is not here yet: an empty slot draws a bone of its shape, a filled one draws as usual.
71
+ Left out, the part takes the nearest loading layout's or part's; `false` opts it out inside one.
72
+ - loadingLabel: string (default Loading). What a screen reader hears while this part is loading, when its own `loading` is set.
73
+ - onChange: ((checked: boolean) => void). Called with the new checked state when the person ticks or clears the box.
74
+ - ref: Ref<HTMLInputElement>. The `<input>`, for focus control.
75
+ - size: "sm" | "md" | "lg" (default md). The label's text size and the box with it.
@@ -0,0 +1,106 @@
1
+ ## Cluster
2
+
3
+ Group: Layout
4
+
5
+ When to use: Items in a line that are not buttons: a label beside a value, an input beside its actions, a row of pills.
6
+
7
+ ### The one right way
8
+ The one item that should take the room left goes in `ClusterGrow`: the input fills the row and the buttons keep their size.
9
+ ```tsx
10
+ import { Button, Cluster, ClusterGrow, Input } from "@slashsuite/ui-react";
11
+
12
+ <Cluster>
13
+ <ClusterGrow>
14
+ <Input aria-label="Search" placeholder="Search invoices" />
15
+ </ClusterGrow>
16
+ <Button>Search</Button>
17
+ </Cluster>
18
+ ```
19
+
20
+ ### Do
21
+ - `gap` is `xs`, `sm` (default) or `md`, the first steps of the `Stack` scale: the items of a row sit closer than the blocks of a column. The `Size` type lists every default that is not `md`.
22
+ - `align` is the cross axis: `center` (default), `baseline` for mixed text sizes, `start` or `end`. `justify` is the main axis: `start` (default), `between` for the two ends, `end`.
23
+ - The items flow onto more lines when the row runs out of room; `wrap={false}` keeps them on one line.
24
+ - Wrap the one item that should fill the row in `ClusterGrow`; it can shrink to nothing, so a long value truncates and the others stay.
25
+ - An empty `ClusterGrow` is a spacer: what follows it goes to the end.
26
+ - A row of buttons is a `ButtonGroup`, which wraps on a phone and can pin an item to the end. Use `Cluster` for every other row.
27
+ - `justify="between"` is for two items; with more, the middle one floats, so use a spacer.
28
+ - `as="ul"` or `as="ol"` makes a wrapping row of like things (tags, chips) a list. Write each item as an `<li>`, as in a `Stack` list; the Cluster does not wrap them, and a `ClusterGrow` does not belong in a list.
29
+
30
+ ### Don't
31
+ Without `ClusterGrow` the input keeps a fixed width and the rest of the row sits empty. Wrap the input in `ClusterGrow` instead.
32
+ ```tsx
33
+ import { Button, Cluster, Input } from "@slashsuite/ui-react";
34
+
35
+ <Cluster>
36
+ <Input aria-label="Search" placeholder="Search invoices" width="sm" />
37
+ <Button>Search</Button>
38
+ </Cluster>
39
+ ```
40
+
41
+ `Cluster` is for every other row; a row of buttons in it does not wrap and has no end slot.
42
+ ```tsx
43
+ import { Button, Cluster } from "@slashsuite/ui-react";
44
+
45
+ <Cluster>
46
+ <Button>Send</Button>
47
+ <Button variant="outline">Download</Button>
48
+ <Button variant="outline">Back</Button>
49
+ </Cluster>
50
+ ```
51
+
52
+ `justify="between"` spreads three items evenly, so the middle one floats away from the group it belongs to.
53
+ ```tsx
54
+ import { Button, Cluster, Text } from "@slashsuite/ui-react";
55
+
56
+ <Cluster justify="between">
57
+ <Text strong>Invoice 1042</Text>
58
+ <Button size="sm" variant="outline">
59
+ Edit
60
+ </Button>
61
+ <Button size="sm" variant="outline" tone="danger">
62
+ Remove
63
+ </Button>
64
+ </Cluster>
65
+ ```
66
+
67
+ The same pills in a plain Cluster are three loose items: no list, no count.
68
+ ```tsx
69
+ import { Cluster, Pill } from "@slashsuite/ui-react";
70
+
71
+ <Cluster>
72
+ <Pill>Vintage</Pill>
73
+ <Pill>Books</Pill>
74
+ <Pill>Vinyl</Pill>
75
+ </Cluster>
76
+ ```
77
+
78
+ ### Accessibility
79
+ - A `Cluster` is a `div` (or a `span` with `as="span"`) and adds no role; the reading and tab order is the source order of its children.
80
+ - A `ul` or `ol` Cluster is a list a screen reader counts; give it an `aria-label` when more than one list is on the page.
81
+ - `ClusterGrow` is a `div` too: put the labelled control inside it, with its own `aria-label` or `Field`.
82
+
83
+ ### Props
84
+ ### Cluster
85
+ A horizontal row of items a fixed `gap` apart (`sm` by default): the row counterpart of `Stack`. `align` is the cross axis (`center` default, `baseline` for mixed text sizes, `start`, `end`) and `justify` the main one (`start` default, `between` to push the first and last items to the two ends, `end`). The items flow onto further lines when the row runs out of room; `wrap={false}` keeps them on one line. Put one `ClusterGrow` around the item that takes the room left over, an input beside its buttons, say. An empty `ClusterGrow` is a spacer that pushes what follows it to the end. `ButtonGroup` is the row for buttons; use `Cluster` for any other row. `as="span"` is for a row inside phrasing content, such as a `PageHeader` description (a `<p>`): its items must be phrasing content too, so no `ClusterGrow`. `as="ul"` or `as="ol"` is a wrapping list with no markers (tags, chips): as in a `Stack` list the Cluster does not wrap its children, so each child is an `<li>` the caller writes, and a `ClusterGrow` (a `div`) does not belong in it.
86
+ - align: "center" | "baseline" | "end" | "start" (default center). The cross axis: `center`, `baseline` (for mixed text sizes), `start` or `end`.
87
+ - as: "div" | "ol" | "span" | "ul" (default div). The element: `div`, `span` for a row inside a `<p>` or other phrasing content, or `ul` or `ol`
88
+ for a list (no markers; each child is an `<li>`).
89
+
90
+ In a `span` the items must be phrasing content, so no `ClusterGrow`.
91
+ - gap: "sm" | "md" | "xs" (default sm). The space between items: the first steps of the gap scale. Its default is one of those the
92
+ `Size` type lists as not `md`.
93
+ - id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
94
+ - justify: "end" | "start" | "between" (default start). The main axis: `start`, `between` (the first and last items at the two ends) or `end`.
95
+ - wrap: boolean (default true). Let the items flow onto further lines when the row runs out of room. `false` keeps them on one line.
96
+
97
+ ### ClusterGrow
98
+ The one child of a `Cluster` (or of a `Stack` with `rowFrom`) that grows to the room left in the row. By default it can shrink to nothing (`min-w-0`), so the items beside it stay on the line and a long value truncates instead of pushing them out. With `minWidth` it instead keeps that width (`sm` 12rem, `md` 17rem) and, in a `Cluster` with `wrap`, drops onto the next line when the room left is narrower, rather than being squashed. Empty, it is a spacer.
99
+ - id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
100
+ - minWidth: "sm" | "md". The narrowest it gets: `sm` 12rem or `md` 17rem. In a `Cluster` with `wrap` it wraps under the other items below this width. Left out, it shrinks to nothing.
101
+
102
+ ### Types
103
+ - ClusterAlign: `"center" | "baseline" | "start" | "end"`. Where a `Cluster`'s items sit across the row: `center`, `baseline` for mixed text sizes, `start` or `end`.
104
+ - ClusterGap: `"sm" | "md" | "xs"`. The first three steps of `Stack`'s scale: `xs` between items in a line, `sm` inside a group, `md` between blocks.
105
+ - ClusterGrowMinWidth: `"sm" | "md"`. The narrowest a `ClusterGrow` gets before the row wraps: `sm` or `md`.
106
+ - ClusterJustify: `"start" | "end" | "between"`. Where a `Cluster`'s items sit along the row: `start`, `end`, or `between` to spread them to both ends.
@@ -0,0 +1,48 @@
1
+ ## CodeExample
2
+
3
+ Group: Text
4
+
5
+ When to use: Documentation that shows a part and its source together.
6
+
7
+ ### The one right way
8
+ `CodeExample` frames a rendered part with the code that makes it, in one box.
9
+ ```tsx
10
+ import { Button, CodeExample } from "@slashsuite/ui-react";
11
+
12
+ <CodeExample code={'<Button variant="primary">Save</Button>'}>
13
+ <Button variant="primary">Save</Button>
14
+ </CodeExample>
15
+ ```
16
+
17
+ ### Do
18
+ - Put the rendered part in `children` and its source in `code`, a string with the newlines kept.
19
+ - `caption` is one note on the example, the last band of the frame.
20
+ - Side by side in a grid, each frame is its own height, so do not pad the previews to match.
21
+ - A wide preview or a long line of code scrolls inside the frame under a thin themed scrollbar; it does not widen the page.
22
+ - `copy` adds a button beside the code that copies the code, not the preview. It needs client JS; on a page rendered to static HTML, inline `copyScript` once (see CopyButton).
23
+ - Inside a `Prose` the preview stays on the app scale, so the part looks as it does on an app screen; the caption is outside it.
24
+ - Only for documentation. A command to copy is a `CopyLine`, and code alone is a `CodeBlock`.
25
+
26
+ ### Don't
27
+ A loose preview with a `CodeBlock` under it is two unrelated things: no shared frame, and they drift apart.
28
+ ```tsx
29
+ import { Button, CodeBlock, Stack } from "@slashsuite/ui-react";
30
+
31
+ <Stack gap="sm">
32
+ <Button variant="primary">Save</Button>
33
+ <CodeBlock>{'<Button variant="primary">Save</Button>'}</CodeBlock>
34
+ </Stack>
35
+ ```
36
+
37
+ ### Accessibility
38
+ - A `<figure>` holds the preview and the code in `<pre><code>`; `caption` is its `<figcaption>`.
39
+ - `aria-*` and `data-*` go on the figure.
40
+
41
+ ### Props
42
+ ### CodeExample
43
+ One framed example: the rendered `children` on top and the `code` that makes them attached underneath, in a single bordered box with one divider between. With `copy`, a copy button beside the code copies it exactly as given (client JS; off by default). An optional `caption` is the frame's last band. The code is React, so it is coloured as TSX. The preview is its own height, never padded to match a neighbour, down to a shared minimum so two frames side by side start alike. A wide preview or a long line of code scrolls inside the frame, under a thin themed scrollbar, instead of widening the page or wrapping. Inside a `Prose` the preview stays on the app scale, so a demo looks as the component does anywhere else; the caption is outside it.
44
+ - caption: ReactNode. One note on the example, under the code.
45
+ - code: string (required). The source shown under the preview, newlines kept.
46
+ - copy: boolean (default false). A copy button beside the code. On a page rendered to static HTML without hydration, inline
47
+ `copyScript` and it works there too.
48
+ - id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
@@ -0,0 +1,70 @@
1
+ ## Code
2
+
3
+ Group: Text
4
+
5
+ When to use: A command, name or path inside a sentence is `Code`; several lines of code are a `CodeBlock`.
6
+
7
+ ### Use instead
8
+ - CopyButton (copy-button.md): Neither a `CopyLine` nor `copy` on a `CodeBlock` or `CodeExample` fits.
9
+ - CopyLine (copy-line.md): The text to copy is one line, such as an install command.
10
+
11
+ ### The one right way
12
+ `Code` is one short run of code inside a sentence: a command, a name, a path.
13
+ ```tsx
14
+ import { Code, Text } from "@slashsuite/ui-react";
15
+
16
+ <Text>
17
+ Run <Code>bun install</Code> once, then <Code>bunx nx run-many -t test</Code> to check it.
18
+ </Text>
19
+ ```
20
+
21
+ ### Do
22
+ - Use `Code` for one short run inside a sentence. It takes the text colour and size around it, and keeps no line breaks.
23
+ - Use `CodeBlock` for several lines. Give the text as `children`, or as `lines` with one entry per line.
24
+ - `label` names the language or file (`bash`, `css`) in a caption above the code; `language` says what to colour, from `tsx`, `ts`, `js`, `json`, `bash`, `console`, `css`, `html` and `yaml`.
25
+ - A shell session is `console`: a line starting with `$ ` is a command, coloured as bash, and every other line is output. With `copy`, only the commands are copied, without the `$ `.
26
+ - A line a reader copies is a `CopyLine`, not a one-line `CodeBlock`. A rendered part shown with its code is a `CodeExample`.
27
+ - Without a `language` the code is one colour (`text`), which suits an error or a log.
28
+ - A long line wraps, so a command is never cut off and still copies as one line. `overflow="scroll"` keeps lines whole and scrolls them sideways under a thin scrollbar in the theme's colour, for code whose layout matters.
29
+ - `copy` adds a copy button beside the code. It needs client JS; on a page rendered to static HTML, inline `copyScript` once (see CopyButton).
30
+
31
+ ### Don't
32
+ `Code` is inline, so its line breaks collapse into one run. Several lines are a `CodeBlock`.
33
+ ```tsx
34
+ import { Code, Text } from "@slashsuite/ui-react";
35
+
36
+ <Text>
37
+ <Code>{"bun install\nbun run build\nbun run test"}</Code>
38
+ </Text>
39
+ ```
40
+
41
+ One short line a reader copies is a `CopyLine`, the smaller box. A one-line `CodeBlock` is for a command that needs a `label` or colour.
42
+ ```tsx
43
+ import { CodeBlock } from "@slashsuite/ui-react";
44
+
45
+ <CodeBlock language="bash">bun add @slashsuite/ui-react</CodeBlock>
46
+
47
+ ```
48
+
49
+ ### Accessibility
50
+ - `Code` renders a `<code>`. `CodeBlock` renders a `<figure>` with the code in `<pre><code>`, so the line breaks are kept.
51
+ - `label` is the `<figcaption>`, which names the figure.
52
+ - `CodeBlock` takes `aria-*` and `data-*` on its figure.
53
+
54
+ ### Props
55
+ ### Code
56
+ Inline code: mono, on a subtle inset background. It takes the surrounding text colour and size (a touch smaller, for the mono face).
57
+ - id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
58
+
59
+ ### CodeBlock
60
+ A block of code: mono, in a bordered inset box. No client JS unless `copy` adds a copy button beside the code, which copies it exactly as given. `language` colours it: `tsx`, `ts`, `js`, `json`, `bash`, `console`, `css`, `html` or `yaml`. `console` is a shell session: a line starting with `$ ` is a command (coloured as bash, its `$ ` dimmed and not selectable) and any other line is output; with `copy` only the commands are copied, without the `$ `. `label` names the language or file (`bash`, `css`) in a caption above the code. `text` (the default) leaves the code in one colour, for a block that is not a language. Give the text as `children` or as `lines`. Long lines wrap, so nothing is cut off and a command stays one copyable line; `overflow="scroll"` keeps lines whole and scrolls them sideways under a thin themed scrollbar, for code whose layout matters. With `overflow="scroll"`, a strip wider than its box is a tab stop named by `label`, else "Code". Every other figure prop goes on the root `<figure>`. For one short line to copy, `CopyLine` is the smaller box.
61
+ - copy: boolean (default false). A copy button beside the code, which copies it exactly as given (a `console` block copies only
62
+ its commands). On a page rendered to static HTML without hydration, inline `copyScript` and it works there too.
63
+ - label: string. A caption above the code naming its language or file (`bash`, `theme.css`).
64
+ - language: "text" | "html" | "tsx" | "ts" | "js" | "json" | "bash" | "console" | "css" | "yaml" (default text). What the code is written in; `text` (the default) colours nothing.
65
+ - lines: string[]. The code as one array entry per line, in place of `children`.
66
+ - overflow: "wrap" | "scroll" (default wrap). What a line longer than the box does: `wrap` onto the next line (the default, nothing is cut
67
+ off), or `scroll` sideways inside the box.
68
+
69
+ ### Types
70
+ - CodeLanguage: `"text" | "tsx" | "ts" | "js" | "json" | "bash" | "console" | "css" | "html" | "yaml"`. The languages a `CodeBlock` colours; `text` is plain, and `console` marks the commands of a terminal session.
@@ -0,0 +1,92 @@
1
+ ## ColourSchemeToggle
2
+
3
+ Group: Actions
4
+
5
+ When to use: A site that offers both schemes: one toggle in the header or controls.
6
+
7
+ ### The one right way
8
+ One `ColourSchemeToggle` in the page header: it switches `<html>`, remembers the choice and shows the scheme you would switch to.
9
+ ```tsx
10
+ import { ColourSchemeToggle } from "@slashsuite/ui-react";
11
+
12
+ <ColourSchemeToggle />
13
+
14
+ ```
15
+
16
+ ### Do
17
+ - Use one `ColourSchemeToggle` per site. It switches `<html>` between light and dark and remembers the choice in `localStorage`.
18
+ - `size` is `sm`, `md` (default) or `lg`, the same squares as `IconButton`.
19
+ - Put `colourSchemeScript` inline in `<head>`, so the stored or system scheme is on `<html>` before first paint and neither scheme flashes the other. It knows only the `dark` class.
20
+ - A light theme with a class of its own passes `schemes`, as in `schemes={{ light: "my-light", dark: "dark" }}`; render the same class on `<html>` on the server with `schemeClass`, and leave the head script out.
21
+ - An app that knows the scheme on the server (from a cookie) passes it as `defaultValue`, sets `store={false}` and persists from `onChange`. It then leaves the head script out.
22
+
23
+ ### Don't
24
+ - Do not build a switch from your own buttons; the functions below are what the toggle itself calls.
25
+
26
+ Two hand-rolled buttons forget the choice, and nothing shows which scheme is on.
27
+ ```tsx
28
+ import { applyColourScheme, Button, ButtonGroup } from "@slashsuite/ui-react";
29
+
30
+ <ButtonGroup label="Colour scheme">
31
+ <Button variant="outline" size="sm" onClick={() => applyColourScheme("light")}>
32
+ Light
33
+ </Button>
34
+ <Button variant="outline" size="sm" onClick={() => applyColourScheme("dark")}>
35
+ Dark
36
+ </Button>
37
+ </ButtonGroup>
38
+ ```
39
+
40
+ Without `schemes` the toggle only adds and removes `dark`, so the light theme's own class is never put back.
41
+ ```tsx
42
+ import { ColourSchemeToggle } from "@slashsuite/ui-react";
43
+
44
+ <ColourSchemeToggle />
45
+
46
+ ```
47
+
48
+ ### Accessibility
49
+ - It is a button named `Switch to dark theme` or `Switch to light theme`, so the name says the action, and the icon is `aria-hidden`. The name follows the class on `<html>` through CSS before hydration, with no script; only the tooltip waits for the client.
50
+ - The icon shown is the scheme you would switch to: the moon on a light page, the sun on a dark one. It follows the class on `<html>` through CSS, so it is right on the first frame.
51
+ - `applyColourScheme` also sets `color-scheme` on `<html>`, so native controls and scrollbars follow.
52
+
53
+ ### Props
54
+ ### ColourSchemeToggle
55
+ A sun/moon button that switches `<html>` between light and dark and remembers the choice. It shows the scheme you would switch to. Pair it with `colourSchemeScript` in `<head>`, unless you pass `schemes` or `defaultValue`: the script knows only the `dark` class and the stored choice, so an app that sets the scheme itself leaves it out. An app whose light scheme has a class of its own passes `schemes` (`{ light: "my-light", dark: "dark" }`); the toggle swaps those classes, and `schemeClass` gives the same one for the server to render on `<html>`. An app that knows the scheme on the server (from a cookie) passes it as `defaultValue`, so the server markup, the hydrating client and the `<html>` class agree; persist a change from `onChange`. The icon and the button's accessible name follow the class on `<html>` through CSS (the name is two visually hidden "Switch to …" spans, one hidden by `display:none`), so even without `defaultValue` a dark page shows the sun and is named "Switch to light theme" from the first frame, with no script. Only the tooltip catches up once the client has hydrated. `store={false}` skips `localStorage`, for an app that keeps the choice in a server cookie and writes it from `onChange`. Every other button prop (`id`, `data-*`, `aria-*`) goes on the button.
56
+ - defaultValue: (ColourScheme & (string | number | readonly string[])) (default light). The scheme the server rendered. What the server and the hydrating client show; the real state follows right after.
57
+ - onChange: (scheme: ColourScheme) => void. Called with the new scheme after a click, for an app that persists the choice itself (a cookie).
58
+ - schemes: ColourSchemeClasses (default { light: "", dark: "dark" }). The class each scheme puts on `<html>`.
59
+ - size: "sm" | "md" | "lg" (default md). The button's height, as an `IconButton`'s.
60
+ - store: boolean (default true). Remember the choice in `localStorage`. `false` leaves persisting to `onChange`.
61
+
62
+ ### Types
63
+ - ColourScheme: `"light" | "dark"`. The two colour schemes a site switches between: `light` and `dark`.
64
+ - ColourSchemeClasses: `{ light: string; dark: string }`. The class each scheme puts on `<html>`: none for light and `dark` for dark, unless the app's theme says otherwise (a light theme with a scope class of its own).
65
+
66
+ ### Functions
67
+ - applyColourScheme: `applyColourScheme(scheme: ColourScheme, root?: HTMLElement, schemes?: ColourSchemeClasses): void`. Puts a scheme on `<html>`: its class, the other scheme's class taken off, and `color-scheme`.
68
+ ```tsx
69
+ button.addEventListener("click", () => {
70
+ const next = readColourScheme() === "dark" ? "light" : "dark";
71
+ applyColourScheme(next);
72
+ storeColourScheme(next);
73
+ });
74
+ ```
75
+ - schemeClass: `schemeClass(scheme: ColourScheme, schemes?: ColourSchemeClasses): string`. The class a scheme puts on `<html>`, for the server to render so the first paint is right; empty for the default light scheme.
76
+ ```tsx
77
+ <html className={schemeClass(scheme, { light: "my-light", dark: "dark" })}>
78
+ ```
79
+ - colourSchemeScript: `colourSchemeScript: string`. A string of JavaScript to inline in `<head>` before first paint: applies the stored scheme, else the system one.
80
+ ```tsx
81
+ <head>
82
+ <script dangerouslySetInnerHTML={{ __html: colourSchemeScript }} />
83
+ </head>
84
+ ```
85
+ - readColourScheme: `readColourScheme(fallback?: ColourScheme): ColourScheme`. The stored choice, else the system preference, with a fallback (default light) when neither is available, as on the server.
86
+ ```tsx
87
+ const scheme = readColourScheme(); // the stored choice, else the system's, else light
88
+ ```
89
+ - storeColourScheme: `storeColourScheme(scheme: ColourScheme): void`. Remembers a scheme in `localStorage` for the next visit; a storage error is swallowed.
90
+ ```tsx
91
+ storeColourScheme(next); // read back on the next visit
92
+ ```