---
title: "mutableStateSetOf"
description: "Create a instance of [MutableSet]<T> that is observable and can be snapshot.

The returned set iteration order is in the order the items were inserted into the set."
type: "function"
---

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


<a id='references'></a>
<div class='sourceset sourceset-common'>Common</div>


```kotlin
@StateFactoryMarker public fun <T> mutableStateSetOf(): SnapshotStateSet<T>
```


Create a instance of `MutableSet`<T> that is observable and can be snapshot.

The returned set iteration order is in the order the items were inserted into the set.



<div class='sourceset sourceset-common'>Common</div>


```kotlin
@StateFactoryMarker
public fun <T> mutableStateSetOf(vararg elements: T): SnapshotStateSet<T>
```


Create an instance of `MutableSet`<T> that is observable and can be snapshot.

The returned set iteration order is in the order the items were inserted into the set.



## Code Examples
### stateSetSample
```kotlin
fun stateSetSample() {
    @Composable
    fun DaysForAlarm() {
        val days = remember { mutableStateSetOf<DayOfWeek>() }
        Column(Modifier.selectableGroup()) {
            DayOfWeek.entries.forEach { dayOfWeek ->
                Row(
                    modifier =
                        Modifier.toggleable(
                            value = dayOfWeek in days,
                            role = Role.Checkbox,
                            onValueChange = {
                                if (it) {
                                    days.add(dayOfWeek)
                                } else {
                                    days.remove(dayOfWeek)
                                }
                            },
                        )
                ) {
                    Checkbox(checked = dayOfWeek in days, onCheckedChange = null)
                    Text(text = dayOfWeek.name)
                }
            }
        }
    }
}
```

