jordond /kmpalette

🎨 A Compose multiplatform port for Androidx Palette. Generate a color palette from an image.

★ 299⑂ 12👁 1⑃ 259● 21▤ 14
KotlinMITCreated 2023-09-11palette.materialkolor.com/
下载:4.0.04.0.0 ↓4.0.02026-08-28
+0
日增长
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

Discussions

Latest release

4.0.0 4.0.0 2026-08-28
4.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                                 |
|----------------------|---------------

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON