You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An alternate `selectedLabel` prop can be specified on each option.
116
+
Multiple values can be selected if the `multiple` prop is `true`. In this mode an "Apply" button will render below the options list. The newly selected values are not applied until the user activates this button. If the user clicks the "Cancel" button, presses escape, or click out of the open menu, their changes will be discarded.
139
117
140
118
```jsx
141
119
initialState = {
142
-
value:'name',
120
+
value:[],
143
121
};
144
122
145
123
constoptions= [
146
-
{ value:'name', label:'Name', selectedLabel:'Sort by name' },
147
-
{ value:'date', label:'Date', selectedLabel:'Sort by date' },
Multiple values can be selected if the `multiple` prop is `true`. In this mode an "Apply" button will render below the options list. The newly selected values are not applied until the user activates this button. If the user clicks the "Cancel" button, presses escape, or click out of the open menu, their changes will be discarded.
151
+
Warning: Consult with your UX designer prior to using this option. We are considering deprecating this behavior in order to simplify multi-select menus.
152
+
153
+
The default multi-select behavior can be overridden with the `applyImmediately` prop. In this mode, a 'Done' button will still render for consistency but the values will be immediately applied. If the user escapes or clicks out of the open menu, their changes will be discarded.
Warning: Consult with your UX designer prior to using this option. We are considering deprecating this behavior in order to simplify multi-select menus.
194
+
Use the `width` prop to customize the width of the button.
205
195
206
-
The default multi-select behavior can be overridden with the `applyImmediately` prop. In this mode, a 'Done' button will still render for consistency but the values will be immediately applied. If the user escapes or clicks out of the open menu, their changes will be discarded.
196
+
```jsx
197
+
constoptions= [
198
+
{ value:'hello', label:'Hello' },
199
+
{ value:'world', label:'World' },
200
+
{ value:'hi', label:'Hi' },
201
+
{ value:'mom', label:'Mom' },
202
+
];
203
+
204
+
<ButtonSelect
205
+
options={options}
206
+
value={state.value}
207
+
onChange={value=> {
208
+
console.log('New Value:', value);
209
+
setState({ value });
210
+
}}
211
+
width="100px"
212
+
/>;
213
+
```
214
+
215
+
## Option properties
216
+
217
+
### Custom selected labels
218
+
219
+
An alternate `selectedLabel` prop can be specified on each option.
207
220
208
221
```jsx
209
222
initialState = {
210
-
value:[],
223
+
value:'name',
211
224
};
212
225
213
226
constoptions= [
214
-
{ value:'one', label:'One' },
215
-
{ value:'two', label:'Two' },
216
-
{ value:'three', label:'Three' },
217
-
{ value:'four', label:'Four' },
218
-
{ value:'five', label:'Five' },
219
-
{ value:'six', label:'Six' },
220
-
{ value:'seven', label:'Seven' },
221
-
{ value:'eight', label:'Eight' },
222
-
{ value:'nine', label:'Nine' },
223
-
{ value:'ten', label:'Ten' },
227
+
{ value:'name', label:'Name', selectedLabel:'Sort by name' },
228
+
{ value:'date', label:'Date', selectedLabel:'Sort by date' },
0 commit comments