
Painter loading images from URIs for Compose UIs, wrapping Coil in a minimal, preconfigured implementation focused solely on image retrieval without animation or extra features.
Load images from a URL into Jetpack Compose and Compose Multiplatform apps with one function. rememberUriPainter() returns a Painter you pass to Image, with no loader to configure.
Image composable and anything else that draws a Painter. No custom image component to learn.Add the library to commonMain. It is published to Maven Central:
kotlin {
sourceSets {
commonMain.dependencies {
implementation("com.composables:compose-uri-painter:1.4.1")
}
}
}Show an image from the network by passing its URL to rememberUriPainter() and the result to Image:
import androidx.compose.foundation.Image
import androidx.compose.runtime.Composable
import com.composables.uripainter.rememberUriPainter
@Composable
fun Photo() {
Image(
painter = rememberUriPainter("https://images.unsplash.com/photo-1476673160081-cf065607f449?q=80&w=1920"),
contentDescription = "Mountain lake at sunrise",
)
}The image is transparent while it loads and appears once it is available.
Fade the image in instead of showing it at once by passing a duration as crossfade:
import kotlin.time.Duration.Companion.milliseconds
Image(
painter = rememberUriPainter(url, crossfade = 300.milliseconds),
contentDescription = null,
)Without crossfade, the image appears immediately.
Fill the available space and crop the overflow by passing ContentScale.Crop to both rememberUriPainter() and Image:
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale
Image(
painter = rememberUriPainter(url, contentScale = ContentScale.Crop),
contentDescription = null,
modifier = Modifier.fillMaxSize(),
contentScale = ContentScale.Crop,
)rememberUriPainter() uses ContentScale.Fit by default, matching Image.
[!WARNING] Pass the same
contentScaletorememberUriPainter()andImage. If they differ, the image can stretch or jump while it loads and fades in.
Play an animated GIF by passing its URL, the same way as any other image:
Image(
painter = rememberUriPainter("https://example.com/animation.gif"),
contentDescription = null,
)contentScale to rememberUriPainter() and Image.android.permission.INTERNET permission in AndroidManifest.xml to load images from the network.Load images from a URL into Jetpack Compose and Compose Multiplatform apps with one function. rememberUriPainter() returns a Painter you pass to Image, with no loader to configure.
Image composable and anything else that draws a Painter. No custom image component to learn.Add the library to commonMain. It is published to Maven Central:
kotlin {
sourceSets {
commonMain.dependencies {
implementation("com.composables:compose-uri-painter:1.4.1")
}
}
}Show an image from the network by passing its URL to rememberUriPainter() and the result to Image:
import androidx.compose.foundation.Image
import androidx.compose.runtime.Composable
import com.composables.uripainter.rememberUriPainter
@Composable
fun Photo() {
Image(
painter = rememberUriPainter("https://images.unsplash.com/photo-1476673160081-cf065607f449?q=80&w=1920"),
contentDescription = "Mountain lake at sunrise",
)
}The image is transparent while it loads and appears once it is available.
Fade the image in instead of showing it at once by passing a duration as crossfade:
import kotlin.time.Duration.Companion.milliseconds
Image(
painter = rememberUriPainter(url, crossfade = 300.milliseconds),
contentDescription = null,
)Without crossfade, the image appears immediately.
Fill the available space and crop the overflow by passing ContentScale.Crop to both rememberUriPainter() and Image:
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale
Image(
painter = rememberUriPainter(url, contentScale = ContentScale.Crop),
contentDescription = null,
modifier = Modifier.fillMaxSize(),
contentScale = ContentScale.Crop,
)rememberUriPainter() uses ContentScale.Fit by default, matching Image.
[!WARNING] Pass the same
contentScaletorememberUriPainter()andImage. If they differ, the image can stretch or jump while it loads and fades in.
Play an animated GIF by passing its URL, the same way as any other image:
Image(
painter = rememberUriPainter("https://example.com/animation.gif"),
contentDescription = null,
)contentScale to rememberUriPainter() and Image.android.permission.INTERNET permission in AndroidManifest.xml to load images from the network.