jordond /kmpalette
🎨 A Compose multiplatform port for Androidx Palette. Generate a color palette from an image.
★ 299⑂ 12👁 1⑃ 259● 21▤ 14
+0
Daily
299
stars
12
forks
1
watchers
259
prs
21
issues
14
releases
README
!Maven Central
!badge-android
!badge-ios
!badge-desktop
!badge-js
!badge-wasm
A Kotlin Multiplatform library for generating color palettes from images, including the dominant
color. You can use this library in combination
with MaterialKolor to generate dynamic Material
themes based on images.
Supports loading images from several sources, see Loaders.
Note: This is a port of
the androidx.palette
library.
Table of Contents
- What's New in 4.0
- Platforms
- Architecture
- Inspiration
- Dynamic Material Themes
- Setup
- Version Catalog
- Standalone Palette (No Compose)
- Usage
- One-shot Generation
- PaletteResult
- Dominant Color
- Generate a color Palette
- Selecting Swatches
- Swatch Colors
- Caching
- Loaders
- Migration
- Feature Requests
- Contributing
- License
- Changes from the original source
What's New in 4.0
Version 4.0 is a significant rewrite. The highlights:
- androidx-palette is now a dependency-free Kotlin Multiplatform module. It no longer depends
on Compose or Skiko. Palette.Builder now takes raw pixel data (IntArray + width + height)
instead of an ImageBitmap, and downscaling is a pure-Kotlin nearest-neighbour implementation.
- New kmpalette-loader module (published as loader) containing the ImageBitmapLoader
interface, so extensions can
depend on the loader contract without pulling in all of core.
- New Maven coordinates. The group is now com.materialkolor.palette and the core artifact is
named core.
- PaletteResult: a sealed Loading/Success/Error result type replaces the previous
ad-hoc state handling.
- One-shot APIs: ImageBitmap.generatePalette() and ImageBitmap.rememberGeneratePalette()
for when you don't need a full state object.
- SwatchTarget: a Kotlin-friendly sealed interface over Target, with Palette.get(target)
operator access.
- ByteArrayLoader moved into core. The extensions-bytearray artifact is gone.
- Dedicated composables per loader (rememberBase64PaletteState, rememberNetworkPaletteState,
rememberPlatformFilePaletteState, and so on) so you no longer wire loaders up by hand.
- extensions-file now uses FileKit instead of Okio.
- The macosX64 target was removed. Kotlin/Native no longer supports Intel macOS, so all
artifacts now publish macosArm64 only.
- No Material 3 dependency. Dominant-color composables no longer fall back to
MaterialTheme.colorScheme, so defaultColor and defaultOnColor are always required and the
library makes no assumption about your design system.
- One cache default. A single top-level DEFAULT_CACHE_SIZE replaces the per-class constants.
- Painter composables live in com.kmpalette.extensions.painter, alongside the resource and
drawable ones. The duplicates in com.kmpalette are gone.
See the Migration Guide for upgrade instructions.
Platforms
| Artifact | Android | Desktop | iOS | macOS | JS | WASM |
|----------------------|:-------:|:-------:|:---:|:-----:|:--:|:----:|
| androidx-palette | ✅Top issues
#222Doesn't work on IOS3 comments · 2025-07-11#197java.lang.IllegalStateException: Size is unspecified using Painter class2 comments · 2024-11-24#221Executing an app with `jsBrowserProductionRun` that uses a library which calls `rememberDominantColorState()` fails1 comments · 2025-05-09#121Alpha must be between 0 and 2551 comments · 2024-03-12#1Dependency Dashboard0 comments · 2023-09-11
Discussions
#198Is library still mantained?1 comments · 2025-01-08#59Generating swatches from a Painter2 comments · 2023-11-28
Latest release
4.0.0 4.0.0 2026-08-284.0.0 4.0 is a significant rewrite. The Maven group changed, three modules are gone, androidx-palette no longer depends on Compose, and every dominant-colour composable now requires explicit default colours. Start with the Migration Guide. Breaking Changes New Maven coordinates. The group changed from com.kmpalette to com.materialkolor.palette, and two artifacts were renamed. Kotlin package names (imports) have not changed. | Module | Old Coordinate | New Coordinate | |----------------------|---------------