Collapse item with AList
See original GitHub issueI want to build a collapsed items list. But item
slot doesn’t work as expected.
How to create a simple collapse with AList
?
Here is the code :
<script lang="ts" setup>
import { ref } from 'vue'
const items = [{
title: 'Apparence',
subtitle: 'Apparence desc...',
},
{
title: 'Network',
subtitle: 'Network desc...',
}]
const selected = ref(new Set())
</script>
<template>
<AList
v-model="selected"
:items="items"
multi
class="[--a-list-gap:0.25rem]"
>
<template #item="{ item, itemIndex }">
<ATypography
:title="[item.title, 'text-red']"
:subtitle="item.subtitle"
/>
<div v-if="selected.has(itemIndex)">I want to put collapsed content here, but this slot is not displayed ! Title isn't red.</div>
</template>
<template #append="{ itemIndex }">
<div
i-fa-chevron-right
class="transition-transform text-gray hover:bg-opacity-0"
:class="selected.has(itemIndex) && 'rotate-90'"
/>
</template>
</AList>
</template>
Issue Analytics
- State:
- Created 10 months ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
How can I target each item in a list with collapsible items?
I have a list of div elements, each containing a header and a body section. Only the header of each item is initially...
Read more >How to Create a Collapsible List of Items in ... - HTML Goodies
In this article, you will see how to use a little bit of standard JavaScript to hide and display items in a list....
Read more >Bootstrap Collapse - W3Schools
The .collapse class indicates a collapsible element (a <div> in our example); this is the content that will be shown or hidden with...
Read more >Expand & collapse groups of items in a list.
My ticket this week: Show documents with the same file name as a version stack. Tech used: Javascript, React, lodash. Some background.
Read more >Nested list collapsing script - How To Create
This example has been collapsed using the script. It is set to auto collapse child branches when sibling branches are expanded. Like the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This
ACollapse
component has nothing to do with UI. You can use it multiple way. I’m not sure what you mean by decouple it from actual UI.Here an example without UI.
Result :
With
ABtn
:With
AAvatar
:And how I use it in my app :
That’s it ! Ok, I close this issue even if in its current state it is not possible to do collapsing with
AList
…