@ceed/cds 1.34.1 → 1.36.0-next.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/dist/components/Accordions/Accordions.d.ts +1 -0
- package/dist/components/Alert/Alert.d.ts +5 -5
- package/dist/components/Autocomplete/Autocomplete.d.ts +2 -2
- package/dist/components/Avatar/Avatar.d.ts +7 -17
- package/dist/components/Box/Box.d.ts +1 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +6 -5
- package/dist/components/Button/Button.d.ts +3 -2
- package/dist/components/Calendar/Calendar.d.ts +1 -0
- package/dist/components/Card/Card.d.ts +1 -0
- package/dist/components/Checkbox/Checkbox.d.ts +1 -0
- package/dist/components/Chip/Chip.d.ts +1 -0
- package/dist/components/Container/Container.d.ts +6 -1
- package/dist/components/CurrencyInput/CurrencyInput.d.ts +1 -1
- package/dist/components/DialogActions/DialogActions.d.ts +1 -0
- package/dist/components/DialogContent/DialogContent.d.ts +1 -0
- package/dist/components/DialogFrame/DialogFrame.d.ts +1 -1
- package/dist/components/DialogTitle/DialogTitle.d.ts +1 -0
- package/dist/components/Divider/Divider.d.ts +1 -0
- package/dist/components/Drawer/Drawer.d.ts +1 -0
- package/dist/components/Dropdown/Dropdown.d.ts +28 -1
- package/dist/components/FilterableCheckboxGroup/FilterableCheckboxGroup.d.ts +1 -1
- package/dist/components/FormControl/FormControl.d.ts +1 -0
- package/dist/components/FormHelperText/FormHelperText.d.ts +1 -0
- package/dist/components/FormLabel/FormLabel.d.ts +1 -0
- package/dist/components/Grid/Grid.d.ts +1 -0
- package/dist/components/IconButton/IconButton.d.ts +3 -2
- package/dist/components/IconMenuButton/IconMenuButton.d.ts +7 -6
- package/dist/components/InfoSign/InfoSign.d.ts +3 -2
- package/dist/components/Input/Input.d.ts +8 -22
- package/dist/components/InsetDrawer/InsetDrawer.d.ts +1 -0
- package/dist/components/Markdown/Markdown.d.ts +9 -24
- package/dist/components/Menu/Menu.d.ts +2 -1
- package/dist/components/MenuButton/MenuButton.d.ts +10 -8
- package/dist/components/Modal/Modal.d.ts +4 -2
- package/dist/components/NavigationGroup/NavigationGroup.d.ts +3 -2
- package/dist/components/NavigationItem/NavigationItem.d.ts +3 -2
- package/dist/components/Navigator/Navigator.d.ts +5 -4
- package/dist/components/Pagination/Pagination.d.ts +2 -2
- package/dist/components/Radio/Radio.d.ts +1 -0
- package/dist/components/RadioList/RadioList.d.ts +3 -2
- package/dist/components/Select/Select.d.ts +12 -10
- package/dist/components/Sheet/Sheet.d.ts +1 -0
- package/dist/components/Stack/Stack.d.ts +1 -0
- package/dist/components/Stepper/Stepper.d.ts +2 -1
- package/dist/components/Switch/Switch.d.ts +1 -0
- package/dist/components/Table/Table.d.ts +7 -5
- package/dist/components/Tabs/Tabs.d.ts +1 -0
- package/dist/components/Textarea/Textarea.d.ts +8 -20
- package/dist/components/ThemeProvider/ThemeProvider.d.ts +15 -0
- package/dist/components/Tooltip/Tooltip.d.ts +1 -0
- package/dist/components/Typography/Typography.d.ts +1 -0
- package/dist/components/Uploader/Uploader.d.ts +18 -17
- package/dist/components/data-display/Avatar.md +60 -72
- package/dist/components/data-display/Badge.md +197 -181
- package/dist/components/data-display/Chip.md +164 -142
- package/dist/components/data-display/DataTable.md +843 -338
- package/dist/components/data-display/InfoSign.md +1 -3
- package/dist/components/data-display/Markdown.md +93 -125
- package/dist/components/data-display/Table.md +1453 -1007
- package/dist/components/data-display/Typography.md +113 -116
- package/dist/components/feedback/Alert.md +80 -86
- package/dist/components/feedback/CircularProgress.md +32 -36
- package/dist/components/feedback/Dialog.md +25 -17
- package/dist/components/feedback/Modal.md +296 -264
- package/dist/components/feedback/Skeleton.md +125 -89
- package/dist/components/index.d.ts +62 -2
- package/dist/components/inputs/Autocomplete.md +191 -95
- package/dist/components/inputs/Button.md +83 -83
- package/dist/components/inputs/ButtonGroup.md +195 -185
- package/dist/components/inputs/Calendar.md +25 -28
- package/dist/components/inputs/Checkbox.md +11 -29
- package/dist/components/inputs/CurrencyInput.md +4 -4
- package/dist/components/inputs/DatePicker.md +229 -110
- package/dist/components/inputs/DateRangePicker.md +248 -137
- package/dist/components/inputs/FilterableCheckboxGroup.md +115 -55
- package/dist/components/inputs/FormControl.md +75 -69
- package/dist/components/inputs/IconButton.md +229 -205
- package/dist/components/inputs/Input.md +131 -98
- package/dist/components/inputs/MonthPicker.md +186 -84
- package/dist/components/inputs/MonthRangePicker.md +73 -49
- package/dist/components/inputs/PercentageInput.md +15 -31
- package/dist/components/inputs/RadioButton.md +320 -256
- package/dist/components/inputs/RadioList.md +66 -50
- package/dist/components/inputs/RadioTileGroup.md +287 -170
- package/dist/components/inputs/SearchBar.md +82 -60
- package/dist/components/inputs/Select.md +106 -95
- package/dist/components/inputs/Slider.md +153 -102
- package/dist/components/inputs/Switch.md +193 -138
- package/dist/components/inputs/Textarea.md +15 -20
- package/dist/components/inputs/Uploader/Uploader.md +68 -39
- package/dist/components/layout/Box.md +841 -662
- package/dist/components/layout/Container.md +3 -11
- package/dist/components/layout/Grid.md +480 -394
- package/dist/components/layout/Stack.md +739 -566
- package/dist/components/navigation/Breadcrumbs.md +4 -4
- package/dist/components/navigation/Drawer.md +34 -25
- package/dist/components/navigation/Dropdown.md +745 -408
- package/dist/components/navigation/IconMenuButton.md +14 -6
- package/dist/components/navigation/InsetDrawer.md +8 -13
- package/dist/components/navigation/Link.md +1 -2
- package/dist/components/navigation/Menu.md +623 -502
- package/dist/components/navigation/MenuButton.md +18 -10
- package/dist/components/navigation/NavigationGroup.md +19 -50
- package/dist/components/navigation/NavigationItem.md +6 -6
- package/dist/components/navigation/Navigator.md +26 -28
- package/dist/components/navigation/Pagination.md +86 -75
- package/dist/components/navigation/Stepper.md +2 -12
- package/dist/components/navigation/Tabs.md +48 -36
- package/dist/components/surfaces/Accordions.md +89 -172
- package/dist/components/surfaces/Card.md +1094 -709
- package/dist/components/surfaces/Divider.md +562 -412
- package/dist/components/surfaces/Sheet.md +700 -518
- package/dist/guides/ThemeProvider.md +8 -8
- package/dist/index.browser.js +5 -5
- package/dist/index.browser.js.map +4 -4
- package/dist/index.cjs +1082 -1036
- package/dist/index.d.ts +2 -1
- package/dist/index.js +749 -695
- package/framer/index.js +1 -1
- package/package.json +34 -36
|
@@ -52,9 +52,9 @@ When the input has a value, hovering over the component reveals a clear (✕) bu
|
|
|
52
52
|
|
|
53
53
|
```tsx
|
|
54
54
|
<Stack alignItems="flex-start" gap={2}>
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
</Stack>
|
|
55
|
+
<Typography level="body-sm">Hover over the input to reveal the clear (✕) button.</Typography>
|
|
56
|
+
<SearchBar value={value} onChange={setValue} />
|
|
57
|
+
</Stack>
|
|
58
58
|
```
|
|
59
59
|
|
|
60
60
|
## Placeholder
|
|
@@ -63,19 +63,25 @@ Each `SearchBarOption` can include a `placeholder` field that is shown in the te
|
|
|
63
63
|
|
|
64
64
|
```tsx
|
|
65
65
|
<Stack alignItems="flex-start" gap={3}>
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
66
|
+
<Stack alignItems="flex-start" gap={1}>
|
|
67
|
+
<Typography level="body-xs" fontWeight="md">
|
|
68
|
+
No placeholder prop — uses the active option's placeholder
|
|
69
|
+
</Typography>
|
|
70
|
+
<SearchBar showSelect options={SAMPLE_OPTIONS} value={value} onChange={setValue} />
|
|
71
|
+
</Stack>
|
|
72
|
+
<Stack alignItems="flex-start" gap={1}>
|
|
73
|
+
<Typography level="body-xs" fontWeight="md">
|
|
74
|
+
placeholder="Search by keyword" — overrides option-level placeholder
|
|
75
|
+
</Typography>
|
|
76
|
+
<SearchBar
|
|
77
|
+
showSelect
|
|
78
|
+
options={SAMPLE_OPTIONS}
|
|
79
|
+
placeholder="Search by keyword"
|
|
80
|
+
value={value}
|
|
81
|
+
onChange={setValue}
|
|
82
|
+
/>
|
|
83
|
+
</Stack>
|
|
71
84
|
</Stack>
|
|
72
|
-
<Stack alignItems="flex-start" gap={1}>
|
|
73
|
-
<Typography level="body-xs" fontWeight="md">
|
|
74
|
-
placeholder="Search by keyword" — overrides option-level placeholder
|
|
75
|
-
</Typography>
|
|
76
|
-
<SearchBar showSelect options={SAMPLE_OPTIONS} placeholder="Search by keyword" value={value} onChange={setValue} />
|
|
77
|
-
</Stack>
|
|
78
|
-
</Stack>
|
|
79
85
|
```
|
|
80
86
|
|
|
81
87
|
## onSearch
|
|
@@ -84,32 +90,46 @@ Each `SearchBarOption` can include a `placeholder` field that is shown in the te
|
|
|
84
90
|
|
|
85
91
|
```tsx
|
|
86
92
|
<Stack alignItems="flex-start" gap={2}>
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
+
<SearchBar
|
|
94
|
+
showSelect
|
|
95
|
+
options={SAMPLE_OPTIONS}
|
|
96
|
+
value={value}
|
|
97
|
+
onChange={setValue}
|
|
98
|
+
onSearch={setLastSearch}
|
|
99
|
+
/>
|
|
100
|
+
<Typography level="body-sm">value: "{value}"</Typography>
|
|
101
|
+
{lastSearch && (
|
|
102
|
+
<Typography level="body-sm">
|
|
103
|
+
onSearch: [{lastSearch.selectValue}] "{lastSearch.inputValue}"
|
|
104
|
+
</Typography>
|
|
105
|
+
)}
|
|
106
|
+
</Stack>
|
|
93
107
|
```
|
|
94
108
|
|
|
95
109
|
When `showSelect` is `false`, `selectValue` is omitted from the payload entirely — not `undefined` as a key, but absent.
|
|
96
110
|
|
|
97
111
|
```tsx
|
|
98
112
|
<Stack alignItems="flex-start" gap={2}>
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
+
<Typography level="body-sm">
|
|
114
|
+
When <code>showSelect</code> is <code>false</code>, <code>selectValue</code> is omitted from
|
|
115
|
+
the <code>onSearch</code> payload.
|
|
116
|
+
</Typography>
|
|
117
|
+
<SearchBar value={value} onChange={setValue} onSearch={setLastSearch} />
|
|
118
|
+
{lastSearch && (
|
|
119
|
+
<Stack alignItems="flex-start" gap={0.5}>
|
|
120
|
+
<Typography level="body-sm">inputValue: "{lastSearch.inputValue}"</Typography>
|
|
121
|
+
<Typography
|
|
122
|
+
level="body-sm"
|
|
123
|
+
sx={{
|
|
124
|
+
color: lastSearch.selectValue === undefined ? "success.500" : "danger.500"
|
|
125
|
+
}}
|
|
126
|
+
>
|
|
127
|
+
selectValue:{" "}
|
|
128
|
+
{lastSearch.selectValue === undefined ? "undefined ✅" : `"${lastSearch.selectValue}" ❌`}
|
|
129
|
+
</Typography>
|
|
130
|
+
</Stack>
|
|
131
|
+
)}
|
|
132
|
+
</Stack>
|
|
113
133
|
```
|
|
114
134
|
|
|
115
135
|
## Width
|
|
@@ -118,31 +138,33 @@ SearchBar sizes to its content by default. Pass any `Box` width prop to constrai
|
|
|
118
138
|
|
|
119
139
|
```tsx
|
|
120
140
|
<Stack alignItems="flex-start" gap={3}>
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
</
|
|
139
|
-
<
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
</
|
|
145
|
-
|
|
141
|
+
<Stack alignItems="flex-start" gap={1}>
|
|
142
|
+
<Typography level="body-xs" fontWeight="md">
|
|
143
|
+
width="100%" — stretches to parent width
|
|
144
|
+
</Typography>
|
|
145
|
+
<Box
|
|
146
|
+
sx={{
|
|
147
|
+
border: "1px dashed",
|
|
148
|
+
borderColor: "neutral.300",
|
|
149
|
+
padding: 1
|
|
150
|
+
}}
|
|
151
|
+
>
|
|
152
|
+
<SearchBar width="100%" value={value} onChange={setValue} />
|
|
153
|
+
</Box>
|
|
154
|
+
</Stack>
|
|
155
|
+
<Stack alignItems="flex-start" gap={1}>
|
|
156
|
+
<Typography level="body-xs" fontWeight="md">
|
|
157
|
+
width={400} — fixed 400px
|
|
158
|
+
</Typography>
|
|
159
|
+
<SearchBar width={400} value={value} onChange={setValue} />
|
|
160
|
+
</Stack>
|
|
161
|
+
<Stack alignItems="flex-start" gap={1}>
|
|
162
|
+
<Typography level="body-xs" fontWeight="md">
|
|
163
|
+
No width prop — sizes to content (inline-flex default)
|
|
164
|
+
</Typography>
|
|
165
|
+
<SearchBar value={value} onChange={setValue} />
|
|
166
|
+
</Stack>
|
|
167
|
+
</Stack>
|
|
146
168
|
```
|
|
147
169
|
|
|
148
170
|
## Props and Customization
|
|
@@ -54,13 +54,7 @@ const options = [
|
|
|
54
54
|
];
|
|
55
55
|
|
|
56
56
|
function MyComponent() {
|
|
57
|
-
return
|
|
58
|
-
<Select
|
|
59
|
-
label="Choose a pet"
|
|
60
|
-
options={options}
|
|
61
|
-
defaultValue="dog"
|
|
62
|
-
/>
|
|
63
|
-
);
|
|
57
|
+
return <Select label="Choose a pet" options={options} defaultValue="dog" />;
|
|
64
58
|
}
|
|
65
59
|
```
|
|
66
60
|
|
|
@@ -70,11 +64,11 @@ Select supports four visual styles: `outlined` (default), `plain`, `soft`, and `
|
|
|
70
64
|
|
|
71
65
|
```tsx
|
|
72
66
|
<Stack spacing={4}>
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
</Stack>
|
|
67
|
+
<Select defaultValue="dog" options={options} />
|
|
68
|
+
<Select defaultValue="dog" variant="plain" options={options} />
|
|
69
|
+
<Select defaultValue="dog" variant="soft" options={options} />
|
|
70
|
+
<Select defaultValue="dog" variant="solid" options={options} />
|
|
71
|
+
</Stack>
|
|
78
72
|
```
|
|
79
73
|
|
|
80
74
|
```tsx
|
|
@@ -90,10 +84,10 @@ Three sizes are available: `sm`, `md` (default), and `lg`.
|
|
|
90
84
|
|
|
91
85
|
```tsx
|
|
92
86
|
<Stack spacing={4}>
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
</Stack>
|
|
87
|
+
<Select defaultValue="dog" size="sm" options={options} />
|
|
88
|
+
<Select defaultValue="dog" size="md" options={options} />
|
|
89
|
+
<Select defaultValue="dog" size="lg" options={options} />
|
|
90
|
+
</Stack>
|
|
97
91
|
```
|
|
98
92
|
|
|
99
93
|
```tsx
|
|
@@ -108,12 +102,12 @@ Apply semantic colors to communicate intent or state.
|
|
|
108
102
|
|
|
109
103
|
```tsx
|
|
110
104
|
<Stack spacing={4}>
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
</Stack>
|
|
105
|
+
<Select defaultValue="dog" color="primary" options={options} />
|
|
106
|
+
<Select defaultValue="dog" color="neutral" options={options} />
|
|
107
|
+
<Select defaultValue="dog" color="success" options={options} />
|
|
108
|
+
<Select defaultValue="dog" color="danger" options={options} />
|
|
109
|
+
<Select defaultValue="dog" color="warning" options={options} />
|
|
110
|
+
</Stack>
|
|
117
111
|
```
|
|
118
112
|
|
|
119
113
|
```tsx
|
|
@@ -129,11 +123,19 @@ Apply semantic colors to communicate intent or state.
|
|
|
129
123
|
Use `startDecorator` and `endDecorator` to add icons, badges, or other elements beside the select trigger.
|
|
130
124
|
|
|
131
125
|
```tsx
|
|
132
|
-
<Select
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
126
|
+
<Select
|
|
127
|
+
placeholder="Select a pet…"
|
|
128
|
+
startDecorator={<FavoriteBorder />}
|
|
129
|
+
endDecorator={
|
|
130
|
+
<Chip size="sm" color="danger" variant="soft">
|
|
131
|
+
+5
|
|
132
|
+
</Chip>
|
|
133
|
+
}
|
|
134
|
+
sx={{
|
|
135
|
+
width: 240
|
|
136
|
+
}}
|
|
137
|
+
options={options}
|
|
138
|
+
/>
|
|
137
139
|
```
|
|
138
140
|
|
|
139
141
|
```tsx
|
|
@@ -144,11 +146,13 @@ import { Chip } from '@ceed/cds';
|
|
|
144
146
|
placeholder="Select a pet..."
|
|
145
147
|
startDecorator={<FavoriteBorder />}
|
|
146
148
|
endDecorator={
|
|
147
|
-
<Chip size="sm" color="danger" variant="soft"
|
|
149
|
+
<Chip size="sm" color="danger" variant="soft">
|
|
150
|
+
+5
|
|
151
|
+
</Chip>
|
|
148
152
|
}
|
|
149
153
|
options={options}
|
|
150
154
|
sx={{ width: 240 }}
|
|
151
|
-
|
|
155
|
+
/>;
|
|
152
156
|
```
|
|
153
157
|
|
|
154
158
|
## Label and Helper Text
|
|
@@ -157,14 +161,14 @@ The `label` prop renders a form label above the select. The `helperText` prop re
|
|
|
157
161
|
|
|
158
162
|
```tsx
|
|
159
163
|
<>
|
|
160
|
-
|
|
161
|
-
</>
|
|
164
|
+
<Select label="Label" defaultValue="dog" options={options} />
|
|
165
|
+
</>
|
|
162
166
|
```
|
|
163
167
|
|
|
164
168
|
```tsx
|
|
165
169
|
<>
|
|
166
|
-
|
|
167
|
-
</>
|
|
170
|
+
<Select label="Select" helperText="I'm helper text" defaultValue="dog" options={options} />
|
|
171
|
+
</>
|
|
168
172
|
```
|
|
169
173
|
|
|
170
174
|
```tsx
|
|
@@ -184,17 +188,12 @@ Set `error` to `true` to visually indicate a validation error. Combine with `hel
|
|
|
184
188
|
|
|
185
189
|
```tsx
|
|
186
190
|
<>
|
|
187
|
-
|
|
188
|
-
</>
|
|
191
|
+
<Select label="label" error defaultValue="dog" options={options} />
|
|
192
|
+
</>
|
|
189
193
|
```
|
|
190
194
|
|
|
191
195
|
```tsx
|
|
192
|
-
<Select
|
|
193
|
-
label="Pet"
|
|
194
|
-
error
|
|
195
|
-
helperText="This field is required"
|
|
196
|
-
options={options}
|
|
197
|
-
/>
|
|
196
|
+
<Select label="Pet" error helperText="This field is required" options={options} />
|
|
198
197
|
```
|
|
199
198
|
|
|
200
199
|
## Form Control
|
|
@@ -203,9 +202,9 @@ Combining `label`, `helperText`, and `error` produces a complete form field. Her
|
|
|
203
202
|
|
|
204
203
|
```tsx
|
|
205
204
|
<>
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
</>
|
|
205
|
+
<Select label="Label" helperText="I'm helper text" defaultValue="dog" options={options} />
|
|
206
|
+
<Select label="Label" helperText="I'm helper text" defaultValue="dog" error options={options} />
|
|
207
|
+
</>
|
|
209
208
|
```
|
|
210
209
|
|
|
211
210
|
## Required Field
|
|
@@ -222,12 +221,7 @@ Set `required` to mark the field as required. An asterisk is added to the label
|
|
|
222
221
|
```
|
|
223
222
|
|
|
224
223
|
```tsx
|
|
225
|
-
<Select
|
|
226
|
-
label="Pet"
|
|
227
|
-
helperText="This field is required"
|
|
228
|
-
required
|
|
229
|
-
options={options}
|
|
230
|
-
/>
|
|
224
|
+
<Select label="Pet" helperText="This field is required" required options={options} />
|
|
231
225
|
```
|
|
232
226
|
|
|
233
227
|
## Multiple Selection
|
|
@@ -245,12 +239,7 @@ Set `multiple` to allow selecting more than one option. The value becomes an arr
|
|
|
245
239
|
```
|
|
246
240
|
|
|
247
241
|
```tsx
|
|
248
|
-
<Select
|
|
249
|
-
label="Pets"
|
|
250
|
-
multiple
|
|
251
|
-
defaultValue={['dog']}
|
|
252
|
-
options={options}
|
|
253
|
-
/>
|
|
242
|
+
<Select label="Pets" multiple defaultValue={['dog']} options={options} />
|
|
254
243
|
```
|
|
255
244
|
|
|
256
245
|
## Controlled Select
|
|
@@ -259,30 +248,41 @@ Use the `value` and `onChange` props for controlled behavior when you need to sy
|
|
|
259
248
|
|
|
260
249
|
```tsx
|
|
261
250
|
<div>
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
251
|
+
<Select
|
|
252
|
+
{...args}
|
|
253
|
+
options={options}
|
|
254
|
+
value={value}
|
|
255
|
+
onChange={(event, newValue) => {
|
|
256
|
+
setValue(newValue);
|
|
257
|
+
args.onChange?.(event, newValue);
|
|
258
|
+
}}
|
|
259
|
+
/>
|
|
260
|
+
<Select
|
|
261
|
+
{...args}
|
|
262
|
+
options={["dog", "cat", "fish", "bird"] as string[]}
|
|
263
|
+
value={value}
|
|
264
|
+
onChange={(event, newValue) => {
|
|
265
|
+
setValue(newValue);
|
|
266
|
+
args.onChange?.(event, newValue);
|
|
267
|
+
}}
|
|
268
|
+
/>
|
|
269
|
+
<Select
|
|
270
|
+
{...args}
|
|
271
|
+
options={["dog", "cat", "fish", "bird"] as string[]}
|
|
272
|
+
value={[value]}
|
|
273
|
+
onChange={(event, newValue) => {
|
|
274
|
+
setValue(newValue);
|
|
275
|
+
args.onChange?.(event, newValue);
|
|
276
|
+
}}
|
|
277
|
+
multiple
|
|
278
|
+
/>
|
|
279
|
+
</div>
|
|
275
280
|
```
|
|
276
281
|
|
|
277
282
|
```tsx
|
|
278
283
|
const [value, setValue] = useState('dog');
|
|
279
284
|
|
|
280
|
-
<Select
|
|
281
|
-
label="Pet"
|
|
282
|
-
value={value}
|
|
283
|
-
onChange={(event, newValue) => setValue(newValue)}
|
|
284
|
-
options={options}
|
|
285
|
-
/>
|
|
285
|
+
<Select label="Pet" value={value} onChange={(event, newValue) => setValue(newValue)} options={options} />;
|
|
286
286
|
```
|
|
287
287
|
|
|
288
288
|
## Disabled Options
|
|
@@ -308,7 +308,7 @@ const options = [
|
|
|
308
308
|
{ value: 'bird', label: 'Bird' },
|
|
309
309
|
];
|
|
310
310
|
|
|
311
|
-
<Select label="Pet" options={options} defaultValue="dog"
|
|
311
|
+
<Select label="Pet" options={options} defaultValue="dog" />;
|
|
312
312
|
```
|
|
313
313
|
|
|
314
314
|
## Options with Secondary Text
|
|
@@ -317,16 +317,27 @@ Add a `secondaryText` field to display supplementary information below each opti
|
|
|
317
317
|
|
|
318
318
|
```tsx
|
|
319
319
|
<Stack spacing={4} direction="row" alignItems="flex-start">
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
</
|
|
320
|
+
{sizes.map((size) => (
|
|
321
|
+
<Stack key={size} spacing={1}>
|
|
322
|
+
<span
|
|
323
|
+
style={{
|
|
324
|
+
color: "#6366f1",
|
|
325
|
+
fontSize: 12
|
|
326
|
+
}}
|
|
327
|
+
>
|
|
328
|
+
{size}
|
|
329
|
+
</span>
|
|
330
|
+
<Select
|
|
331
|
+
placeholder="Placeholder"
|
|
332
|
+
options={optionsWithSecondaryText}
|
|
333
|
+
sx={{
|
|
334
|
+
minWidth: 200
|
|
335
|
+
}}
|
|
336
|
+
size={size}
|
|
337
|
+
/>
|
|
338
|
+
</Stack>
|
|
339
|
+
))}
|
|
340
|
+
</Stack>
|
|
330
341
|
```
|
|
331
342
|
|
|
332
343
|
```tsx
|
|
@@ -336,7 +347,7 @@ const userOptions = [
|
|
|
336
347
|
{ value: 'sophia', label: 'Sophia Martinez', secondaryText: '(646) 555-0734' },
|
|
337
348
|
];
|
|
338
349
|
|
|
339
|
-
<Select placeholder="Select a contact" options={userOptions}
|
|
350
|
+
<Select placeholder="Select a contact" options={userOptions} />;
|
|
340
351
|
```
|
|
341
352
|
|
|
342
353
|
## Numeric Values
|
|
@@ -345,11 +356,11 @@ Select supports both string and numeric option values. When using numeric values
|
|
|
345
356
|
|
|
346
357
|
```tsx
|
|
347
358
|
<Stack spacing={4}>
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
</Stack>
|
|
359
|
+
<Select defaultValue={1} options={numericOptions} />
|
|
360
|
+
<Select defaultValue={1} variant="plain" options={numericOptions} />
|
|
361
|
+
<Select defaultValue={1} variant="soft" options={numericOptions} />
|
|
362
|
+
<Select defaultValue={1} variant="solid" options={numericOptions} />
|
|
363
|
+
</Stack>
|
|
353
364
|
```
|
|
354
365
|
|
|
355
366
|
```tsx
|
|
@@ -359,7 +370,7 @@ const numericOptions = [
|
|
|
359
370
|
{ value: 3, label: 'Option 3' },
|
|
360
371
|
];
|
|
361
372
|
|
|
362
|
-
<Select options={numericOptions} defaultValue={1}
|
|
373
|
+
<Select options={numericOptions} defaultValue={1} />;
|
|
363
374
|
```
|
|
364
375
|
|
|
365
376
|
## Common Use Cases
|
|
@@ -590,12 +601,12 @@ const options = [
|
|
|
590
601
|
{ value: 2, label: 'Option 2' },
|
|
591
602
|
] as const;
|
|
592
603
|
|
|
593
|
-
<Select<typeof options[number], false>
|
|
604
|
+
<Select<(typeof options)[number], false>
|
|
594
605
|
options={options}
|
|
595
606
|
onChange={(e, val) => {
|
|
596
607
|
// val is typed as number
|
|
597
608
|
}}
|
|
598
|
-
|
|
609
|
+
/>;
|
|
599
610
|
```
|
|
600
611
|
|
|
601
612
|
> **Note**: Select also accepts all Joy UI Select props.
|