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.
..
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.
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:
<input> with x-model → works perfectly with forms, Livewire, Filament, etc.?color=#ff6b6b from the URL and selects it automaticallyI already used it in a couple of quick tools:
Basically anywhere you want users to pick a color without leaving Alpine/Tailwind land.
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.