@slashsuite/ui-react 0.12.0 → 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.
- package/README.md +12 -0
- package/agent-docs/components/app-shell.md +136 -0
- package/agent-docs/components/avatar-stack.md +64 -0
- package/agent-docs/components/avatar.md +76 -0
- package/agent-docs/components/badge.md +61 -0
- package/agent-docs/components/body-text.md +158 -0
- package/agent-docs/components/bottom-sheet.md +95 -0
- package/agent-docs/components/breadcrumbs.md +62 -0
- package/agent-docs/components/bullet-list.md +54 -0
- package/agent-docs/components/button.md +135 -0
- package/agent-docs/components/callout.md +86 -0
- package/agent-docs/components/card-grid.md +108 -0
- package/agent-docs/components/card.md +113 -0
- package/agent-docs/components/centered-layout.md +90 -0
- package/agent-docs/components/chat-composer.md +48 -0
- package/agent-docs/components/chat-message.md +61 -0
- package/agent-docs/components/chat-thread.md +49 -0
- package/agent-docs/components/checkbox.md +75 -0
- package/agent-docs/components/cluster.md +106 -0
- package/agent-docs/components/code-example.md +48 -0
- package/agent-docs/components/code.md +70 -0
- package/agent-docs/components/colour-scheme-toggle.md +92 -0
- package/agent-docs/components/container.md +50 -0
- package/agent-docs/components/copy-button.md +61 -0
- package/agent-docs/components/copy-line.md +54 -0
- package/agent-docs/components/date-field.md +103 -0
- package/agent-docs/components/date-range-picker.md +101 -0
- package/agent-docs/components/detail-layout.md +147 -0
- package/agent-docs/components/dialog.md +178 -0
- package/agent-docs/components/disclosure.md +66 -0
- package/agent-docs/components/divider.md +62 -0
- package/agent-docs/components/docs-layout.md +160 -0
- package/agent-docs/components/drawer.md +128 -0
- package/agent-docs/components/empty-state.md +67 -0
- package/agent-docs/components/field-dialog.md +97 -0
- package/agent-docs/components/field.md +68 -0
- package/agent-docs/components/fieldset.md +82 -0
- package/agent-docs/components/file-drop.md +52 -0
- package/agent-docs/components/form-layout.md +141 -0
- package/agent-docs/components/form-row.md +93 -0
- package/agent-docs/components/full-bleed-layout.md +116 -0
- package/agent-docs/components/headings.md +101 -0
- package/agent-docs/components/hero.md +59 -0
- package/agent-docs/components/icon-button.md +92 -0
- package/agent-docs/components/icon.md +66 -0
- package/agent-docs/components/image.md +64 -0
- package/agent-docs/components/input.md +83 -0
- package/agent-docs/components/kbd.md +38 -0
- package/agent-docs/components/key-value-list.md +81 -0
- package/agent-docs/components/lightbox.md +97 -0
- package/agent-docs/components/list-layout.md +154 -0
- package/agent-docs/components/list-row.md +116 -0
- package/agent-docs/components/loading.md +69 -0
- package/agent-docs/components/markdown.md +51 -0
- package/agent-docs/components/media-tile.md +97 -0
- package/agent-docs/components/menu.md +103 -0
- package/agent-docs/components/meta-list.md +69 -0
- package/agent-docs/components/morph.md +128 -0
- package/agent-docs/components/navigation-progress.md +56 -0
- package/agent-docs/components/outline-region.md +63 -0
- package/agent-docs/components/page-fade.md +116 -0
- package/agent-docs/components/page-header.md +93 -0
- package/agent-docs/components/pagination.md +64 -0
- package/agent-docs/components/pill.md +104 -0
- package/agent-docs/components/progress-bar.md +66 -0
- package/agent-docs/components/prose-layout.md +87 -0
- package/agent-docs/components/prose.md +41 -0
- package/agent-docs/components/radio-group.md +74 -0
- package/agent-docs/components/scroll-strip.md +48 -0
- package/agent-docs/components/segmented-control.md +133 -0
- package/agent-docs/components/select.md +65 -0
- package/agent-docs/components/show.md +120 -0
- package/agent-docs/components/side-column.md +70 -0
- package/agent-docs/components/sidebar-layout.md +134 -0
- package/agent-docs/components/site-footer.md +63 -0
- package/agent-docs/components/site-search.md +67 -0
- package/agent-docs/components/sortable-list.md +107 -0
- package/agent-docs/components/split-bar.md +54 -0
- package/agent-docs/components/stack.md +197 -0
- package/agent-docs/components/stacked-bar.md +88 -0
- package/agent-docs/components/stat-tile.md +69 -0
- package/agent-docs/components/status-pages.md +105 -0
- package/agent-docs/components/steps.md +74 -0
- package/agent-docs/components/sticky-bar.md +51 -0
- package/agent-docs/components/switch.md +79 -0
- package/agent-docs/components/table.md +373 -0
- package/agent-docs/components/tabs.md +180 -0
- package/agent-docs/components/text-link.md +105 -0
- package/agent-docs/components/textarea.md +51 -0
- package/agent-docs/components/timeline.md +79 -0
- package/agent-docs/components/toast.md +86 -0
- package/agent-docs/components/trend-chart.md +61 -0
- package/agent-docs/components/video.md +44 -0
- package/agent-docs/llms.txt +155 -0
- package/package.json +6 -3
- package/skills/uislash/SKILL.md +20 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
## Pagination
|
|
2
|
+
|
|
3
|
+
Group: Navigation
|
|
4
|
+
|
|
5
|
+
When to use: A list split into pages that the reader moves through: a directory, search results, an archive.
|
|
6
|
+
|
|
7
|
+
### The one right way
|
|
8
|
+
`pageHref` gives the URL of each page, so the page lives in the URL: back, a new tab and a shared link all work.
|
|
9
|
+
```tsx
|
|
10
|
+
import { Pagination } from "@slashsuite/ui-react";
|
|
11
|
+
|
|
12
|
+
<Pagination
|
|
13
|
+
label="Directory pages"
|
|
14
|
+
page={4}
|
|
15
|
+
pageCount={12}
|
|
16
|
+
pageHref={(page) => (page > 1 ? `?page=${page}` : "?")}
|
|
17
|
+
/>
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Do
|
|
21
|
+
- Give `pageHref` the URL of a page; the page lives in the URL, so back, a new tab and a shared link work. Each link goes through the app's `LinkProvider`.
|
|
22
|
+
- `page` is the page shown, from 1, and `pageCount` how many there are; a stale page past the end draws the last one, and a single page draws nothing.
|
|
23
|
+
- One Pagination under the list; a long list may add one above it too, each with its own `label`.
|
|
24
|
+
- The count line ("21 to 40 of 312") is a `Caption` beside it, not part of it.
|
|
25
|
+
- `previousLabel`, `nextLabel` and `pageLabel` carry the words for another language.
|
|
26
|
+
|
|
27
|
+
### Don't
|
|
28
|
+
Buttons that set the page in state: no URL, so the back button, a new tab and a shared link all lose the page.
|
|
29
|
+
```tsx
|
|
30
|
+
import { Button, Cluster } from "@slashsuite/ui-react";
|
|
31
|
+
|
|
32
|
+
<Cluster gap="xs">
|
|
33
|
+
<Button size="sm" variant="outline" onClick={() => undefined}>
|
|
34
|
+
First
|
|
35
|
+
</Button>
|
|
36
|
+
<Button size="sm" variant="outline" onClick={() => undefined}>
|
|
37
|
+
Previous
|
|
38
|
+
</Button>
|
|
39
|
+
<span>Page 4 of 12</span>
|
|
40
|
+
<Button size="sm" variant="outline" onClick={() => undefined}>
|
|
41
|
+
Next
|
|
42
|
+
</Button>
|
|
43
|
+
<Button size="sm" variant="outline" onClick={() => undefined}>
|
|
44
|
+
Last
|
|
45
|
+
</Button>
|
|
46
|
+
</Cluster>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Accessibility
|
|
50
|
+
- A `<nav>` named by `label`. Every page is a link, and the current one has `aria-current="page"`.
|
|
51
|
+
- Previous on the first page and Next on the last are plain text, not links, so there is no dead stop in the tab order.
|
|
52
|
+
- The gaps (`…`) are `aria-hidden`. Below `sm` the numbers give way to `pageLabel` ("Page 4 of 12") between Previous and Next.
|
|
53
|
+
|
|
54
|
+
### Props
|
|
55
|
+
### Pagination
|
|
56
|
+
Page links for a long list: Previous, the page numbers and Next, in a `<nav>` named by `label`. Each is a link to `pageHref(page)`, drawn by the app's router link through `LinkProvider`, so the page lives in the URL and back, a new tab and a shared link all work. The current page is a link with `aria-current="page"`. Below `sm` the numbers give way to `pageLabel` ("Page 2 of 4"). Renders nothing for one page. The count line ("21 to 40 of 312") is the caller's `Caption`.
|
|
57
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
58
|
+
- label: string (required). Names the `<nav>`. Two pagers on a page (above and below a list) each need their own.
|
|
59
|
+
- nextLabel: string (default Next). The next-page link's text.
|
|
60
|
+
- page: number (required). The page shown, from 1. Drawn clamped into `1` to `pageCount`.
|
|
61
|
+
- pageCount: number (required). How many pages there are. One or none draws nothing.
|
|
62
|
+
- pageHref: (page: number) => string (required). The URL of one page, called for every link drawn: `(page) => (page > 1 ? `?page=${page}` : "?")`.
|
|
63
|
+
- pageLabel: ((page: number, pageCount: number) => string) (default (at, count) => `Page ${at} of ${count}`). The summary shown in place of the numbers below `sm`. Default: `Page 2 of 4`.
|
|
64
|
+
- previousLabel: string (default Previous). The previous-page link's text.
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
## Pill
|
|
2
|
+
|
|
3
|
+
Group: Content
|
|
4
|
+
|
|
5
|
+
When to use: A short word that says what state or kind something is: paid, draft, flaky.
|
|
6
|
+
|
|
7
|
+
### Use instead
|
|
8
|
+
- Badge (badge.md): A count sits on an icon.
|
|
9
|
+
|
|
10
|
+
### The one right way
|
|
11
|
+
The tone carries the meaning: `positive` for done, `warn` for waiting, `danger` for failed, and no tone for a draft.
|
|
12
|
+
```tsx
|
|
13
|
+
import { Cluster, Pill } from "@slashsuite/ui-react";
|
|
14
|
+
|
|
15
|
+
<Cluster>
|
|
16
|
+
<Pill tone="positive" dot>
|
|
17
|
+
Paid
|
|
18
|
+
</Pill>
|
|
19
|
+
<Pill tone="warn" dot>
|
|
20
|
+
Due
|
|
21
|
+
</Pill>
|
|
22
|
+
<Pill tone="danger" dot>
|
|
23
|
+
Overdue
|
|
24
|
+
</Pill>
|
|
25
|
+
<Pill dot>Draft</Pill>
|
|
26
|
+
</Cluster>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Do
|
|
30
|
+
- Choose `tone` by meaning: `positive` for done or good, `warn` for waiting or at risk, `danger` for failed, `neutral` (the default) for a draft or no state, `info` for a note; `accent` for a kind or category that is none of those.
|
|
31
|
+
- `size` is `sm`, `md` (default) or `lg`; with none, a Pill takes the size of the `Card`, `ListRow` or `Table` it sits in.
|
|
32
|
+
- `dot` adds a leading dot in the Pill's colour; `round` swaps the rounded-square corners for a full pill shape. Use one look across a view.
|
|
33
|
+
- `name` makes a two-tone `name: value` pill (`<Pill name="Weight">72 kg</Pill>`): the name keeps the tone's tint and the children sit on the surface beside it. Keep the name to a word or two.
|
|
34
|
+
- `onRemove` adds an x button after the text, for a chip the reader can drop (an attachment, a filter); `removeLabel` names it (`Remove invoice.pdf`) and is required with it. On a link or button Pill the x is a separate button beside it, never nested inside.
|
|
35
|
+
- A Pill that goes somewhere takes `href` (`external` for a new tab; an in-app one goes through your router's `Link` on `LinkProvider`); one that does something takes `onClick`.
|
|
36
|
+
- A Pill beside a card's title is the Card's `status`, not a hand-built row.
|
|
37
|
+
- A message to read is a `Callout`, and an action is a `Button`.
|
|
38
|
+
|
|
39
|
+
### Don't
|
|
40
|
+
- Never make a row of clickable `Pill`s a filter: a filter is pressed `Button`s in a `Fieldset`.
|
|
41
|
+
|
|
42
|
+
One tone for every status says nothing: a reader cannot tell Paid from Overdue at a glance. Pick the tone by what the status means.
|
|
43
|
+
```tsx
|
|
44
|
+
import { Cluster, Pill } from "@slashsuite/ui-react";
|
|
45
|
+
|
|
46
|
+
<Cluster>
|
|
47
|
+
<Pill tone="accent" dot>
|
|
48
|
+
Paid
|
|
49
|
+
</Pill>
|
|
50
|
+
<Pill tone="accent" dot>
|
|
51
|
+
Due
|
|
52
|
+
</Pill>
|
|
53
|
+
<Pill tone="accent" dot>
|
|
54
|
+
Overdue
|
|
55
|
+
</Pill>
|
|
56
|
+
</Cluster>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
A Pill inside a `TextLink` is two parts doing one job, and the Pill's own hover dim and focus ring go unused. Give the Pill the `href`.
|
|
60
|
+
```tsx
|
|
61
|
+
import { Pill, TextLink } from "@slashsuite/ui-react";
|
|
62
|
+
|
|
63
|
+
<TextLink href="#flakes">
|
|
64
|
+
<Pill tone="warn" round>
|
|
65
|
+
3 flaky
|
|
66
|
+
</Pill>
|
|
67
|
+
</TextLink>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Accessibility
|
|
71
|
+
- A two-tone Pill reads "Weight: 72 kg" to a screen reader (a visually hidden colon follows the label). The x of `onRemove` is a `<button type="button">` with `removeLabel` as its `aria-label` and its tooltip, with the icon `aria-hidden`.
|
|
72
|
+
- A plain Pill is a `<span>`; the dot is `aria-hidden`. The tone is colour only, so the text must say the status itself.
|
|
73
|
+
- With `href` it is a link and with `onClick` a `<button type="button">`; both dim on hover and show the focus ring.
|
|
74
|
+
- `external` adds `target="_blank"` and `rel="noreferrer"`.
|
|
75
|
+
|
|
76
|
+
### Props
|
|
77
|
+
### Pill
|
|
78
|
+
A small tinted label whose `tone` says what it means; `dot` adds a leading dot in the pill's own text colour, `round` swaps the rounded-md corners for a full pill shape, and `size` steps the text (with none, it takes its container's). `name` makes it two-tone, `name: value`: the name keeps the tone's tint and the children, the value, sit on the surface beside it. `href` makes it a link (the app's router link through `LinkProvider` for an in-app path, else a plain `<a>`; `external` opens a new tab) and `onClick` makes it a button, each with a hover dim and the focus ring. `onRemove` adds an x button after the text (named by `removeLabel`), a separate button beside a link or button pill rather than nested in it. `title` is its tooltip and description; a plain pill with one takes a tab stop. While `loading` with no text yet it is a bone of its size.
|
|
79
|
+
- children: ReactNode. The pill's text; while `loading`, none yet draws the pill as a bone of its size.
|
|
80
|
+
- dot: boolean. A leading dot in the pill's own text colour.
|
|
81
|
+
- external: boolean. Opens in a new tab: adds `target="_blank"` and `rel="noreferrer"`.
|
|
82
|
+
- href: string. Makes the pill a link to this URL; an in-app path goes through the app's `LinkProvider`.
|
|
83
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
84
|
+
- loading: boolean. The data is not here yet: an empty slot draws a bone of its shape, a filled one draws as usual.
|
|
85
|
+
Left out, the part takes the nearest loading layout's or part's; `false` opts it out inside one.
|
|
86
|
+
- loadingLabel: string (default Loading). What a screen reader hears while this part is loading, when its own `loading` is set.
|
|
87
|
+
- name: string. The name half of a two-tone `name: value` pill: `children` is the value. The name keeps the
|
|
88
|
+
tone's tint and the value sits on a plain surface beside it, in a hairline border. Keep the
|
|
89
|
+
name to a word or two (`Weight`, `Sleep`).
|
|
90
|
+
- onClick: MouseEventHandler<HTMLButtonElement>. A Pill that is a button: runs `onClick`. Defaults to `type="button"`.
|
|
91
|
+
- onRemove: (() => void). Adds a small x button after the text that calls this: for a chip the reader can drop (an attachment, a filter). It sits beside a link or button pill, never inside it.
|
|
92
|
+
- removeLabel: string. The x button's accessible name and tooltip: `Remove invoice.pdf`. Required with `onRemove`.
|
|
93
|
+
- round: boolean. A full pill shape in place of the rounded-md corners.
|
|
94
|
+
- size: "sm" | "md" | "lg" (default the container's, else md). `sm` is smaller text, for a dense row; `lg` larger, beside a heading. Left out, a Pill takes
|
|
95
|
+
the size of the `Card`, `ListRow` or `Table` it sits in, else `md`.
|
|
96
|
+
- title: string. The detail behind a pill whose text is short or cut off (the full status, a date): its tooltip
|
|
97
|
+
on hover, keyboard focus and a tap, and its description. A plain pill with a title is focusable.
|
|
98
|
+
|
|
99
|
+
Keep anything a reader needs on the pill itself.
|
|
100
|
+
- tone: "neutral" | "info" | "positive" | "warn" | "danger" | "accent" (default neutral). What the pill means: `neutral`, `info`, `positive`, `warn` or `danger`, or `accent` for a
|
|
101
|
+
category that is none of those.
|
|
102
|
+
|
|
103
|
+
### Types
|
|
104
|
+
- PillTone: `Tone | "accent"`. A Pill's tones: the five meanings, and `accent` for a category that is none of them.
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
## ProgressBar
|
|
2
|
+
|
|
3
|
+
Group: Data
|
|
4
|
+
|
|
5
|
+
When to use: How far something has got toward a whole: money saved, steps done.
|
|
6
|
+
|
|
7
|
+
### The one right way
|
|
8
|
+
Say in words how far along it is, beside the bar. The bar shows the share and the words give the figures.
|
|
9
|
+
```tsx
|
|
10
|
+
import { Caption, Cluster, ProgressBar, Stack, Text } from "@slashsuite/ui-react";
|
|
11
|
+
|
|
12
|
+
<Stack gap="xs">
|
|
13
|
+
<Cluster justify="between">
|
|
14
|
+
<Text as="span">Kitchen funded</Text>
|
|
15
|
+
<Caption as="span">R 45 000 of R 75 000</Caption>
|
|
16
|
+
</Cluster>
|
|
17
|
+
<ProgressBar value={45000} max={75000} label="Kitchen funded" />
|
|
18
|
+
</Stack>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Do
|
|
22
|
+
- `value` is on the scale of `max`, which is 100 unless you pass one: three of twelve is `value={3} max={12}`. A fraction such as `0.25` is read as a quarter of one percent. A value past `max` is held at full.
|
|
23
|
+
- `label` is required and names what the bar measures.
|
|
24
|
+
- Say the figures in words beside the bar; the bar draws none.
|
|
25
|
+
- `tone` is `accent`, `positive`, `warn` or `danger`; `size` is `sm`, `md` (default) or `lg`.
|
|
26
|
+
- A share between two parties is a `SplitBar`; the parts of one whole are a `StackedBar`.
|
|
27
|
+
|
|
28
|
+
### Don't
|
|
29
|
+
A bare bar: nobody can tell what it measures or how much it holds.
|
|
30
|
+
```tsx
|
|
31
|
+
import { ProgressBar } from "@slashsuite/ui-react";
|
|
32
|
+
|
|
33
|
+
<ProgressBar value={60} label="Kitchen funded" />
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
A fraction such as `0.25` is read as a quarter of one percent, not a quarter of the bar.
|
|
38
|
+
```tsx
|
|
39
|
+
import { ProgressBar } from "@slashsuite/ui-react";
|
|
40
|
+
|
|
41
|
+
<ProgressBar value={0.25} label="Months saved" />
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Accessibility
|
|
46
|
+
- A ProgressBar has `role="progressbar"`, `aria-label` set to `label`, and `aria-valuemin`, `aria-valuemax` and `aria-valuenow` on a 0 to 100 scale.
|
|
47
|
+
- The announced percent is whole, and is never 0 or 100 unless the value truly is.
|
|
48
|
+
- The bar draws no text, so the words beside it carry the figures for everyone.
|
|
49
|
+
|
|
50
|
+
### Props
|
|
51
|
+
### ProgressBar
|
|
52
|
+
A thin horizontal bar with a filled share, for progress toward a total. `value` is held between 0 and `max`. `label` names what it measures, for a screen reader, which also hears the percentage. While `loading` it is one bone the bar's size, since 0 is a real value.
|
|
53
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
54
|
+
- label: string (required). What the bar measures, for a screen reader, which also hears the percentage.
|
|
55
|
+
- loading: boolean. The data is not here yet: an empty slot draws a bone of its shape, a filled one draws as usual.
|
|
56
|
+
Left out, the part takes the nearest loading layout's or part's; `false` opts it out inside one.
|
|
57
|
+
- loadingLabel: string (default Loading). What a screen reader hears while this part is loading, when its own `loading` is set.
|
|
58
|
+
- max: number (default 100). The value that fills the bar; `value` is drawn as its share of this. Defaults to 100.
|
|
59
|
+
- size: "sm" | "md" | "lg" (default md). The bar's height: `sm` 6px, `md` 8px, `lg` 12px.
|
|
60
|
+
- tone: "positive" | "warn" | "danger" | "accent" (default accent). What the progress means: `accent` (the default) plain progress, `positive` done or on track,
|
|
61
|
+
`warn` at risk, `danger` over a limit or failed.
|
|
62
|
+
- value: number (required). How far along, held between 0 and `max`.
|
|
63
|
+
|
|
64
|
+
### Types
|
|
65
|
+
- BarSize: `"sm" | "md" | "lg"`. 6px, 8px or 12px tall.
|
|
66
|
+
- BarTone: `"positive" | "warn" | "danger" | "accent"`. The colour of a bar's fill.
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
## ProseLayout
|
|
2
|
+
|
|
3
|
+
Group: Page layouts
|
|
4
|
+
|
|
5
|
+
When to use: Privacy, terms, help or any page that is mostly paragraphs.
|
|
6
|
+
|
|
7
|
+
### The one right way
|
|
8
|
+
Text pages (privacy, terms, help) are one reading column; the header sits inside it.
|
|
9
|
+
```tsx
|
|
10
|
+
import { ProseLayout, SectionHeading, Text } from "@slashsuite/ui-react";
|
|
11
|
+
|
|
12
|
+
<ProseLayout title="Privacy" description="How we handle your data.">
|
|
13
|
+
<SectionHeading>What we keep</SectionHeading>
|
|
14
|
+
<Text>We keep your account details and the quotes you send, and nothing else.</Text>
|
|
15
|
+
<SectionHeading>Who sees it</SectionHeading>
|
|
16
|
+
<Text>Only you and the people you invite to your organisation.</Text>
|
|
17
|
+
</ProseLayout>
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Full page
|
|
21
|
+
A whole text page: the shell with its brand and nav, then one reading column with the header inside it.
|
|
22
|
+
```tsx
|
|
23
|
+
import { AppShell, Tabs, ProseLayout, SectionHeading, Text } from "@slashsuite/ui-react";
|
|
24
|
+
|
|
25
|
+
<AppShell
|
|
26
|
+
brand={<a href="#">Hack Cove</a>}
|
|
27
|
+
nav={
|
|
28
|
+
<Tabs
|
|
29
|
+
label="Main"
|
|
30
|
+
items={[
|
|
31
|
+
{ label: "Quotes", href: "#quotes", selected: true },
|
|
32
|
+
{ label: "Clients", href: "#clients" },
|
|
33
|
+
]}
|
|
34
|
+
/>
|
|
35
|
+
}
|
|
36
|
+
>
|
|
37
|
+
<ProseLayout title="Privacy" description="How we handle your data.">
|
|
38
|
+
<SectionHeading>What we keep</SectionHeading>
|
|
39
|
+
<Text>We keep your account details and the quotes you send, and nothing else.</Text>
|
|
40
|
+
<SectionHeading>Who sees it</SectionHeading>
|
|
41
|
+
<Text>Only you and the people you invite to your organisation.</Text>
|
|
42
|
+
</ProseLayout>
|
|
43
|
+
</AppShell>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Do
|
|
47
|
+
- The text is the `children`: `SectionHeading`s and `Text` paragraphs, spaced `md` apart.
|
|
48
|
+
- `gap` picks another spacing from the same scale (`xs` to `xl`) for the whole page; the default is right for most pages.
|
|
49
|
+
- The header sits inside the column, so its `actions` stay beside the text.
|
|
50
|
+
- The `description` is the page's lede, set larger than the paragraphs after it, and the title above it is the strongest text on the page.
|
|
51
|
+
- `width` is `narrow` (the reading column, the default), `wide` or `full`. Use `wide` for a page that is not long prose, such as pricing, so it does not leave the right third empty; a paragraph and the lede keep their reading measure.
|
|
52
|
+
- Data or cards in a grid are not prose: use `ListLayout` or `CardGrid`.
|
|
53
|
+
|
|
54
|
+
### Don't
|
|
55
|
+
`ListLayout` is for lists: its content runs the full width, so lines of text get too long to read. Use `ProseLayout`.
|
|
56
|
+
```tsx
|
|
57
|
+
import { Card, ListLayout, Text } from "@slashsuite/ui-react";
|
|
58
|
+
|
|
59
|
+
<ListLayout title="Privacy" description="How we handle your data.">
|
|
60
|
+
<Card>
|
|
61
|
+
<Text>
|
|
62
|
+
We keep your account details and the quotes you send, and nothing else. Only you and the
|
|
63
|
+
people you invite to your organisation can see them.
|
|
64
|
+
</Text>
|
|
65
|
+
</Card>
|
|
66
|
+
</ListLayout>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Accessibility
|
|
70
|
+
- The title is the page's `h1`.
|
|
71
|
+
- Use `SectionHeading` for sections so the outline runs h1 then h2.
|
|
72
|
+
- `data-*` and `aria-*` go on the column's wrapper.
|
|
73
|
+
|
|
74
|
+
### Props
|
|
75
|
+
### ProseLayout
|
|
76
|
+
A text page: header, then `children` stacked `gap` apart (`md` by default), all in one column that starts at the Container's start edge (it is not re-centred, so the title does not jump). `width` sets the column: `narrow` (`max-w-3xl`, the default) is a reading measure; `wide` (`max-w-5xl`) and `full` (the Container's whole width) suit a page that is not long prose, such as a pricing page. Paragraphs (`Text`) and the header's lede keep their own reading measure whatever the width. Unlike `FormLayout` the header sits inside the column, so its `actions` stay beside the text instead of at the Container's far edge. While `loading` it owns the wait and passes it to everything inside, the header too.
|
|
77
|
+
- actions: ReactNode. Right of the title on `sm` and up, below it on a phone.
|
|
78
|
+
- breadcrumbs: ReactNode. A `Breadcrumbs` above the title.
|
|
79
|
+
- description: ReactNode. The lede under the title: a `Lead`, so it outranks the body text after it.
|
|
80
|
+
- gap: "sm" | "md" | "lg" | "xs" | "xl" (default md). The space between blocks: `xs` gap-2, `sm` gap-4, `md` gap-6, `lg` gap-8, `xl` gap-12 (gap-16 from `sm`).
|
|
81
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
82
|
+
- loading: boolean. The data is not here yet: an empty slot draws a bone of its shape, a filled one draws as usual.
|
|
83
|
+
Left out, the part takes the nearest loading layout's or part's; `false` opts it out inside one.
|
|
84
|
+
- loadingLabel: string (default Loading). What a screen reader hears while this part is loading, when its own `loading` is set.
|
|
85
|
+
- tabs: ReactNode. A `Tabs` (or similar) under the title.
|
|
86
|
+
- title: ReactNode (required). The page's `h1`.
|
|
87
|
+
- width: "narrow" | "full" | "wide" (default narrow). The column's width: `narrow` max-w-3xl, `wide` max-w-5xl, `full` the Container's width.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
## Prose
|
|
2
|
+
|
|
3
|
+
Group: Text
|
|
4
|
+
|
|
5
|
+
When to use: The body of a docs page or an article, where a reader scans headings. An app screen never uses it.
|
|
6
|
+
|
|
7
|
+
### The one right way
|
|
8
|
+
A docs page or an article wraps its body in `Prose`: body 16, the h4 at body size in semibold, the h3 at 20 and the h2 at 24.
|
|
9
|
+
```tsx
|
|
10
|
+
import { Prose } from "@slashsuite/ui-react";
|
|
11
|
+
|
|
12
|
+
<Prose>
|
|
13
|
+
<ProseDoc />
|
|
14
|
+
</Prose>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### Do
|
|
18
|
+
- Wrap the body of a docs page or an article in `Prose`, inside a `ProseLayout`, a `SidebarLayout` or anywhere else. `ProseLayout` takes no prop for it.
|
|
19
|
+
- Write the page with the usual parts: `SectionHeading` is the h2, `SubsectionHeading` the h3 and `SubsectionHeading size="sm"` (as `h4`) the h4, `Text` the paragraph. Inside `Prose` they take the long-form sizes; nothing else about them changes.
|
|
20
|
+
- `Callout` text, `BulletList` items, inline `Code` and a `TextLink` follow the body size. `Caption`, `Overline`, `Table`, `CodeBlock` and the form controls keep theirs.
|
|
21
|
+
- A `Dialog`, `Drawer` or `EmptyState` inside `Prose` looks as it does on any app screen.
|
|
22
|
+
- The sizes are fixed: `Prose` has no size to choose.
|
|
23
|
+
|
|
24
|
+
### Don't
|
|
25
|
+
- Never use `Prose` on an app screen. A dashboard, a form or a list keeps the app sizes.
|
|
26
|
+
|
|
27
|
+
Without `Prose` the same page has the dense app sizes: the h2 and the h3 are one size, only 2px above the body.
|
|
28
|
+
```tsx
|
|
29
|
+
<ProseDoc />
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Accessibility
|
|
34
|
+
- `Prose` renders a `div` and adds nothing to the page outline or to what a screen reader announces.
|
|
35
|
+
- The heading elements are unchanged: pick `as` to keep the outline in order, as everywhere else.
|
|
36
|
+
- `id`, `aria-*` and `data-*` go on the `div`.
|
|
37
|
+
|
|
38
|
+
### Props
|
|
39
|
+
### Prose
|
|
40
|
+
Long-form content, for a docs page or an article. A block (`div`) that sets the long line height (leading-7) on itself and puts the text roles inside it on the prose scale: `Text` text-base/7 (the size it is outside, on a longer line), `SectionHeading` text-2xl/8, `SubsectionHeading` `lg` text-2xl/8, `md` text-xl/7 and `sm` text-base/7 (a semibold line at body size), and the box of a `Callout` text-base/7. Every other role keeps its size. Nothing outside a `Prose` changes, and a `Dialog`, `Drawer` or `EmptyState` inside one is back on the app scale. An app screen never uses it: wrap the body of a docs page or an article, inside a `ProseLayout`, a `SidebarLayout` or anywhere else. Its blocks (`Section`s, paragraphs) are a `Stack`'s gap apart, as they would be in a `Stack`.
|
|
41
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
## RadioGroup
|
|
2
|
+
|
|
3
|
+
Group: Forms
|
|
4
|
+
|
|
5
|
+
When to use: A setting or answer with two to five options the person should see side by side: a visibility, a delivery method, a type.
|
|
6
|
+
|
|
7
|
+
### The one right way
|
|
8
|
+
One of a few options, all visible, is a `RadioGroup`: the group has a name and each option its label.
|
|
9
|
+
```tsx
|
|
10
|
+
import { Radio, RadioGroup } from "@slashsuite/ui-react";
|
|
11
|
+
|
|
12
|
+
<RadioGroup label="Shop type" defaultValue="vintage">
|
|
13
|
+
<Radio value="vintage" label="Vintage" />
|
|
14
|
+
<Radio value="books" label="Books" />
|
|
15
|
+
</RadioGroup>
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### Do
|
|
19
|
+
- Give the `RadioGroup` a `label` that names the question, and a `Radio` per option with its own `label` and a `value`.
|
|
20
|
+
- Keep the choice with `defaultValue`, or control it with `value` and `onChange(value)`. `name` posts it in a form.
|
|
21
|
+
- A `hint` on a `Radio` is a muted line under its label, for the option that needs a sentence; a `hint` on the group is a line under the group's label.
|
|
22
|
+
- An `error` on the group is a red line under the options and marks every circle red; it is the same wording rule as `Field`'s. The group draws its own label and error, so it is never put in a `Field`.
|
|
23
|
+
- `disabled` on the group disables every option; on a `Radio` it disables that one. Say why in the group's `hint`.
|
|
24
|
+
- `required` marks a choice the form cannot submit without; the group is `aria-required`.
|
|
25
|
+
- `size` (`sm`, `md` the default, `lg`) sets every circle and label, to match the `Input`s around it.
|
|
26
|
+
- More than five options, or a list that grows, is a `Select`. Several ticks are `Checkbox`es. Switching a view in place is a `SegmentedControl`.
|
|
27
|
+
|
|
28
|
+
### Don't
|
|
29
|
+
Checkboxes allow several ticks: they cannot say "one of these", and the screen reader hears no group.
|
|
30
|
+
```tsx
|
|
31
|
+
import { Checkbox, Stack } from "@slashsuite/ui-react";
|
|
32
|
+
|
|
33
|
+
<Stack gap="sm">
|
|
34
|
+
<Checkbox label="Vintage" defaultChecked />
|
|
35
|
+
<Checkbox label="Books" />
|
|
36
|
+
</Stack>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Accessibility
|
|
40
|
+
- The group is a `role="radiogroup"` named by its label; each `Radio` is a native `<input type="radio">` inside its `<label>`, so clicking the words chooses it.
|
|
41
|
+
- The group is one tab stop. The arrow keys move between the options and choose, wrapping at each end and skipping a disabled one.
|
|
42
|
+
- An `error` is a `role="alert"` line and the group is `aria-invalid`; a `hint` is the option's `aria-describedby`.
|
|
43
|
+
- The focus ring is drawn round the option that has focus, by the component.
|
|
44
|
+
|
|
45
|
+
### Props
|
|
46
|
+
### RadioGroup
|
|
47
|
+
A named group of radios, one chosen. The `label` names the group; `hint` is a muted line under the options that says more (the group's description); an `error` replaces it with a red line (`role="alert"`) and marks the group invalid. Give it `value` and `onChange`, or `defaultValue` and let it keep the choice. `name` posts the choice in a form. The arrow keys move between the radios and choose, and the group is one tab stop. `size` sizes every radio in the group, the same scale as a `Checkbox`. While `loading` the labels are drawn and each circle is a bone.
|
|
48
|
+
- children: ReactNode (required). The `Radio`s.
|
|
49
|
+
- defaultValue: string. The `value` chosen to begin with, when the group keeps its own choice.
|
|
50
|
+
- disabled: boolean. Disables every radio.
|
|
51
|
+
- error: ReactNode. Shown under the options in red with `role="alert"`; marks the group invalid. Like `Field`'s `error`.
|
|
52
|
+
- hint: ReactNode. A muted line under the options that says more; it describes the group. Replaced by `error`.
|
|
53
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
54
|
+
- label: ReactNode (required). The group's visible name, above the options.
|
|
55
|
+
- loading: boolean. The data is not here yet: an empty slot draws a bone of its shape, a filled one draws as usual.
|
|
56
|
+
Left out, the part takes the nearest loading layout's or part's; `false` opts it out inside one.
|
|
57
|
+
- loadingLabel: string (default Loading). What a screen reader hears while this part is loading, when its own `loading` is set.
|
|
58
|
+
- name: string. The form field the choice posts under.
|
|
59
|
+
- onChange: (value: string) => void. Called with the chosen radio's `value`.
|
|
60
|
+
- required: boolean. Marks the choice required: the group is `aria-required`, and a form will not submit with no option chosen.
|
|
61
|
+
- size: "sm" | "md" | "lg" (default md). The size of every radio in the group: `sm` is `text-xs` and a smaller circle, `lg` `text-base`
|
|
62
|
+
and a larger one.
|
|
63
|
+
- value: string. The `value` of the chosen radio.
|
|
64
|
+
|
|
65
|
+
### Radio
|
|
66
|
+
One option of a `RadioGroup`: a `label` and, under it, an optional `hint`. Click the label or the circle. While `loading` the circle is a bone.
|
|
67
|
+
- disabled: boolean. Disables this radio alone.
|
|
68
|
+
- hint: ReactNode. A muted line under the label that says more. It is the radio's `aria-describedby`.
|
|
69
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
70
|
+
- label: ReactNode (required). The text beside the circle.
|
|
71
|
+
- loading: boolean. The data is not here yet: an empty slot draws a bone of its shape, a filled one draws as usual.
|
|
72
|
+
Left out, the part takes the nearest loading layout's or part's; `false` opts it out inside one.
|
|
73
|
+
- loadingLabel: string (default Loading). What a screen reader hears while this part is loading, when its own `loading` is set.
|
|
74
|
+
- value: string (required). What the group's `value` becomes when this one is chosen.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
## ScrollStrip
|
|
2
|
+
|
|
3
|
+
Group: Content
|
|
4
|
+
|
|
5
|
+
When to use: A row of media or people that is longer than the page is wide: recent statuses, a team.
|
|
6
|
+
|
|
7
|
+
### The one right way
|
|
8
|
+
A row of media that runs past the page is a `ScrollStrip`: one line, a thin scrollbar, snapping.
|
|
9
|
+
```tsx
|
|
10
|
+
import { MediaTile, ScrollStrip } from "@slashsuite/ui-react";
|
|
11
|
+
|
|
12
|
+
<ScrollStrip label="Recent statuses">
|
|
13
|
+
{[...sampleScenes, ...sampleScenes].map((scene, index) => (
|
|
14
|
+
<MediaTile key={index} src={scene.src} alt={scene.alt} label="Anna" />
|
|
15
|
+
))}
|
|
16
|
+
</ScrollStrip>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Do
|
|
20
|
+
- Put `MediaTile`s or `Avatar`s as the children and name the strip with `label`. They keep their own width and never shrink or wrap.
|
|
21
|
+
- `gap` is a `Cluster`'s: `xs`, `sm` (the default) or `md`; the `Size` type lists every default that is not `md`.
|
|
22
|
+
- It scrolls only when the items run past its width, with a thin themed scrollbar, and the items snap to the start edge.
|
|
23
|
+
|
|
24
|
+
### Don't
|
|
25
|
+
- Do not use it for a few items that fit: that is a `Cluster`. A grid that wraps is a `CardGrid`.
|
|
26
|
+
|
|
27
|
+
A `Cluster` wraps the tiles onto several lines, so the row takes over the page instead of staying in one line.
|
|
28
|
+
```tsx
|
|
29
|
+
import { Cluster, MediaTile } from "@slashsuite/ui-react";
|
|
30
|
+
|
|
31
|
+
<Cluster>
|
|
32
|
+
{[...sampleScenes, ...sampleScenes].map((scene, index) => (
|
|
33
|
+
<MediaTile key={index} src={scene.src} alt={scene.alt} label="Anna" />
|
|
34
|
+
))}
|
|
35
|
+
</Cluster>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Accessibility
|
|
39
|
+
- A `role="group"` named by `label`. It takes keyboard focus (`tabindex="0"`) with a focus ring, so the arrow keys scroll it without a pointer.
|
|
40
|
+
- `id`, `data-*` and `aria-*` go on the strip.
|
|
41
|
+
|
|
42
|
+
### Props
|
|
43
|
+
### ScrollStrip
|
|
44
|
+
A single row of items that scrolls sideways when it runs past the width of its parent, with a thin themed scrollbar and the items snapping into place: a strip of `MediaTile`s or `Avatar`s. Items never shrink or wrap. The strip takes the keyboard focus, so the arrow keys scroll it without a pointer. A grid that wraps is a `CardGrid` or a `Cluster`.
|
|
45
|
+
- children: ReactNode (required). The items, one after another: `MediaTile`s, `Avatar`s. They keep their own width.
|
|
46
|
+
- gap: "sm" | "md" | "xs" (default sm). The space between items, as `Cluster`'s `gap`.
|
|
47
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
48
|
+
- label: string (required). Names the strip for a screen reader, e.g. "Recent statuses".
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
## SegmentedControl
|
|
2
|
+
|
|
3
|
+
Group: Forms
|
|
4
|
+
|
|
5
|
+
When to use: A mode or a range chosen in place: daily or weekly, split or even.
|
|
6
|
+
|
|
7
|
+
### Use instead
|
|
8
|
+
- Tabs (tabs.md): The choice switches the panel right under the row.
|
|
9
|
+
- Fieldset (fieldset.md): Several toggles can be on at once and narrow a list: pressed `Button`s in a `Fieldset`.
|
|
10
|
+
|
|
11
|
+
### The one right way
|
|
12
|
+
A mode or a range chosen in place: the caller owns `value`, and `label` names the group.
|
|
13
|
+
```tsx
|
|
14
|
+
import { useState } from "react";
|
|
15
|
+
import { SegmentedControl } from "@slashsuite/ui-react";
|
|
16
|
+
|
|
17
|
+
function Example() {
|
|
18
|
+
const [value, setValue] = useState("week");
|
|
19
|
+
return (
|
|
20
|
+
<SegmentedControl
|
|
21
|
+
label="Range"
|
|
22
|
+
items={[
|
|
23
|
+
{ value: "day", label: "Daily" },
|
|
24
|
+
{ value: "week", label: "Weekly" },
|
|
25
|
+
{ value: "month", label: "Monthly" },
|
|
26
|
+
]}
|
|
27
|
+
value={value}
|
|
28
|
+
onChange={setValue}
|
|
29
|
+
/>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Do
|
|
35
|
+
- Two to five short options. The caller owns `value` and `onChange`; `label` names the group.
|
|
36
|
+
- `size` is `sm`, `md` (default) or `lg`, the heights of a `Button`.
|
|
37
|
+
- `fill` when the group sits in a column (a form field): the options share its full width, so the border ends at the last option.
|
|
38
|
+
- An on/off setting is a `Checkbox` or a `Switch`; a long list is a `Select`.
|
|
39
|
+
- Switching the panel under a row of headings is `Tabs`.
|
|
40
|
+
- A `count` sits muted after the label.
|
|
41
|
+
- An option that cannot be chosen yet takes a `disabledReason` that says why; `disabled` on the group disables every option.
|
|
42
|
+
- Options that go to another page are links: `href` on each, drawn by the app's router link through `LinkProvider`. `value` marks the current page.
|
|
43
|
+
|
|
44
|
+
### Don't
|
|
45
|
+
An on/off setting is a `Checkbox`, not a two-option SegmentedControl.
|
|
46
|
+
```tsx
|
|
47
|
+
import { useState } from "react";
|
|
48
|
+
import { SegmentedControl } from "@slashsuite/ui-react";
|
|
49
|
+
|
|
50
|
+
function Example() {
|
|
51
|
+
const [value, setValue] = useState("on");
|
|
52
|
+
return (
|
|
53
|
+
<SegmentedControl
|
|
54
|
+
label="Email me"
|
|
55
|
+
items={[
|
|
56
|
+
{ value: "on", label: "On" },
|
|
57
|
+
{ value: "off", label: "Off" },
|
|
58
|
+
]}
|
|
59
|
+
value={value}
|
|
60
|
+
onChange={setValue}
|
|
61
|
+
/>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
A bare `disabled` option leaves the person guessing why it is greyed out.
|
|
67
|
+
```tsx
|
|
68
|
+
import { useState } from "react";
|
|
69
|
+
import { SegmentedControl } from "@slashsuite/ui-react";
|
|
70
|
+
|
|
71
|
+
function Example() {
|
|
72
|
+
const [value, setValue] = useState("split");
|
|
73
|
+
return (
|
|
74
|
+
<SegmentedControl
|
|
75
|
+
label="Split"
|
|
76
|
+
items={[
|
|
77
|
+
{ value: "split", label: "Split" },
|
|
78
|
+
{ value: "even", label: "Even" },
|
|
79
|
+
{ value: "custom", label: "Custom", disabled: true },
|
|
80
|
+
]}
|
|
81
|
+
value={value}
|
|
82
|
+
onChange={setValue}
|
|
83
|
+
/>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Buttons that navigate from `onChange` are not links: they cannot be opened in a new tab or copied, and the current page is not marked as one.
|
|
89
|
+
```tsx
|
|
90
|
+
import { SegmentedControl } from "@slashsuite/ui-react";
|
|
91
|
+
|
|
92
|
+
<SegmentedControl
|
|
93
|
+
label="Journal"
|
|
94
|
+
value="daily"
|
|
95
|
+
items={[
|
|
96
|
+
{ value: "daily", label: "Daily" },
|
|
97
|
+
{ value: "weekly", label: "Weekly" },
|
|
98
|
+
]}
|
|
99
|
+
onChange={(value) => window.location.assign(`#${value}`)}
|
|
100
|
+
/>
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Accessibility
|
|
104
|
+
- Buttons form a `radiogroup` named by `label`; each option is a `radio` with `aria-checked`.
|
|
105
|
+
- The group is one tab stop. The arrow keys (all four), Home and End move to the next enabled option and choose it.
|
|
106
|
+
- An option with `disabledReason` is `aria-disabled`: the arrow keys reach it and choose 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). A `disabled` option is skipped.
|
|
107
|
+
- Links form a `<nav>` named by `label`, and the current one has `aria-current="page"`.
|
|
108
|
+
- The focus ring comes from the component.
|
|
109
|
+
|
|
110
|
+
### Props
|
|
111
|
+
### SegmentedControl
|
|
112
|
+
A joined pill group where one option is filled: a mode or a range chosen in place. `items` are `{ value, label }` buttons (`value` and `onChange` are the caller's state; the arrow keys, Home and End move the choice) or links (`href`, an in-app one drawn by the app's router `<Link>` through `LinkProvider`; `value` marks the current one, which gets `aria-current`). An item may carry a `count`, and a button one `disabledReason` (it stays reachable by the arrows and its reason is a tooltip) or a bare `disabled`; `disabled` on the group disables every option. `label` names the group. `size` matches the height of a `Button` of the same size, and `{ base, md }` changes it at 48rem. `fill` stretches the options across the group's width; `wrap` lets them wrap into full rows of a box, always or (`"narrow"`) only while the group is under 32rem wide.
|
|
113
|
+
- disabled: boolean. Every option is disabled, e.g. until the page has hydrated.
|
|
114
|
+
- fill: boolean (default false). The group takes its parent's full width and the options grow to share it, so the border ends
|
|
115
|
+
at the last option. Still a pill.
|
|
116
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
117
|
+
- items: Segment[] (required). The options in order: `{ value, label }` buttons, or links (`href`), the current link marked by its `selected` or by a `value` equal to the group's. Either may carry a `count`; a button may be `disabled`.
|
|
118
|
+
- label: string (required). The accessible name of the group.
|
|
119
|
+
- onChange: ((value: string) => void). Called with the option's `value` when one is chosen, by click or arrow key.
|
|
120
|
+
- size: Size | ResponsiveSize (default md). The control's height and text, on the scale of a `Button`. `{ base: "md", md: "lg" }` changes
|
|
121
|
+
size at the `md` breakpoint (48rem), in CSS.
|
|
122
|
+
|
|
123
|
+
Give it the same value as a responsive `Button` in the same row.
|
|
124
|
+
- value: string. The `value` of the current option; for links, an alternative to `selected` on the item.
|
|
125
|
+
- wrap: boolean | "narrow" (default false). The options wrap onto full rows of at most three (five are 3 then 2) in a box with rounded
|
|
126
|
+
corners and a line between options, instead of a pill. `"narrow"`: the box only while the group
|
|
127
|
+
itself is under 32rem wide (a container query, so it follows the column it sits in), and a
|
|
128
|
+
filled pill from 32rem up. Implies `fill`.
|
|
129
|
+
|
|
130
|
+
For five options that will not fit one row.
|
|
131
|
+
|
|
132
|
+
### Types
|
|
133
|
+
- Segment: `{ label: ReactNode; count?: number; title?: string; value: string; disabled?: boolean; disabledReason?: string; controls?: string } | { label: ReactNode; count?: number; title?: string; value?: string; selected?: boolean; external?: boolean; href: string }`. One option of a SegmentedControl: a button with a `value`, or a link with an `href`; never both kinds in one group.
|