mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 10:21:05 +00:00
feat(multi-select): make MultiSelect
slottable (#1183)
This commit is contained in:
parent
f5594daba6
commit
1017e80198
7 changed files with 71 additions and 17 deletions
|
@ -13,6 +13,12 @@ By default, items will be ordered alphabetically based on the `item.text` value.
|
|||
{id: "2", text: "Fax"}]}"
|
||||
/>
|
||||
|
||||
### Custom slot
|
||||
|
||||
Override the default slot to customize the display of each item. Access the item and index through the `let:` directive.
|
||||
|
||||
<FileSource src="/framed/MultiSelect/MultiSelectSlot" />
|
||||
|
||||
### No alphabetical ordering
|
||||
|
||||
To prevent alphabetical item ordering, pass an empty function to the `sortItem` prop.
|
||||
|
|
33
docs/src/pages/framed/MultiSelect/MultiSelectSlot.svelte
Normal file
33
docs/src/pages/framed/MultiSelect/MultiSelectSlot.svelte
Normal file
|
@ -0,0 +1,33 @@
|
|||
<script>
|
||||
import { MultiSelect } from "carbon-components-svelte";
|
||||
</script>
|
||||
|
||||
<MultiSelect
|
||||
titleText="Contact"
|
||||
label="Select contact methods..."
|
||||
items="{[
|
||||
{ id: '0', text: 'Slack' },
|
||||
{ id: '1', text: 'Email' },
|
||||
{ id: '2', text: 'Fax' },
|
||||
]}"
|
||||
let:item
|
||||
let:index
|
||||
>
|
||||
<div>
|
||||
<strong>{item.text}</strong>
|
||||
</div>
|
||||
<div>
|
||||
id: {item.id} - index:
|
||||
{index}
|
||||
</div>
|
||||
</MultiSelect>
|
||||
|
||||
<style>
|
||||
:global(.bx--list-box__menu-item, .bx--list-box__menu-item__option) {
|
||||
height: auto;
|
||||
}
|
||||
|
||||
:global(.bx--checkbox-label-text) {
|
||||
display: block;
|
||||
}
|
||||
</style>
|
Loading…
Add table
Add a link
Reference in a new issue