How to add more options to color palettes?

AI-generated summary

In a discussion titled “How to add more options to color palettes?” in the Support category, alltiagocom observes that some color palettes (like Dracula) offer more customization than others and asks how to extend palette options. awesomerobot clarifies that direct color overrides aren’t possible via the palette admin UI but can be achieved through themes. alltiagocom asks if editing files via SSH would work, to which awesomerobot responds that such changes may be overwritten during updates. Instead, they recommend creating a custom theme with a modified about.json file (as shown in the Dracula theme example) to add new color definitions that appear in the admin UI. Alternatively, CSS overrides in a theme’s common file can be used — for example, setting --primary-low: red; — with available variables viewable via browser inspector. alltiagocom thanks them for the detailed guidance and plans to test the methods.

I noticed that some palettes have more options to set colors than others.
For example the Dracula palette has way more options than other palettes.

I saw this post, but I don’t know if this is relevant:

This seems related to Themes, but palettes don’t have that option to edit the code and add Color definitions.

Yes, a theme can directly override individual colors — this isn’t possible via the color palette admin area

Thank you for sharing that.

So, to someone who’s not yet very familiar with some of the stuff, that means I need to SSH my server (if that’s what the terminology is?) and find that json file, make those changes, and then it would be reflected in the UI?

If so, then we can override the default variables, as well as adding new ones, right?

if you did it this way, I think it would probably get overwritten by the next Discourse update… so generally you want to leave the existing palettes alone

If you want to create a new palette with all the extended color overrides, and make it so users can select that palette, the simplest way is to create a theme and upload it.

All you would have to do in the theme itself is edit about.json to contain the color definitions… there’s an example here:

Once the theme is added to the site, the included color palette will be added to admin/customize/colors and you can make that user-selectable

Another way to customize our colors is to override them directly with CSS, this would require using a certain theme rather than a specific color palette… but in the theme’s common file you can do something like:

``css
:root {
--primary-low: red;
--secondary: #ff0000;
}
``
you can see all the available colors to override by opening the browser inspector, clicking the HTML element at the top, and doing some scrolling (we have a lot of variables now)

The benefit of this method is that you can do it via the theme editor in the admin UI

There’s a lot to digest here, but I will definitely take some time to read, analyze it, and test it.

Thank you so much for the detailed reply. I saved it to my notes. :raising_hands: