Feedback
Feedbackanimated

Skeleton loader

A content-shaped placeholder with a shimmer sweep while data loads.

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 SkeletonRow() {
    val shimmer by rememberInfiniteTransition(label = "sk").animateFloat(
        initialValue = 0f, targetValue = 1f,
        animationSpec = infiniteRepeatable(tween(1100)), label = "x",
    )
    fun Modifier.shimmer() = drawWithCache {
        val brush = Brush.linearGradient(
            colors = listOf(Color(0x22888888), Color(0x55888888), Color(0x22888888)),
            start = Offset(size.width * (shimmer - 0.3f), 0f),
            end = Offset(size.width * (shimmer + 0.3f), 0f),
        )
        onDrawBehind { drawRect(brush) }
    }
    Row(verticalAlignment = Alignment.CenterVertically) {
        Box(Modifier.size(40.dp).clip(CircleShape)
            .background(MaterialTheme.colorScheme.surfaceVariant).shimmer())
        Spacer(Modifier.width(12.dp))
        Column(verticalArrangement = Arrangement.spacedBy(6.dp)) {
            Box(Modifier.height(10.dp).width(120.dp).clip(CircleShape)
                .background(MaterialTheme.colorScheme.surfaceVariant).shimmer())
            Box(Modifier.height(10.dp).width(80.dp).clip(CircleShape)
                .background(MaterialTheme.colorScheme.surfaceVariant).shimmer())
        }
    }
}