Toggles
Togglesanimated

Record

Record button morphing a red dot into a stop square while recording.

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 RecordToggle() {
  var recording by remember { mutableStateOf(false) }
  val radius by animateDpAsState(
    targetValue = if (recording) 4.dp else 12.dp,
    label = "radius",
  )
  val size by animateDpAsState(
    targetValue = if (recording) 16.dp else 22.dp,
    label = "size",
  )
  Box(
    contentAlignment = Alignment.Center,
    modifier = Modifier
      .size(40.dp)
      .clip(CircleShape)
      .border(2.dp, Color(0xFFEF4444), CircleShape)
      .clickable { recording = !recording },
  ) {
    Box(
      Modifier
        .size(size)
        .clip(RoundedCornerShape(radius))
        .background(Color(0xFFEF4444)),
    )
  }
}