@cdx-ui/components 0.2.3 → 0.2.4
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/AGENTS.md +24 -0
- package/README.md +2 -0
- package/coverage.svg +1 -1
- package/docs/components/accordion/content.md +538 -0
- package/docs/components/alert/content.md +203 -0
- package/docs/components/alert-dialog/content.md +319 -0
- package/docs/components/avatar/content.md +368 -0
- package/docs/components/avatar/design.md +202 -0
- package/docs/components/badge/content.md +235 -0
- package/docs/components/bottom-sheet/content.md +351 -0
- package/docs/components/bottom-sheet/design.md +249 -0
- package/docs/components/breadcrumbs/content.md +169 -0
- package/docs/components/button/content.md +398 -0
- package/docs/components/button/design.md +258 -0
- package/docs/components/calendar/content.md +137 -0
- package/docs/components/card/content.md +283 -0
- package/docs/components/carousel/content.md +416 -0
- package/docs/components/checkbox/content.md +236 -0
- package/docs/components/checkbox/design.md +214 -0
- package/docs/components/chip/content.md +439 -0
- package/docs/components/chip/design.md +418 -0
- package/docs/components/color-area/content.md +86 -0
- package/docs/components/color-field/content.md +134 -0
- package/docs/components/color-picker/content.md +208 -0
- package/docs/components/color-slider/content.md +120 -0
- package/docs/components/color-swatch/content.md +64 -0
- package/docs/components/color-swatch-picker/content.md +126 -0
- package/docs/components/content.md +97 -0
- package/docs/components/currency-input/content.md +205 -0
- package/docs/components/data-grid/content.md +522 -0
- package/docs/components/date-field/content.md +147 -0
- package/docs/components/date-picker/content.md +360 -0
- package/docs/components/date-range-picker/content.md +301 -0
- package/docs/components/date-time-field/content.md +157 -0
- package/docs/components/date-time-list/content.md +105 -0
- package/docs/components/date-time-picker/content.md +272 -0
- package/docs/components/dialog/content.md +436 -0
- package/docs/components/dialog/design.md +192 -0
- package/docs/components/divider/content.md +112 -0
- package/docs/components/drawer/content.md +436 -0
- package/docs/components/field/content.md +277 -0
- package/docs/components/form/content.md +62 -0
- package/docs/components/full-screen-dialog/content.md +881 -0
- package/docs/components/heading/content.md +55 -0
- package/docs/components/icon/content.md +190 -0
- package/docs/components/icon-button/content.md +200 -0
- package/docs/components/icon-button/design.md +165 -0
- package/docs/components/image/content.md +104 -0
- package/docs/components/input/content.md +281 -0
- package/docs/components/input/design.md +389 -0
- package/docs/components/insurance-disclosure/content.md +103 -0
- package/docs/components/link/content.md +180 -0
- package/docs/components/link/design.md +160 -0
- package/docs/components/list-item/content.md +695 -0
- package/docs/components/menu/content.md +1247 -0
- package/docs/components/month-calendar/content.md +84 -0
- package/docs/components/month-picker/content.md +273 -0
- package/docs/components/otp-input/content.md +327 -0
- package/docs/components/progress-bar/content.md +87 -0
- package/docs/components/progress-circle/content.md +176 -0
- package/docs/components/progress-segmented/content.md +119 -0
- package/docs/components/quick-action-button/content.md +154 -0
- package/docs/components/quick-action-button/design.md +170 -0
- package/docs/components/radio/content.md +224 -0
- package/docs/components/range-calendar/content.md +123 -0
- package/docs/components/reorderable-list/content.md +309 -0
- package/docs/components/scoped-theme/content.md +47 -0
- package/docs/components/scroll-shadow/content.md +686 -0
- package/docs/components/select/content.md +400 -0
- package/docs/components/select/design.md +301 -0
- package/docs/components/skeleton/content.md +103 -0
- package/docs/components/slider/content.md +423 -0
- package/docs/components/stack/content.md +161 -0
- package/docs/components/switch/content.md +150 -0
- package/docs/components/switch/design.md +208 -0
- package/docs/components/table/content.md +548 -0
- package/docs/components/table-pagination/content.md +177 -0
- package/docs/components/tabs/content.md +292 -0
- package/docs/components/text/content.md +142 -0
- package/docs/components/textarea/content.md +222 -0
- package/docs/components/tile/content.md +703 -0
- package/docs/components/toast/content.md +456 -0
- package/docs/components/toggle-button/content.md +505 -0
- package/docs/components/tooltip/content.md +350 -0
- package/docs/components/virtualized-list/content.md +250 -0
- package/docs/foundations/content.md +9 -0
- package/docs/foundations/expressions/icons/content.md +19 -0
- package/docs/foundations/styles/tokens/all-tokens/content.md +192 -0
- package/docs/foundations/styles/tokens/what-are-tokens/content.md +33 -0
- package/docs/foundations/styles/tokens/what-are-tokens/design.md +33 -0
- package/docs/getting-started/content.md +4 -0
- package/docs/getting-started/designers/content.md +13 -0
- package/docs/getting-started/designers/design.md +13 -0
- package/docs/getting-started/developers/accessibility/content.md +31 -0
- package/docs/getting-started/developers/content.md +612 -0
- package/docs/getting-started/developers/styling/content.md +193 -0
- package/docs/llms.txt +193 -0
- package/docs/patterns/account-management/content.md +75 -0
- package/docs/patterns/authentication/content.md +52 -0
- package/docs/patterns/content.md +10 -0
- package/docs/patterns/dashboard/content.md +39 -0
- package/docs/patterns/empty-states/content.md +31 -0
- package/docs/patterns/forms/content.md +109 -0
- package/docs/patterns/onboarding/content.md +69 -0
- package/docs/patterns/payments/content.md +35 -0
- package/docs/patterns/settings/content.md +72 -0
- package/docs/resources/content.md +9 -0
- package/docs/resources/figma-libraries/content.md +42 -0
- package/docs/resources/release-notes/0.0.1-beta.118/content.md +27 -0
- package/docs/resources/release-notes/0.0.1-beta.122/content.md +21 -0
- package/docs/resources/release-notes/0.0.1-beta.124/content.md +16 -0
- package/docs/resources/release-notes/0.0.1-beta.126/content.md +10 -0
- package/docs/resources/release-notes/0.0.1-beta.127/content.md +14 -0
- package/docs/resources/release-notes/0.0.1-beta.128/content.md +9 -0
- package/docs/resources/release-notes/0.0.1-beta.129/content.md +18 -0
- package/docs/resources/release-notes/0.0.1-beta.130/content.md +18 -0
- package/docs/resources/release-notes/0.0.1-beta.133/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.134/content.md +17 -0
- package/docs/resources/release-notes/0.0.1-beta.136/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.137/content.md +10 -0
- package/docs/resources/release-notes/0.0.1-beta.138/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.139/content.md +13 -0
- package/docs/resources/release-notes/0.0.1-beta.140/content.md +26 -0
- package/docs/resources/release-notes/0.0.1-beta.141/content.md +63 -0
- package/docs/resources/release-notes/0.0.1-beta.142/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.143/content.md +12 -0
- package/docs/resources/release-notes/0.0.1-beta.144/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.145/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.147/content.md +10 -0
- package/docs/resources/release-notes/0.0.1-beta.149/content.md +10 -0
- package/docs/resources/release-notes/0.0.1-beta.150/content.md +13 -0
- package/docs/resources/release-notes/0.0.1-beta.152/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.154/content.md +15 -0
- package/docs/resources/release-notes/0.0.1-beta.156/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.158/content.md +9 -0
- package/docs/resources/release-notes/0.0.1-beta.159/content.md +11 -0
- package/docs/resources/release-notes/0.0.1-beta.160/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.161/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.163/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.164/content.md +9 -0
- package/docs/resources/release-notes/0.0.1-beta.166/content.md +17 -0
- package/docs/resources/release-notes/0.0.1-beta.167/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.168/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.169/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.171/content.md +16 -0
- package/docs/resources/release-notes/0.0.1-beta.172/content.md +24 -0
- package/docs/resources/release-notes/0.0.1-beta.173/content.md +15 -0
- package/docs/resources/release-notes/0.0.1-beta.174/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.176/content.md +32 -0
- package/docs/resources/release-notes/0.0.1-beta.179/content.md +11 -0
- package/docs/resources/release-notes/0.0.1-beta.182/content.md +13 -0
- package/docs/resources/release-notes/0.0.1-beta.185/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.187/content.md +27 -0
- package/docs/resources/release-notes/0.1.1/content.md +23 -0
- package/docs/resources/release-notes/0.1.2/content.md +7 -0
- package/docs/resources/release-notes/0.1.4/content.md +19 -0
- package/docs/resources/release-notes/0.1.5/content.md +7 -0
- package/docs/resources/release-notes/0.1.6/content.md +7 -0
- package/docs/resources/release-notes/0.2.0/content.md +31 -0
- package/docs/resources/release-notes/0.2.1/content.md +17 -0
- package/docs/resources/release-notes/0.2.2/content.md +11 -0
- package/docs/resources/release-notes/0.2.3/content.md +15 -0
- package/docs/resources/release-notes/content.md +64 -0
- package/lib/commonjs/components/DateTimeList/index.js +11 -26
- package/lib/commonjs/components/DateTimeList/index.js.map +1 -1
- package/lib/commonjs/components/DateTimeList/styles.js +2 -12
- package/lib/commonjs/components/DateTimeList/styles.js.map +1 -1
- package/lib/commonjs/components/ListItem/index.js.map +1 -1
- package/lib/commonjs/components/ListItem/styles.js +2 -1
- package/lib/commonjs/components/ListItem/styles.js.map +1 -1
- package/lib/commonjs/components/Menu/index.js +11 -5
- package/lib/commonjs/components/Menu/index.js.map +1 -1
- package/lib/commonjs/components/ScrollShadow/gradient.js +29 -0
- package/lib/commonjs/components/ScrollShadow/gradient.js.map +1 -0
- package/lib/commonjs/components/ScrollShadow/index.js +171 -44
- package/lib/commonjs/components/ScrollShadow/index.js.map +1 -1
- package/lib/commonjs/components/ScrollShadow/styles.js +58 -14
- package/lib/commonjs/components/ScrollShadow/styles.js.map +1 -1
- package/lib/commonjs/components/ScrollShadow/useComposedScrollHandler.js +63 -0
- package/lib/commonjs/components/ScrollShadow/useComposedScrollHandler.js.map +1 -0
- package/lib/commonjs/components/ScrollShadow/useScrollShadow.js +48 -8
- package/lib/commonjs/components/ScrollShadow/useScrollShadow.js.map +1 -1
- package/lib/commonjs/components/Tabs/index.js +16 -23
- package/lib/commonjs/components/Tabs/index.js.map +1 -1
- package/lib/commonjs/components/Tabs/styles.js +1 -10
- package/lib/commonjs/components/Tabs/styles.js.map +1 -1
- package/lib/commonjs/figma/ListItem.SectionHeader.figma.js +20 -5
- package/lib/commonjs/figma/ListItem.SectionHeader.figma.js.map +1 -1
- package/lib/module/components/DateTimeList/index.js +12 -27
- package/lib/module/components/DateTimeList/index.js.map +1 -1
- package/lib/module/components/DateTimeList/styles.js +1 -11
- package/lib/module/components/DateTimeList/styles.js.map +1 -1
- package/lib/module/components/ListItem/index.js.map +1 -1
- package/lib/module/components/ListItem/styles.js +2 -1
- package/lib/module/components/ListItem/styles.js.map +1 -1
- package/lib/module/components/Menu/index.js +11 -5
- package/lib/module/components/Menu/index.js.map +1 -1
- package/lib/module/components/ScrollShadow/gradient.js +24 -0
- package/lib/module/components/ScrollShadow/gradient.js.map +1 -0
- package/lib/module/components/ScrollShadow/index.js +170 -48
- package/lib/module/components/ScrollShadow/index.js.map +1 -1
- package/lib/module/components/ScrollShadow/styles.js +57 -13
- package/lib/module/components/ScrollShadow/styles.js.map +1 -1
- package/lib/module/components/ScrollShadow/useComposedScrollHandler.js +57 -0
- package/lib/module/components/ScrollShadow/useComposedScrollHandler.js.map +1 -0
- package/lib/module/components/ScrollShadow/useScrollShadow.js +46 -8
- package/lib/module/components/ScrollShadow/useScrollShadow.js.map +1 -1
- package/lib/module/components/Tabs/index.js +17 -24
- package/lib/module/components/Tabs/index.js.map +1 -1
- package/lib/module/components/Tabs/styles.js +0 -9
- package/lib/module/components/Tabs/styles.js.map +1 -1
- package/lib/module/figma/ListItem.SectionHeader.figma.js +20 -5
- package/lib/module/figma/ListItem.SectionHeader.figma.js.map +1 -1
- package/lib/typescript/components/DateTimeList/index.d.ts.map +1 -1
- package/lib/typescript/components/DateTimeList/styles.d.ts +1 -4
- package/lib/typescript/components/DateTimeList/styles.d.ts.map +1 -1
- package/lib/typescript/components/ListItem/index.d.ts +5 -4
- package/lib/typescript/components/ListItem/index.d.ts.map +1 -1
- package/lib/typescript/components/ListItem/styles.d.ts +1 -1
- package/lib/typescript/components/ListItem/styles.d.ts.map +1 -1
- package/lib/typescript/components/Menu/index.d.ts.map +1 -1
- package/lib/typescript/components/ScrollShadow/gradient.d.ts +7 -0
- package/lib/typescript/components/ScrollShadow/gradient.d.ts.map +1 -0
- package/lib/typescript/components/ScrollShadow/index.d.ts +57 -15
- package/lib/typescript/components/ScrollShadow/index.d.ts.map +1 -1
- package/lib/typescript/components/ScrollShadow/styles.d.ts +8 -2
- package/lib/typescript/components/ScrollShadow/styles.d.ts.map +1 -1
- package/lib/typescript/components/ScrollShadow/useComposedScrollHandler.d.ts +13 -0
- package/lib/typescript/components/ScrollShadow/useComposedScrollHandler.d.ts.map +1 -0
- package/lib/typescript/components/ScrollShadow/useScrollShadow.d.ts +15 -2
- package/lib/typescript/components/ScrollShadow/useScrollShadow.d.ts.map +1 -1
- package/lib/typescript/components/Tabs/index.d.ts.map +1 -1
- package/lib/typescript/components/Tabs/styles.d.ts +0 -7
- package/lib/typescript/components/Tabs/styles.d.ts.map +1 -1
- package/lib/typescript/figma/ListItem.SectionHeader.figma.d.ts.map +1 -1
- package/package.json +8 -6
- package/src/components/DateTimeList/index.tsx +13 -26
- package/src/components/DateTimeList/styles.ts +1 -10
- package/src/components/ListItem/index.tsx +5 -4
- package/src/components/ListItem/styles.ts +1 -0
- package/src/components/Menu/index.tsx +11 -8
- package/src/components/ScrollShadow/gradient.ts +48 -0
- package/src/components/ScrollShadow/index.tsx +300 -69
- package/src/components/ScrollShadow/styles.ts +45 -28
- package/src/components/ScrollShadow/useComposedScrollHandler.ts +58 -0
- package/src/components/ScrollShadow/useScrollShadow.ts +72 -10
- package/src/components/Tabs/index.tsx +25 -35
- package/src/components/Tabs/styles.ts +0 -9
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
# Slider (https://design.candescent.com/docs/components/slider)
|
|
2
|
+
|
|
3
|
+
Resources: [Figma](https://www.figma.com/design/0lEVMVlLj8ZS4fgItr3pmd/%E2%AD%90-Forge-DS--Components?node-id=11500-17763), [Storybook](https://victorious-wave-0daadf00f.6.azurestaticapps.net/?path=/story/inputs-slider--default)
|
|
4
|
+
|
|
5
|
+
A compound component with sub-components for the rail, track fill, thumb, optional value popup, and step marks.
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { Slider } from '@cdx-ui/components';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Basic
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { useState } from 'react';
|
|
15
|
+
import { Slider } from '@cdx-ui/components';
|
|
16
|
+
|
|
17
|
+
export default function SliderBasicDemo() {
|
|
18
|
+
const [value, setValue] = useState(55);
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<Slider
|
|
22
|
+
value={value}
|
|
23
|
+
onChange={setValue}
|
|
24
|
+
min={0}
|
|
25
|
+
max={100}
|
|
26
|
+
step={1}
|
|
27
|
+
accessibilityLabel="Volume"
|
|
28
|
+
>
|
|
29
|
+
<Slider.Rail>
|
|
30
|
+
<Slider.Track />
|
|
31
|
+
</Slider.Rail>
|
|
32
|
+
<Slider.Thumb>
|
|
33
|
+
<Slider.Popup />
|
|
34
|
+
</Slider.Thumb>
|
|
35
|
+
</Slider>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Range
|
|
41
|
+
|
|
42
|
+
Use array `value` / `defaultValue` and `onChange` for a two-thumb range. Set an explicit `index` on each `Slider.Thumb` and provide per-thumb `accessibilityLabel` values (for example, minimum and maximum price).
|
|
43
|
+
|
|
44
|
+
```tsx
|
|
45
|
+
import { useState } from 'react';
|
|
46
|
+
import { Slider } from '@cdx-ui/components';
|
|
47
|
+
|
|
48
|
+
export default function SliderRangeDemo() {
|
|
49
|
+
const [value, setValue] = useState<number[]>([200, 800]);
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<Slider
|
|
53
|
+
value={value}
|
|
54
|
+
onChange={setValue}
|
|
55
|
+
min={0}
|
|
56
|
+
max={1000}
|
|
57
|
+
step={10}
|
|
58
|
+
accessibilityLabel="Price range"
|
|
59
|
+
>
|
|
60
|
+
<Slider.Rail>
|
|
61
|
+
<Slider.Track />
|
|
62
|
+
</Slider.Rail>
|
|
63
|
+
<Slider.Thumb index={0} accessibilityLabel="Minimum price">
|
|
64
|
+
<Slider.Popup />
|
|
65
|
+
</Slider.Thumb>
|
|
66
|
+
<Slider.Thumb index={1} accessibilityLabel="Maximum price">
|
|
67
|
+
<Slider.Popup />
|
|
68
|
+
</Slider.Thumb>
|
|
69
|
+
</Slider>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## With marks
|
|
75
|
+
|
|
76
|
+
Add `Slider.MarkerGroup` with a `Slider.Marker` child; marks are placed at each `step` interval.
|
|
77
|
+
|
|
78
|
+
```tsx
|
|
79
|
+
import { useState } from 'react';
|
|
80
|
+
import { Box, Slider } from '@cdx-ui/components';
|
|
81
|
+
|
|
82
|
+
export default function SliderWithMarksDemo() {
|
|
83
|
+
const [value, setValue] = useState(50);
|
|
84
|
+
const [rangeValue, setRangeValue] = useState<number[]>([20, 70]);
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<Box className="w-full gap-10">
|
|
88
|
+
<Slider
|
|
89
|
+
value={value}
|
|
90
|
+
onChange={setValue}
|
|
91
|
+
min={0}
|
|
92
|
+
max={100}
|
|
93
|
+
step={10}
|
|
94
|
+
accessibilityLabel="Volume"
|
|
95
|
+
>
|
|
96
|
+
<Slider.Rail>
|
|
97
|
+
<Slider.Track />
|
|
98
|
+
</Slider.Rail>
|
|
99
|
+
<Slider.Thumb>
|
|
100
|
+
<Slider.Popup />
|
|
101
|
+
</Slider.Thumb>
|
|
102
|
+
<Slider.MarkerGroup>
|
|
103
|
+
<Slider.Marker />
|
|
104
|
+
</Slider.MarkerGroup>
|
|
105
|
+
</Slider>
|
|
106
|
+
<Slider
|
|
107
|
+
value={rangeValue}
|
|
108
|
+
onChange={setRangeValue}
|
|
109
|
+
min={0}
|
|
110
|
+
max={100}
|
|
111
|
+
step={10}
|
|
112
|
+
accessibilityLabel="Volume range"
|
|
113
|
+
>
|
|
114
|
+
<Slider.Rail>
|
|
115
|
+
<Slider.Track />
|
|
116
|
+
</Slider.Rail>
|
|
117
|
+
<Slider.Thumb index={0} accessibilityLabel="Minimum volume">
|
|
118
|
+
<Slider.Popup />
|
|
119
|
+
</Slider.Thumb>
|
|
120
|
+
<Slider.Thumb index={1} accessibilityLabel="Maximum volume">
|
|
121
|
+
<Slider.Popup />
|
|
122
|
+
</Slider.Thumb>
|
|
123
|
+
<Slider.MarkerGroup>
|
|
124
|
+
<Slider.Marker />
|
|
125
|
+
</Slider.MarkerGroup>
|
|
126
|
+
</Slider>
|
|
127
|
+
</Box>
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Vertical
|
|
133
|
+
|
|
134
|
+
Use `orientation="vertical"`. The thumb travels along the rail from bottom to top. Single-value, range, and step marks all work the same way as they do horizontally.
|
|
135
|
+
|
|
136
|
+
```tsx
|
|
137
|
+
import { useState } from 'react';
|
|
138
|
+
import { Box, Slider } from '@cdx-ui/components';
|
|
139
|
+
|
|
140
|
+
export default function SliderVerticalDemo() {
|
|
141
|
+
const [value, setValue] = useState(40);
|
|
142
|
+
const [rangeValue, setRangeValue] = useState<number[]>([25, 75]);
|
|
143
|
+
const [steppedValue, setSteppedValue] = useState(60);
|
|
144
|
+
|
|
145
|
+
return (
|
|
146
|
+
<Box className="h-56 flex-row items-center gap-12">
|
|
147
|
+
<Slider
|
|
148
|
+
orientation="vertical"
|
|
149
|
+
value={value}
|
|
150
|
+
onChange={setValue}
|
|
151
|
+
min={0}
|
|
152
|
+
max={100}
|
|
153
|
+
accessibilityLabel="Level"
|
|
154
|
+
>
|
|
155
|
+
<Slider.Rail>
|
|
156
|
+
<Slider.Track />
|
|
157
|
+
</Slider.Rail>
|
|
158
|
+
<Slider.Thumb>
|
|
159
|
+
<Slider.Popup />
|
|
160
|
+
</Slider.Thumb>
|
|
161
|
+
</Slider>
|
|
162
|
+
<Slider
|
|
163
|
+
orientation="vertical"
|
|
164
|
+
value={rangeValue}
|
|
165
|
+
onChange={setRangeValue}
|
|
166
|
+
min={0}
|
|
167
|
+
max={100}
|
|
168
|
+
accessibilityLabel="Level range"
|
|
169
|
+
>
|
|
170
|
+
<Slider.Rail>
|
|
171
|
+
<Slider.Track />
|
|
172
|
+
</Slider.Rail>
|
|
173
|
+
<Slider.Thumb index={0} accessibilityLabel="Minimum level">
|
|
174
|
+
<Slider.Popup />
|
|
175
|
+
</Slider.Thumb>
|
|
176
|
+
<Slider.Thumb index={1} accessibilityLabel="Maximum level">
|
|
177
|
+
<Slider.Popup />
|
|
178
|
+
</Slider.Thumb>
|
|
179
|
+
</Slider>
|
|
180
|
+
<Slider
|
|
181
|
+
orientation="vertical"
|
|
182
|
+
value={steppedValue}
|
|
183
|
+
onChange={setSteppedValue}
|
|
184
|
+
min={0}
|
|
185
|
+
max={100}
|
|
186
|
+
step={10}
|
|
187
|
+
accessibilityLabel="Stepped level"
|
|
188
|
+
>
|
|
189
|
+
<Slider.Rail>
|
|
190
|
+
<Slider.Track />
|
|
191
|
+
</Slider.Rail>
|
|
192
|
+
<Slider.Thumb>
|
|
193
|
+
<Slider.Popup />
|
|
194
|
+
</Slider.Thumb>
|
|
195
|
+
<Slider.MarkerGroup>
|
|
196
|
+
<Slider.Marker />
|
|
197
|
+
</Slider.MarkerGroup>
|
|
198
|
+
</Slider>
|
|
199
|
+
</Box>
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## With field
|
|
205
|
+
|
|
206
|
+
Compose with `Field` and `Field.Label` for a labeled slider. Set `accessibilityLabel` on `Slider` to match the visible label text.
|
|
207
|
+
|
|
208
|
+
```tsx
|
|
209
|
+
import { useState } from 'react';
|
|
210
|
+
import { Field, Slider } from '@cdx-ui/components';
|
|
211
|
+
|
|
212
|
+
export default function SliderWithFieldDemo() {
|
|
213
|
+
const [value, setValue] = useState(50);
|
|
214
|
+
|
|
215
|
+
return (
|
|
216
|
+
<Field className="w-full">
|
|
217
|
+
<Field.Label>Image Size</Field.Label>
|
|
218
|
+
<Slider
|
|
219
|
+
value={value}
|
|
220
|
+
onChange={setValue}
|
|
221
|
+
min={0}
|
|
222
|
+
max={100}
|
|
223
|
+
step={1}
|
|
224
|
+
accessibilityLabel="Image Size"
|
|
225
|
+
>
|
|
226
|
+
<Slider.Rail>
|
|
227
|
+
<Slider.Track />
|
|
228
|
+
</Slider.Rail>
|
|
229
|
+
<Slider.Thumb>
|
|
230
|
+
<Slider.Popup />
|
|
231
|
+
</Slider.Thumb>
|
|
232
|
+
</Slider>
|
|
233
|
+
</Field>
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
## With icons
|
|
239
|
+
|
|
240
|
+
Decorative icons on each end — a common volume or intensity control pattern. Mark icons `aria-hidden` because the slider exposes the value via `accessibilityLabel`.
|
|
241
|
+
|
|
242
|
+
```tsx
|
|
243
|
+
import { useState } from 'react';
|
|
244
|
+
import { Box, Icon, Slider } from '@cdx-ui/components';
|
|
245
|
+
import { VolumeDown, VolumeUp } from '@cdx-ui/icons';
|
|
246
|
+
|
|
247
|
+
export default function SliderWithIconsDemo() {
|
|
248
|
+
const [value, setValue] = useState(50);
|
|
249
|
+
|
|
250
|
+
return (
|
|
251
|
+
<Box className="w-full flex-row items-center gap-3">
|
|
252
|
+
<Icon as={VolumeDown} color="secondary" className="shrink-0" aria-hidden />
|
|
253
|
+
<Box className="min-w-0 flex-1">
|
|
254
|
+
<Slider
|
|
255
|
+
value={value}
|
|
256
|
+
onChange={setValue}
|
|
257
|
+
min={0}
|
|
258
|
+
max={100}
|
|
259
|
+
step={1}
|
|
260
|
+
accessibilityLabel="Volume"
|
|
261
|
+
>
|
|
262
|
+
<Slider.Rail>
|
|
263
|
+
<Slider.Track />
|
|
264
|
+
</Slider.Rail>
|
|
265
|
+
<Slider.Thumb>
|
|
266
|
+
<Slider.Popup />
|
|
267
|
+
</Slider.Thumb>
|
|
268
|
+
</Slider>
|
|
269
|
+
</Box>
|
|
270
|
+
<Icon as={VolumeUp} color="secondary" className="shrink-0" aria-hidden />
|
|
271
|
+
</Box>
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
## Disabled
|
|
277
|
+
|
|
278
|
+
```tsx
|
|
279
|
+
import { Slider } from '@cdx-ui/components';
|
|
280
|
+
|
|
281
|
+
export default function SliderDisabledDemo() {
|
|
282
|
+
return (
|
|
283
|
+
<Slider isDisabled defaultValue={30} min={0} max={100} accessibilityLabel="Disabled volume">
|
|
284
|
+
<Slider.Rail>
|
|
285
|
+
<Slider.Track />
|
|
286
|
+
</Slider.Rail>
|
|
287
|
+
<Slider.Thumb>
|
|
288
|
+
<Slider.Popup />
|
|
289
|
+
</Slider.Thumb>
|
|
290
|
+
</Slider>
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
## API
|
|
296
|
+
|
|
297
|
+
### Slider
|
|
298
|
+
|
|
299
|
+
Root container that manages value, range (`min`/`max`/`step`), orientation, and disabled state. On web the root is a grouping element (`role="group"`); each `Slider.Thumb` is the focusable slider control.
|
|
300
|
+
|
|
301
|
+
| Prop | Type | Default | Description |
|
|
302
|
+
| --- | --- | --- | --- |
|
|
303
|
+
| `className?` | `string` | — | — |
|
|
304
|
+
| `children?` | `ReactNode` | — | — |
|
|
305
|
+
| `orientation?` | `'horizontal' \| 'vertical'` | — | — |
|
|
306
|
+
| `min?` | `number` | ``0`` | Minimum selectable value. |
|
|
307
|
+
| `max?` | `number` | ``100`` | Maximum selectable value. |
|
|
308
|
+
| `step?` | `number` | ``1`` | Increment used to snap value updates and generate automatic `Slider.MarkerGroup` marks. |
|
|
309
|
+
| `isDisabled?` | `boolean` | ``false`` | Disables pointer, keyboard, and screen reader interaction. |
|
|
310
|
+
| `value?` | `number \| readonly number[]` | — | — |
|
|
311
|
+
| `defaultValue?` | `number \| readonly number[]` | — | Initial uncontrolled value. Defaults to `min`. Initial uncontrolled thumb values. |
|
|
312
|
+
| `onChange?` | `((value: number) => void) \| ((value: number[]) => void)` | — | Called while the value changes. Called while any thumb value changes. |
|
|
313
|
+
| `onChangeComplete?` | `((value: number) => void) \| ((value: number[]) => void)` | — | Called when a pointer, keyboard, or screen reader interaction completes. |
|
|
314
|
+
| `color?` | `'action' \| 'danger' \| 'warning' \| 'success' \| 'info'` | ``action`` | Semantic color token for the track fill and thumb border. |
|
|
315
|
+
|
|
316
|
+
Inherits all [`ViewProps`](https://reactnative.dev/docs/view#props).
|
|
317
|
+
|
|
318
|
+
| Attribute | Values | Description |
|
|
319
|
+
| ------------------ | -------------------------- | ------------------------------------------- |
|
|
320
|
+
| `data-orientation` | `horizontal` \| `vertical` | Slider axis |
|
|
321
|
+
| `data-disabled` | `true` \| `false` | Disabled state |
|
|
322
|
+
| `data-dragging` | `true` \| `false` | Active drag state |
|
|
323
|
+
| `data-hover` | `true` \| `false` | Whether a thumb is hovered (web) |
|
|
324
|
+
| `data-focus` | `true` \| `false` | Whether a thumb is focused |
|
|
325
|
+
| `data-values` | string | Comma-separated thumb values (e.g. `20,80`) |
|
|
326
|
+
| `data-min` | string | Minimum value |
|
|
327
|
+
| `data-max` | string | Maximum value |
|
|
328
|
+
|
|
329
|
+
## Sub-components
|
|
330
|
+
|
|
331
|
+
### Slider.Rail
|
|
332
|
+
|
|
333
|
+
Full track background and hit area for tap and drag interactions. Accepts `Slider.Track` as a child for the filled portion.
|
|
334
|
+
|
|
335
|
+
| Prop | Type | Default | Description |
|
|
336
|
+
| --- | --- | --- | --- |
|
|
337
|
+
| `className?` | `string` | — | — |
|
|
338
|
+
| `children?` | `ReactNode` | — | — |
|
|
339
|
+
| `asChild?` | `boolean` | — | — |
|
|
340
|
+
|
|
341
|
+
Inherits all [`ViewProps`](https://reactnative.dev/docs/view#props).
|
|
342
|
+
|
|
343
|
+
### Slider.Track
|
|
344
|
+
|
|
345
|
+
Filled portion of the rail that reflects the current value and semantic `color` token. Width (horizontal) or height (vertical) is computed automatically.
|
|
346
|
+
|
|
347
|
+
| Prop | Type | Default | Description |
|
|
348
|
+
| --- | --- | --- | --- |
|
|
349
|
+
| `className?` | `string` | — | — |
|
|
350
|
+
| `children?` | `ReactNode` | — | — |
|
|
351
|
+
| `asChild?` | `boolean` | — | — |
|
|
352
|
+
|
|
353
|
+
Inherits all [`ViewProps`](https://reactnative.dev/docs/view#props).
|
|
354
|
+
|
|
355
|
+
### Slider.Thumb
|
|
356
|
+
|
|
357
|
+
Draggable thumb control. Pass `index` for range sliders (`0` for the first thumb, `1` for the second). Each thumb is individually focusable with `role="slider"` on web and `accessibilityRole="adjustable"` on native. Compose optional `Slider.Popup` as a child to show a value tooltip on hover, focus, or drag.
|
|
358
|
+
|
|
359
|
+
| Prop | Type | Default | Description |
|
|
360
|
+
| --- | --- | --- | --- |
|
|
361
|
+
| `className?` | `string` | — | — |
|
|
362
|
+
| `children?` | `ReactNode` | — | Either children or a render prop that receives a boolean reflecting whether the component is currently pressed. |
|
|
363
|
+
| `index?` | `number` | — | Zero-based thumb index. Defaults to `0` for single-value sliders. |
|
|
364
|
+
| `asChild?` | `boolean` | — | — |
|
|
365
|
+
|
|
366
|
+
Inherits all [`PressableProps`](https://reactnative.dev/docs/pressable#props).
|
|
367
|
+
|
|
368
|
+
### Slider.Popup
|
|
369
|
+
|
|
370
|
+
Optional value tooltip rendered inside `Slider.Thumb`. Omit when no tooltip is needed. Defaults to the formatted numeric value; pass `children` for a custom label.
|
|
371
|
+
|
|
372
|
+
| Prop | Type | Default | Description |
|
|
373
|
+
| --- | --- | --- | --- |
|
|
374
|
+
| `className?` | `string` | — | — |
|
|
375
|
+
| `children?` | `ReactNode` | — | — |
|
|
376
|
+
| `asChild?` | `boolean` | — | — |
|
|
377
|
+
|
|
378
|
+
Inherits all [`ViewProps`](https://reactnative.dev/docs/view#props).
|
|
379
|
+
|
|
380
|
+
### Slider.MarkerGroup
|
|
381
|
+
|
|
382
|
+
Optional container for step marks along the rail. When a single template `Slider.Marker` (without `value`) is provided, the group clones it at each `step` interval between `min` and `max`.
|
|
383
|
+
|
|
384
|
+
| Prop | Type | Default | Description |
|
|
385
|
+
| --- | --- | --- | --- |
|
|
386
|
+
| `className?` | `string` | — | — |
|
|
387
|
+
| `children?` | `ReactNode` | — | — |
|
|
388
|
+
| `asChild?` | `boolean` | — | — |
|
|
389
|
+
|
|
390
|
+
Inherits all [`ViewProps`](https://reactnative.dev/docs/view#props).
|
|
391
|
+
|
|
392
|
+
### Slider.Marker
|
|
393
|
+
|
|
394
|
+
Individual step mark. For single-value sliders, marks at or below the current value render filled. For ranges, marks inside `[values[0], values[n-1]]` render filled. Omit `value` for auto step cloning inside `Slider.MarkerGroup`.
|
|
395
|
+
|
|
396
|
+
| Prop | Type | Default | Description |
|
|
397
|
+
| --- | --- | --- | --- |
|
|
398
|
+
| `className?` | `string` | — | — |
|
|
399
|
+
| `children?` | `ReactNode` | — | — |
|
|
400
|
+
| `asChild?` | `boolean` | — | — |
|
|
401
|
+
| `value?` | `number` | — | — |
|
|
402
|
+
|
|
403
|
+
Inherits all [`ViewProps`](https://reactnative.dev/docs/view#props).
|
|
404
|
+
|
|
405
|
+
## Anatomy
|
|
406
|
+
|
|
407
|
+
| `data-slot` | Element |
|
|
408
|
+
| --------------------- | ------------------------------------------ |
|
|
409
|
+
| `slider` | Root container |
|
|
410
|
+
| `slider-rail` | Full track background and interaction area |
|
|
411
|
+
| `slider-track` | Filled track segment |
|
|
412
|
+
| `slider-thumb` | Draggable value control |
|
|
413
|
+
| `slider-popup` | Optional value tooltip |
|
|
414
|
+
| `slider-marker-group` | Step marks container |
|
|
415
|
+
| `slider-marker` | Individual step mark |
|
|
416
|
+
|
|
417
|
+
## Accessibility
|
|
418
|
+
|
|
419
|
+
On web, the root uses `role="group"` and each thumb uses `role="slider"` with value bounds derived from its neighbours. Arrow keys adjust the focused thumb; Home and End move it to its current bounds.
|
|
420
|
+
|
|
421
|
+
On native, each thumb uses `accessibilityRole="adjustable"` and responds to increment and decrement actions. Its numeric `accessibilityValue` is normalized to 0–100 while `text` announces the formatted value.
|
|
422
|
+
|
|
423
|
+
Give each thumb a distinct `accessibilityLabel` in range sliders. The root label names the group. The rail, track, marks, and popup are hidden from the accessibility tree.
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# Stack (https://design.candescent.com/docs/components/stack)
|
|
2
|
+
|
|
3
|
+
Resources: [Storybook](https://victorious-wave-0daadf00f.6.azurestaticapps.net/?path=/story/layout-vstack--default)
|
|
4
|
+
|
|
5
|
+
`HStack` and `VStack` arrange children along the horizontal or vertical axis.
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { HStack, VStack } from '@cdx-ui/components';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Horizontal stack
|
|
12
|
+
|
|
13
|
+
Use `HStack` to arrange related content in a row.
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { Box, HStack, Text } from '@cdx-ui/components';
|
|
17
|
+
|
|
18
|
+
export default function StackHorizontalDemo() {
|
|
19
|
+
return (
|
|
20
|
+
<HStack space="md">
|
|
21
|
+
<Box className="rounded-lg border border-stroke-secondary bg-surface-secondary px-4 py-3">
|
|
22
|
+
<Text>Checking</Text>
|
|
23
|
+
</Box>
|
|
24
|
+
<Box className="rounded-lg border border-stroke-secondary bg-surface-secondary px-4 py-3">
|
|
25
|
+
<Text>Savings</Text>
|
|
26
|
+
</Box>
|
|
27
|
+
<Box className="rounded-lg border border-stroke-secondary bg-surface-secondary px-4 py-3">
|
|
28
|
+
<Text>Credit</Text>
|
|
29
|
+
</Box>
|
|
30
|
+
</HStack>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Vertical stack
|
|
36
|
+
|
|
37
|
+
Use `VStack` to arrange related content in a column.
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
import { Box, Text, VStack } from '@cdx-ui/components';
|
|
41
|
+
|
|
42
|
+
export default function StackVerticalDemo() {
|
|
43
|
+
return (
|
|
44
|
+
<VStack space="md" className="w-full max-w-sm">
|
|
45
|
+
<Box className="rounded-lg border border-stroke-secondary bg-surface-secondary px-4 py-3">
|
|
46
|
+
<Text>Account details</Text>
|
|
47
|
+
</Box>
|
|
48
|
+
<Box className="rounded-lg border border-stroke-secondary bg-surface-secondary px-4 py-3">
|
|
49
|
+
<Text>Transfer settings</Text>
|
|
50
|
+
</Box>
|
|
51
|
+
<Box className="rounded-lg border border-stroke-secondary bg-surface-secondary px-4 py-3">
|
|
52
|
+
<Text>Notifications</Text>
|
|
53
|
+
</Box>
|
|
54
|
+
</VStack>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Spacing
|
|
60
|
+
|
|
61
|
+
Use `space` to apply a token-based gap between children. Both components support `xs` through `6xl`.
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
import { Box, HStack, Text, VStack } from '@cdx-ui/components';
|
|
65
|
+
|
|
66
|
+
const SPACES = ['xs', 'md', 'xl', '3xl'] as const;
|
|
67
|
+
|
|
68
|
+
export default function StackSpacingDemo() {
|
|
69
|
+
return (
|
|
70
|
+
<VStack space="lg">
|
|
71
|
+
{SPACES.map((space) => (
|
|
72
|
+
<VStack key={space} space="xs">
|
|
73
|
+
<Text size="sm" color="secondary">
|
|
74
|
+
{space}
|
|
75
|
+
</Text>
|
|
76
|
+
<HStack space={space}>
|
|
77
|
+
<Box className="size-8 rounded-md bg-surface-action-strong" />
|
|
78
|
+
<Box className="size-8 rounded-md bg-surface-action-strong" />
|
|
79
|
+
<Box className="size-8 rounded-md bg-surface-action-strong" />
|
|
80
|
+
</HStack>
|
|
81
|
+
</VStack>
|
|
82
|
+
))}
|
|
83
|
+
</VStack>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Reversed order
|
|
89
|
+
|
|
90
|
+
Set `reversed` to reverse the visual order of children along the stack axis. Source and screen-reader order remain unchanged.
|
|
91
|
+
|
|
92
|
+
```tsx
|
|
93
|
+
import { Box, HStack, Text, VStack } from '@cdx-ui/components';
|
|
94
|
+
|
|
95
|
+
// The on-strong text class is allowed because this demo paints the surface itself. See "Text on a
|
|
96
|
+
// colored surface" on the Styling and customization page.
|
|
97
|
+
function NumberedItem({ children }: { children: string }) {
|
|
98
|
+
return (
|
|
99
|
+
<Box className="size-10 items-center justify-center rounded-lg bg-surface-action-strong">
|
|
100
|
+
<Text className="text-content-action-on-strong">{children}</Text>
|
|
101
|
+
</Box>
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export default function StackReversedDemo() {
|
|
106
|
+
return (
|
|
107
|
+
<VStack space="lg">
|
|
108
|
+
<VStack space="xs">
|
|
109
|
+
<Text size="sm" color="secondary">
|
|
110
|
+
Default
|
|
111
|
+
</Text>
|
|
112
|
+
<HStack space="sm">
|
|
113
|
+
<NumberedItem>1</NumberedItem>
|
|
114
|
+
<NumberedItem>2</NumberedItem>
|
|
115
|
+
<NumberedItem>3</NumberedItem>
|
|
116
|
+
</HStack>
|
|
117
|
+
</VStack>
|
|
118
|
+
<VStack space="xs">
|
|
119
|
+
<Text size="sm" color="secondary">
|
|
120
|
+
Reversed
|
|
121
|
+
</Text>
|
|
122
|
+
<HStack space="sm" reversed>
|
|
123
|
+
<NumberedItem>1</NumberedItem>
|
|
124
|
+
<NumberedItem>2</NumberedItem>
|
|
125
|
+
<NumberedItem>3</NumberedItem>
|
|
126
|
+
</HStack>
|
|
127
|
+
</VStack>
|
|
128
|
+
</VStack>
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## API
|
|
134
|
+
|
|
135
|
+
`HStack` and `VStack` share the same layout props and inherit React Native `ViewProps`.
|
|
136
|
+
|
|
137
|
+
### HStack
|
|
138
|
+
|
|
139
|
+
| Prop | Type | Default | Description |
|
|
140
|
+
| --- | --- | --- | --- |
|
|
141
|
+
| `className?` | `string` | — | — |
|
|
142
|
+
| `children?` | `React.ReactNode` | — | — |
|
|
143
|
+
| `ref?` | `React.Ref<View>` | — | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). |
|
|
144
|
+
| `space?` | `'xs' \| 'sm' \| 'md' \| 'lg' \| 'xl' \| '2xl' \| '3xl' \| '4xl' \| '5xl' \| '6xl'` | — | Token-based gap between children. |
|
|
145
|
+
| `reversed?` | `boolean` | `false` | Reverses the visual order of children along the stack axis. Source order and screen-reader order stay unchanged. |
|
|
146
|
+
| `key?` | `React.Key \| null` | — | — |
|
|
147
|
+
|
|
148
|
+
Inherits all [`ViewProps`](https://reactnative.dev/docs/view#props).
|
|
149
|
+
|
|
150
|
+
### VStack
|
|
151
|
+
|
|
152
|
+
| Prop | Type | Default | Description |
|
|
153
|
+
| --- | --- | --- | --- |
|
|
154
|
+
| `className?` | `string` | — | — |
|
|
155
|
+
| `children?` | `React.ReactNode` | — | — |
|
|
156
|
+
| `ref?` | `React.Ref<View>` | — | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). |
|
|
157
|
+
| `space?` | `'xs' \| 'sm' \| 'md' \| 'lg' \| 'xl' \| '2xl' \| '3xl' \| '4xl' \| '5xl' \| '6xl'` | — | Token-based gap between children. |
|
|
158
|
+
| `reversed?` | `boolean` | `false` | Reverses the visual order of children along the stack axis. Source order and screen-reader order stay unchanged. |
|
|
159
|
+
| `key?` | `React.Key \| null` | — | — |
|
|
160
|
+
|
|
161
|
+
Inherits all [`ViewProps`](https://reactnative.dev/docs/view#props).
|