Skip to content

Commit

Permalink
Add docs on setting multiple values in select (#1508)
Browse files Browse the repository at this point in the history
  • Loading branch information
ak-beam authored Aug 14, 2023
1 parent b09a48b commit e73e32f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion docs/pages/components/select.md
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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';
Expand Down

0 comments on commit e73e32f

Please sign in to comment.