Selects
Selects

Cycle select

A labelled value flanked by arrows that cycle through options in place.

Economy

Installation

caveui components are copy-paste Jetpack Compose built entirely on Material 3 — there's no caveui dependency to add. Make sure Material 3 is on your classpath (it ships with the Compose BOM), then copy the Usage snippet below into your project.

kotlin
// build.gradle.kts (module)
dependencies {
    implementation(platform("androidx.compose:compose-bom:2025.06.00"))
    implementation("androidx.compose.material3:material3")
}

Usage

kotlin
@Composable
fun CycleSelect(options: List<String>) {
    var index by remember { mutableStateOf(0) }
    Row(
        verticalAlignment = Alignment.CenterVertically,
        horizontalArrangement = Arrangement.spacedBy(8.dp),
    ) {
        IconButton(onClick = {
            index = (index - 1 + options.size) % options.size
        }) { Icon(Icons.Filled.ChevronLeft, "Previous") }
        Text(
            options[index],
            Modifier.weight(1f),
            textAlign = TextAlign.Center,
            style = MaterialTheme.typography.titleMedium,
        )
        IconButton(onClick = {
            index = (index + 1) % options.size
        }) { Icon(Icons.Filled.ChevronRight, "Next") }
    }
}