Grab it on my codepen

The selected color is stored in Alpine.js state and can be accessed via:

$store.colorPicker.selectedColor

Or via the hidden input field for form submission.

..

Lightweight Alpine.js v3 Color Picker Component – Clean, Fast & Zero Hassle

I needed a super simple color picker for a side project and didn't want to drag in 50kb+ libraries or deal with complicated setup. So I built this tiny thing using only Alpine.js v3 + Tailwind CSS. It's exactly the kind of component I love: copy → paste → done.

Why I made this (and why you might want it)

Most color pickers are either massive full-featured things (great, but overkill) or too basic and missing the little details. This one sits right in the middle:

Real-world places this shines

I already used it in a couple of quick tools:

Basically anywhere you want users to pick a color without leaving Alpine/Tailwind land.

How to drop it into your project

Just include Alpine & Tailwind (CDN is fine for prototypes), copy the div[x-data="colorPicker()"] block and the script at the bottom. Tweak the colors array to whatever palette your project needs – corporate colors, brand kit, Tailwind defaults, whatever.

Made with ❤️ in Sweden 🇸🇪

Feel free to steal it, modify it – MIT licensed, go wild.

WhatsApp Get a consulting