Replies: 5 comments
-
i try using the ExpandableTile component, the same question for me. {#each list as row}
<ExpandableTile expanded={row.open}>
<div slot="above" on:click={(e) => {
list = list.map(s => {
s.open = false
if (s.id === row.id) {
s.open = true
}
return s
})
console.log('list', list)
}}>
{row.label}
</div>
<div slot="below">
{row.label}
</div>
</ExpandableTile>
{/each} |
Beta Was this translation helpful? Give feedback.
-
You could try something like this: // Demo.svelte
<script>
import { Accordion, AccordionItem } from "carbon-components-svelte";
export let list;
let openId;
</script>
<Accordion>
{#each list as row}
<AccordionItem open={row.id === openId} on:click={() => openId = row.id} ... />
{/each}
</Accordion> |
Beta Was this translation helpful? Give feedback.
-
@malinowskip thanks a lot. but it need click twice. tap an unexpanded item, flash it once, and then close , and click again to expand |
Beta Was this translation helpful? Give feedback.
-
Actually, In my example |
Beta Was this translation helpful? Give feedback.
-
@malinowskip thanks a lot. i noticed that svelte can only bind to an identifier (e.g.
|
Beta Was this translation helpful? Give feedback.
-
in the example i use change the item open filed to control, the field change but the accordion component not change.
I want the control to have only one item open at a time.
in the App.svelte:
in the Demo.svelte:
Beta Was this translation helpful? Give feedback.
All reactions