mirror of
https://github.com/shoelace-style/webawesome.git
synced 2026-01-12 12:09:26 +00:00
Add docs on setting multiple values in select (#1508)
This commit is contained in:
committed by
GitHub
parent
b09a48bec4
commit
e73e32fb71
@@ -250,7 +250,11 @@ Note that multi-select options may wrap, causing the control to expand verticall
|
||||
|
||||
### Setting Initial Values
|
||||
|
||||
Use the `value` attribute to set the initial selection. When using `multiple`, use space-delimited values to select more than one option.
|
||||
Use the `value` attribute to set the initial selection.
|
||||
|
||||
When using `multiple`, the `value` _attribute_ uses space-delimited values to select more than one option.
|
||||
Note that `sl-option` values cannot contain spaces for this reason. If accessing or setting the `value` _property_
|
||||
through Javascript, `value` is an array.
|
||||
|
||||
```html:preview
|
||||
<sl-select value="option-1 option-2" multiple clearable>
|
||||
@@ -261,6 +265,11 @@ Use the `value` attribute to set the initial selection. When using `multiple`, u
|
||||
</sl-select>
|
||||
```
|
||||
|
||||
```js
|
||||
const select = document.querySelector('sl-select[multiple]');
|
||||
select.value = ['option-1', 'option-2']
|
||||
```
|
||||
|
||||
```jsx:react
|
||||
import SlDivider from '@shoelace-style/shoelace/dist/react/divider';
|
||||
import SlOption from '@shoelace-style/shoelace/dist/react/option';
|
||||
|
||||
Reference in New Issue
Block a user