Inputs
Inputsicon

Copy field

Read-only value field with a trailing button that copies it to the clipboard.

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
val clipboard = LocalClipboardManager.current
var copied by remember { mutableStateOf(false) }
val token = "cv_live_8f2a91"
OutlinedTextField(
    value = token,
    onValueChange = {},
    readOnly = true,
    trailingIcon = {
        IconButton(onClick = {
            clipboard.setText(AnnotatedString(token))
            copied = true
        }) {
            Icon(
                if (copied) Icons.Filled.Check else Icons.Filled.ContentCopy,
                contentDescription = "Copy",
            )
        }
    },
)