Naming colors for LVGL displays (works for other display types as well)

I wanted to be able to use the names of colors instead of 6 digit hex numbers. I found this website with the CSS names for over 200 colors. I had a Chatbot covert it to a color table for ESPhome code. I now include it in my YAML files.

Is this useful for other people? Do I need to add more colors?

I use this code to include it.

packages:
  common_files:
    url: https://github.com/agillis/esphome-configs
    ref: main
    files: [common/color.yaml ]
1 Like

Allowing colour names is on my TODO list for the ESPHome LVGL component. The minor drawback to what you implemented is that each of those colours takes up space in flash whether in use or not - admittedly not a lot, but I hate waste :slight_smile:

Yeah I was wondering about that. ESPHome seem very efficient. At the moment I have some very complex YAML files with many pages of widgets and it only takes up about 10% of my 8GB flash so I wasn’t worried about it.

With 8GB you would never have to worry. Though I suspect you actually only have 8MB. Still a lot, even though you are limited to 4MB if you use OTA. I have not yet gone over 2MB for an ESPHome build (in fact not much over 1MB.)

I’m glad you posted this though, like I said I had thought about colour names, but knowing someone wants that is extra motivation to get it done.

Thanks for the the inspiration!

Nice! This is really good stuff. I’ll remove these defaults from my color file.