mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-20 12:23:02 +00:00
docs(multi-select): add "Custom slot" example
This commit is contained in:
parent
c141aa8d35
commit
453ac707b9
2 changed files with 39 additions and 0 deletions
|
@ -13,6 +13,12 @@ By default, items will be ordered alphabetically based on the `item.text` value.
|
||||||
{id: "2", text: "Fax"}]}"
|
{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
|
### No alphabetical ordering
|
||||||
|
|
||||||
To prevent alphabetical item ordering, pass an empty function to the `sortItem` prop.
|
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