Toggles
Toggles

Card Radio

Bordered selectable card with an icon and a corner check when active.

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 CardRadioGroup() {
  var selected by remember { mutableStateOf(0) }
  Row(horizontalArrangement = Arrangement.spacedBy(12.dp)) {
    repeat(2) { index ->
      val active = index == selected
      Box {
        Box(
          contentAlignment = Alignment.Center,
          modifier = Modifier
            .size(56.dp)
            .clip(RoundedCornerShape(12.dp))
            .border(
              width = 2.dp,
              color = if (active)
                MaterialTheme.colorScheme.primary
              else
                MaterialTheme.colorScheme.outline,
              shape = RoundedCornerShape(12.dp),
            )
            .clickable { selected = index },
        ) {
          Icon(
            imageVector = Icons.Default.Star,
            contentDescription = null,
            tint = MaterialTheme.colorScheme.primary,
          )
        }
        if (active) {
          Icon(
            imageVector = Icons.Default.CheckCircle,
            contentDescription = null,
            tint = MaterialTheme.colorScheme.primary,
            modifier = Modifier
              .align(Alignment.TopEnd)
              .size(18.dp),
          )
        }
      }
    }
  }
}