Overlays
Overlays
Image lightbox
A dimmed lightbox that frames a photo with a close control and a position counter.
2 / 6
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 Lightbox(index: Int, total: Int, onClose: () -> Unit) {
Dialog(
onDismissRequest = onClose,
properties = DialogProperties(usePlatformDefaultWidth = false),
) {
Box(Modifier.fillMaxSize().background(Color(0xF20A0A0A))) {
Box(
Modifier.align(Alignment.Center).fillMaxWidth(0.86f)
.aspectRatio(1f)
.clip(MaterialTheme.shapes.large)
.background(Color(0xFF1F2937)),
)
IconButton(
onClick = onClose,
modifier = Modifier.align(Alignment.TopEnd).padding(8.dp),
) { Icon(Icons.Filled.Close, "Close", tint = Color.White) }
Text(
"${index + 1} / $total",
Modifier.align(Alignment.BottomCenter).padding(24.dp),
color = Color.White,
style = MaterialTheme.typography.labelMedium,
)
}
}
}