Get all colors to create a select element
Hello Filament's lovers.
Is there a way to get colors defined in (default tailwind and extended) in array ?
I'd like to build a select element to pick one in form.
If not, do you have any tips to get colors to accomplish this ?
5 Replies
If you're using Filament forms for the select, you can have a look at
Filament\Support\Colors\Color
class. I believe it has all (or most?) tailwind stuffDo you need all of the tailwind colors or all of the colors registered on the panel?
all tailwind colors defined in tailwind conf, so default and eventually, these in extend array
Could possibly save the colors in a json file, then import them into your TW config file. And for the select, in the options callback use File::json() to get the json file and parse the array into the options you need.
But I think you going to have a bigger issue in that even doing this will not guarantee that the color will be in the final built css file. If a class isn’t used in the files TW scans it won’t be used in the build. You would have to use TW’s safelist option to force it to always include all of the colors.
Thanks awcodes for your point of view. It opens me this way: I create an Enum class, where I define each color needed, get tints of hint with
And to retrieve these colors I call
And using rgb values, no problem in final css 🙂
thanks