Hints
Hintsanimated

Copy confirm

A copy control that swaps its label to a confirmation with a check on tap.

Copied

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 CopyConfirm(value: String) {
    val clipboard = LocalClipboardManager.current
    var copied by remember { mutableStateOf(false) }
    LaunchedEffect(copied) {
        if (copied) { delay(1500); copied = false }
    }
    FilledTonalButton(
        onClick = {
            clipboard.setText(AnnotatedString(value))
            copied = true
        },
        shape = RoundedCornerShape(10.dp),
    ) {
        AnimatedContent(targetState = copied, label = "copy") { done ->
            Row(verticalAlignment = Alignment.CenterVertically) {
                Icon(
                    if (done) Icons.Filled.Check else Icons.Filled.ContentCopy,
                    contentDescription = null,
                    modifier = Modifier.size(16.dp),
                    tint = if (done) Color(0xFF16A34A) else LocalContentColor.current,
                )
                Spacer(Modifier.width(6.dp))
                Text(if (done) "Copied" else "Copy")
            }
        }
    }
}