Images and resources
Images, icons, fonts and texts that ship with your app are resources. In Compose Multiplatform they go into one folder, and work the same on Android, iOS, desktop and web. You only need a text editor and Gradle.
Example
// File: composeApp/src/commonMain/composeResources/drawable/landscape.png
Image(
painter = painterResource(Res.drawable.landscape),
contentDescription = "Hills at sunset",
)
Setup
Add the resources library in composeApp/build.gradle.kts. Use the same version as your Compose plugin:
kotlin {
sourceSets {
commonMain.dependencies {
implementation("org.jetbrains.compose.components:components-resources:1.12.2")
}
}
}
Projects made with the Kotlin Multiplatform wizard already have it.
The folder
Make a composeResources folder next to your kotlin folder, with one subfolder per kind of file:
composeApp/src/commonMain/
├── kotlin/ your code
└── composeResources/
├── drawable/ images: PNG, JPEG, WebP, BMP, SVG, XML vectors
├── font/ fonts: TTF, OTF
├── values/ texts: strings.xml
└── files/ anything else, read as bytes
Copy files in with any file manager. Then build once, or run ./gradlew generateComposeResClass. Gradle makes a Kotlin object called Res with one entry per file:
| File | In code |
|---|---|
drawable/landscape.png |
Res.drawable.landscape |
drawable/ic_rocket.xml |
Res.drawable.ic_rocket |
font/inter_medium.ttf |
Res.font.inter_medium |
<string name="app_name"> in values/strings.xml |
Res.string.app_name |
The file name, without the extension, becomes a Kotlin name. Use lowercase letters, digits and _, like ic_rocket.xml. Two files with the same name and a different extension clash.
Res is in the package <your project>.generated.resources. Your editor offers the import; if it doesn't, build again.
Images: PNG and JPEG
Load any image with painterResource and show it with Image:

Image(
painter = painterResource(Res.drawable.landscape),
contentDescription = "Hills at sunset",
contentScale = ContentScale.Crop,
modifier = Modifier.size(280.dp, 160.dp).clip(MaterialTheme.shapes.large),
)
contentScale says how the image fits its box. ContentScale.Crop fills the box and cuts off what sticks out; Fit shows the whole image; FillBounds stretches it:

Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
listOf(ContentScale.Fit, ContentScale.Crop, ContentScale.FillBounds).forEach { scale ->
Image(
painter = painterResource(Res.drawable.landscape),
contentDescription = null,
contentScale = scale,
modifier = Modifier.size(120.dp).background(MaterialTheme.colorScheme.surfaceContainerHighest),
)
}
}
Use .clip(shape) to round the corners. See the Shapes guide.
Always set contentDescription for screen readers, or null for images that are only decoration.
Icons: XML vectors and SVG
For icons, use vector files. They stay sharp at any size.
- XML vector drawables (
.xml, the Android format) work on all platforms. - SVG works on desktop, iOS and web, but not on Android. There it throws an error at runtime.
If your app runs on Android, convert SVGs to XML vectors. Use the vd-tool command line tool from the Android SDK, or an online "SVG to vector drawable" converter.

Row(horizontalArrangement = Arrangement.spacedBy(8.dp), verticalAlignment = Alignment.CenterVertically) {
// Icon tints the drawing with the content color. Good for one-color icons.
Button(onClick = {}) {
Icon(painterResource(Res.drawable.ic_rocket), contentDescription = null, Modifier.size(ButtonDefaults.IconSize))
Spacer(Modifier.size(ButtonDefaults.IconSpacing))
Text(stringResource(Res.string.launch))
}
IconButton(onClick = {}) {
Icon(painterResource(Res.drawable.ic_rocket), contentDescription = "Launch")
}
// Image keeps the colors of the file. Use it for colored icons.
Image(painterResource(Res.drawable.leaf), contentDescription = "Leaf", Modifier.size(32.dp))
}
Iconpaints the whole drawing in one color, the current content color. That makes one-color icons follow the theme. See the Colors guide.Imagekeeps the colors of the file. Use it for logos and colored drawings.
Material's own icons are also available as a library: Icons.Filled.Home from material-icons-core (a few common icons) and material-icons-extended (all of them). These libraries are no longer updated. For newer icons, download them as SVG or XML vectors from Material Symbols and add them as files.
Textures
To repeat a small image across a background, load it as an ImageBitmap with imageResource, and paint it with an ImageShader:

val tile = imageResource(Res.drawable.tile)
Box(
Modifier
.size(280.dp, 140.dp)
.clip(MaterialTheme.shapes.large)
.background(ShaderBrush(ImageShader(tile, TileMode.Repeated, TileMode.Repeated))),
contentAlignment = Alignment.Center,
) {
Surface(shape = MaterialTheme.shapes.medium) {
Text("Text on a texture", Modifier.padding(12.dp))
}
}
TileMode.Repeated repeats the image in both directions. TileMode.Mirror flips every second copy, so the edges match.
Texts
Put texts in composeResources/values/strings.xml:
<resources>
<string name="app_name">Trail Notes</string>
<string name="greeting">Hello, %1$s!</string>
</resources>

Column {
Text(stringResource(Res.string.app_name), style = MaterialTheme.typography.titleLarge)
// %1$s in the XML is replaced by the first argument.
Text(stringResource(Res.string.greeting, "Ada"))
}
For other languages, add values-de/strings.xml, values-fr/strings.xml and so on with the same names. The right one is picked from the system language.
Outside a composable, use getString(Res.string.app_name). It is a suspend function.
Other files
Anything in composeResources/files/ is read as bytes, with the path as a string:
val json = Res.readBytes("files/trails.json").decodeToString()
readBytes is a suspend function. Call it from a LaunchedEffect or a coroutine. For a file another library opens itself, like a video, get its URI with Res.getUri("files/intro.mp4").
Dark mode and screen density
Folders can have qualifiers. The app picks the best match:
drawable-dark/logo.pngis used in dark mode,drawable/logo.pngotherwise.drawable-xxhdpi/photo.pngis used on high-density screens. Without it,drawable/photo.pngis scaled.values-de/strings.xmlis used when the system language is German.
The file name must be the same in every folder. In code it's still Res.drawable.logo.
The app icon
The app icon is not a Compose resource. Each platform reads it from its own place, before your app starts.
Desktop
The window icon, shown in the title bar and task bar, comes from a resource:
fun main() = application {
Window(
onCloseRequest = ::exitApplication,
title = "Trail Notes",
icon = painterResource(Res.drawable.app_icon),
) { App() }
}
The icon of the installed app comes from files in build.gradle.kts. Each system wants its own format:
compose.desktop {
application {
nativeDistributions {
windows { iconFile.set(project.file("icons/app.ico")) }
macOS { iconFile.set(project.file("icons/app.icns")) }
linux { iconFile.set(project.file("icons/app.png")) }
}
}
}
Make the .ico and .icns files from a 1024 × 1024 PNG with any icon converter.
Android
The launcher icon lives in composeApp/src/androidMain/res/, not in composeResources.
The simplest way: put a square PNG in each density folder, all named ic_launcher.png:
| Folder | Size |
|---|---|
mipmap-mdpi |
48 × 48 |
mipmap-hdpi |
72 × 72 |
mipmap-xhdpi |
96 × 96 |
mipmap-xxhdpi |
144 × 144 |
mipmap-xxxhdpi |
192 × 192 |
AndroidManifest.xml points to it with android:icon="@mipmap/ic_launcher". The wizard project already has this line, so you only replace the files.
Newer Android versions cut icons into a circle or other shape. For full control, add an adaptive icon: mipmap-anydpi-v26/ic_launcher.xml with a <background> and a <foreground> layer, each 108 × 108 dp with the important part in the middle 72 dp.
iOS
The icon is in the Xcode project: iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/. Recent Xcode versions need only one 1024 × 1024 PNG. Replace the PNG in that folder, and keep its name, or update Contents.json next to it.
Web
Put a favicon.ico or PNG next to index.html in src/wasmJsMain/resources/, and add <link rel="icon" href="favicon.png"> to the <head> of index.html.
Summary
| You want | Write |
|---|---|
| A picture | Image(painterResource(Res.drawable.photo), "Description") |
| Fill a box with it | contentScale = ContentScale.Crop |
| An icon in a button | Icon(painterResource(Res.drawable.ic_add), null) |
| A repeated texture | ShaderBrush(ImageShader(imageResource(Res.drawable.tile), TileMode.Repeated, TileMode.Repeated)) |
| A text | stringResource(Res.string.app_name) |
| Any file | Res.readBytes("files/data.json") |
| A font | Font(Res.font.inter_regular), see the Typography guide |
| The desktop window icon | Window(icon = painterResource(Res.drawable.app_icon)) |