An implementation of a Lightbox for Jetpack Compose. Press an image anywhere in your layout to open a gallery of images.
- Android SDK level 16+
- Jetpack Compose version 2025.11.00 or higher
Platforms other than Android are currently not supported.
Make sure Jitpack is added to the list of package repositories in settings.gradle.
dependencyResolutionManagement {
repositories {
... // other repositories
maven { url 'https://jitpack.io' }
}
}Then add the dependency to the build.gradle of your app:
dependencies {
... // other dependencies
implementation 'com.github.x-sheep:compose-lightbox:0.1.5'
}- 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 Lennard Sprong. MIT License