---
title: "expandableItems"
description: "Adds a series of items, that will be expanded/collapsed according to the [ExpandableState]

Example of an expandable list:"
type: "function"
---

<div class='type'>Function</div>


<a id='references'></a>
<div class='sourceset sourceset-android'>Android</div>


```kotlin
public fun ScalingLazyListScope.expandableItems(
    state: ExpandableState,
    count: Int,
    key: ((index: Int) -> Any)? = null,
    itemContent: @Composable BoxScope.(index: Int) -> Unit,
)
```


Adds a series of items, that will be expanded/collapsed according to the `ExpandableState`

Example of an expandable list:

#### Parameters

| | |
| --- | --- |
| state | The `ExpandableState` connected to these items. |
| count | The number of items |
| key | a factory of stable and unique keys representing the item. Using the same key for multiple items in the list is not allowed. Type of the key should be saveable via Bundle on Android. If null is passed the position in the list will represent the key. When you specify the key the scroll position will be maintained based on the key, which means if you add/remove items before the current visible item the item with the given key will be kept as the first visible one. |
| itemContent | the content displayed by a single item |




## Code Examples
### ExpandableWithItemsSample
```kotlin
@Composable
fun ExpandableWithItemsSample() {
    val expandableState = rememberExpandableState()
    val sampleItem: @Composable (String) -> Unit = { label ->
        Chip(label = { Text(label) }, onClick = {}, secondaryLabel = { Text("line 2 - Secondary") })
    }
    val items = List(10) { "Item $it" }
    val top = items.take(3)
    val rest = items.drop(3)
    ScalingLazyColumn(modifier = Modifier.fillMaxSize()) {
        items(top.size) { sampleItem(top[it]) }
        expandableItems(expandableState, rest.size) { sampleItem(rest[it]) }
        expandableButton(expandableState) {
            OutlinedCompactChip(
                label = {
                    Text("Show More")
                    Spacer(Modifier.size(6.dp))
                    Icon(painterResource(R.drawable.ic_expand_more_24), "Expand")
                },
                onClick = { expandableState.expanded = true },
            )
        }
    }
}
```

