PHPackages                             charlieetienne/palette-generator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. charlieetienne/palette-generator

ActiveLibrary

charlieetienne/palette-generator
================================

A PHP library for generating tailwind v4 color palettes from a hexadecimal color

v1.1(10mo ago)2345↓100%MITPHPPHP ^8.4CI passing

Since Jul 7Pushed 5mo agoCompare

[ Source](https://github.com/CharlieEtienne/palette-generator)[ Packagist](https://packagist.org/packages/charlieetienne/palette-generator)[ RSS](/packages/charlieetienne-palette-generator/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

Palette Generator
=================

[](#palette-generator)

A PHP library for generating Tailwind v4 color palettes from a hexadecimal color.

Installation
------------

[](#installation)

```
composer require charlieetienne/palette-generator
```

Requirements
------------

[](#requirements)

This package only requires PHP 8.4.

For Laravel users, this package will be auto-discovered thanks to `PaletteGeneratorServiceProvider`.

Usage
-----

[](#usage)

```
use CharlieEtienne\PaletteGenerator\PaletteGenerator;

// Generate a Tailwind 4 like palette from a hex color
$palette = PaletteGenerator::generatePalette('#3b82f6');

// Returns this array:
// [
//    50 => "oklch(0.97 0.014 254.604)"
//    100 => "oklch(0.932 0.027 255.585)"
//    200 => "oklch(0.882 0.045 254.128)"
//    300 => "oklch(0.809 0.084 251.813)"
//    400 => "oklch(0.707 0.14 254.624)"
//    500 => "oklch(0.623 0.188 259.815)"
//    600 => "oklch(0.546 0.22 262.881)"
//    700 => "oklch(0.488 0.222 264.376)"
//    800 => "oklch(0.424 0.185 265.638)"
//    900 => "oklch(0.379 0.141 265.522)"
//    950 => "oklch(0.282 0.091 267.935)"
// ]
```

How it works
------------

[](#how-it-works)

This package was inspired by [uihue](https://www.uihue.com/) from Matteo Frana. The author detailed his method in an article called ["The Mystery of Tailwind Colors (v4)"](https://dev.to/matfrana/the-mystery-of-tailwind-colors-v4-hjh), but the short version is:

1. Use the DeltaE 2000 algorithm to iterate through the Tailwind CSS colors and find the nearest match
2. Apply this delta with a smoothing effect as we approach the extreme light and dark hues to preserve the color's distinctive features.

I simply tried to do the same in PHP.

Example
-------

[](#example)

[![palette-generator](https://private-user-images.githubusercontent.com/9772943/463911748-b3a27896-4b05-4b01-9b71-9e4d178c05a3.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzQxOTc4NTUsIm5iZiI6MTc3NDE5NzU1NSwicGF0aCI6Ii85NzcyOTQzLzQ2MzkxMTc0OC1iM2EyNzg5Ni00YjA1LTRiMDEtOWI3MS05ZTRkMTc4YzA1YTMucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MDMyMiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjAzMjJUMTYzOTE1WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MDcxYjUwNzYyMDk4Zjk5YWJlMjZmNmZiN2IwZGI4NDkyMGYwM2VhMzQ2MWU5NTcyOGZkNTIzYWI3NmFjMjQ4MSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.XjW6N922ujTY0dh-fmEbJGeIPZAOZrQ9R6OOVwqHIPw)](https://private-user-images.githubusercontent.com/9772943/463911748-b3a27896-4b05-4b01-9b71-9e4d178c05a3.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzQxOTc4NTUsIm5iZiI6MTc3NDE5NzU1NSwicGF0aCI6Ii85NzcyOTQzLzQ2MzkxMTc0OC1iM2EyNzg5Ni00YjA1LTRiMDEtOWI3MS05ZTRkMTc4YzA1YTMucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MDMyMiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjAzMjJUMTYzOTE1WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MDcxYjUwNzYyMDk4Zjk5YWJlMjZmNmZiN2IwZGI4NDkyMGYwM2VhMzQ2MWU5NTcyOGZkNTIzYWI3NmFjMjQ4MSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.XjW6N922ujTY0dh-fmEbJGeIPZAOZrQ9R6OOVwqHIPw)Performance
-----------

[](#performance)

Due to the algorithm itself, it may be more resource-intensive than other solutions.

Here are some benchmarks:

`CharlieEtienne\PaletteGenerator::generatePalette('#ad70e5')`

- Execution time: ~0.00012 seconds per run
- Benchmark speed: ~8,155 ops/sec

Tests were run on a MB Air M2, inside a Laravel app.

To improve performance, you may want to cache the results.

Contribute
----------

[](#contribute)

Your PR is welcome!

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance64

Regular maintenance activity

Popularity16

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

2

Last Release

308d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/87a9f2bb61802ac686a254580641ce7c2000c22b6894987de47d62c9a3e1fa9f?d=identicon)[CharlieEtienne](/maintainers/CharlieEtienne)

---

Top Contributors

[![CharlieEtienne](https://avatars.githubusercontent.com/u/9772943?v=4)](https://github.com/CharlieEtienne "CharlieEtienne (15 commits)")

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/charlieetienne-palette-generator/health.svg)

```
[![Health](https://phpackages.com/badges/charlieetienne-palette-generator/health.svg)](https://phpackages.com/packages/charlieetienne-palette-generator)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
