Sliders
Medium
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 SnapSlider() {
val labels = listOf("Low", "Medium", "High")
var index by remember { mutableStateOf(1) }
val pos by animateFloatAsState(index / 2f, label = "snap")
Column {
Box(Modifier.fillMaxWidth().height(36.dp)) {
Box(Modifier.fillMaxWidth().height(6.dp)
.align(Alignment.CenterStart)
.clip(CircleShape)
.background(MaterialTheme.colorScheme.surfaceVariant))
labels.forEachIndexed { i, _ ->
Box(
Modifier.align(BiasAlignment(i / 2f * 2 - 1, 0f))
.size(10.dp).clip(CircleShape)
.background(MaterialTheme.colorScheme.outline)
.clickable { index = i },
)
}
Box(
Modifier.align(BiasAlignment(pos * 2 - 1, 0f))
.size(22.dp).clip(CircleShape)
.background(MaterialTheme.colorScheme.primary),
)
}
Text(labels[index], style = MaterialTheme.typography.labelLarge)
}
}