An implementation of a Lightbox for Jetpack Compose. Press an image anywhere in your layout to open a gallery of images.
compose-lightbox.mp4
- For Android: SDK level 23+
- Compose Multiplatform 1.11 or higher
This library currently supports Android and iOS. For older Android phones, use version 1.x without Multiplatform support.
This library depends on Coil 3 for image loading and display. Follow the Quick Start instructions to connect it a networking library like Ktor or OkHttp.
Once a regular AsyncImage() loads successfully in your app, you can integrate ComposeLightbox.
Add the ComposeLightbox dependency to the build.gradle of your app:
implementation("io.github.x-sheep:compose-lightbox:2.0.0")- Add
LightboxHostabove your Scaffold, to make sure the overlay covers the entire app screen. - Create a list of
PhotoItemobjects to describe each image. - Display the images in your layout with
LightboxImage. This composable will automatically add a Click handler.
Simple example:
import io.github.xsheep.composelightbox.*
@Composable
fun Gallery() {
LightboxHost {
Scaffold { padding ->
val photoList = remember {
listOf<PhotoItem>() // Add your photos here
}
LazyColumn(contentPadding = padding) {
items(photoList) {
LightboxImage(photoList, it, Modifier.size(300.dp))
}
}
}
}
}If your layout is changing size when the Lightbox opens and closes, you can try increasing the window insets used in your Scaffold:
Scaffold(contentWindowInsets = WindowInsets.mandatorySystemGestures.union(WindowInsets.displayCutout))Copyright (c) 2025-2026 Lennard Sprong. MIT License