Using ColorThief and OKLCH to Build Adaptive, Accessible UIUsing ColorThief and OKLCH to Build Adaptive, Accessible UI
The network for creativity
Join 1.25M professional creatives like you
Connect with clients, get discovered, and run your business 100% commission-free
Creatives on Contra have earned over $150M and we are just getting started
I explored ColorThief today, a JavaScript library that extracts a dominant color and a palette from an image. One useful application is a music player whose background picks up colors from the album artwork.
In v3, palette extraction uses OKLCH by default, grouping colors by their perceived similarity. It also provides swatches such as Vibrant and Muted, plus contrast ratios against black and white.
I’d use those colors for backgrounds and decorative accents while keeping error, status and primary action colors consistent. After adjusting a background’s lightness or saturation, contrast needs checking again.
For a catalog with fixed product images, I’d save the palette during image processing rather than extract it every time someone opens a card. The goal is to let the interface adapt to its content while keeping its hierarchy and readability predictable.
Back to feed
The network for creativity
Join 1.25M professional creatives like you
Connect with clients, get discovered, and run your business 100% commission-free
Creatives on Contra have earned over $150M and we are just getting started