[Resolved] Color constants

Home Forums Support [Resolved] Color constants

Home Forums Support Color constants

Viewing 15 posts - 1 through 15 (of 20 total)
  • Author
  • #252502


    I have a dominant color on my site (under development) that I use in a lot of places, various section backgrounds, buttons, etc. For now I manually type them in/select through GeneratePress color selector (for section background, etc), but I already know this must not be the right way to do it.

    Is it possible to somehow define a global color and then use it by name everywhere? For instance if I would like to change it later on, I wouldn’t have to go through all the places I’ve set it.

    Or in general, what would be the best way to handle this, so I have my color somehow defined in only ONE place?


    Lead Developer
    Lead Developer

    Currently this isn’t possible, but I see the point in having a Customizer option for setting the primary color.

    However, making it available in Sections etc.. most likely wouldn’t be possible.

    If you’re worried about that, I would use the custom classes field in Sections instead. Give you sections specific classes, then use CSS to give those classes your primary colors.

    This way if those colors change, you just need to adjust the CSS for each class instead of going through each section.

    Let me know if that makes sense or not 🙂


    Yes, I was already thinking about that as a possible option.
    My question is more like an opinion request, not necessarily a feature request.
    So let’s say I make some class where I set the background color and use that for the sections. What about other places, like buttons, etc, where I also want to use that color? Or in the header, where I set the colors through the customizer? This is already 3 places where I set the same value. I’m a C++ programmer, and having to set the same value more than just once already feels not right.

    So I’m thinking along the lines of a global CSS define of some sort, and I’d just reference that. Is this possible in any way in general? (Note: I’m a near-total beginner of HTML/CSS, so bear with me if the stuff I ask makes no sense 🙂

    Lead Developer
    Lead Developer

    Unfortunately there’s not really such thing as a global variable in CSS – at least not in this sense.

    Your buttons and section classes would all be in the same area, so that wouldn’t be too difficult to switch out the colors (only a few values to change).

    The header is in the Customizer, but again only one setting.

    Not ideal, somewhat repetition needed – however changing 3 or 4 values to change the primary color of your entire website isn’t so bad 🙂



    Not sure how much of an issue/trouble it would be to change/enhance the Color picker now used to include the ability to choose and save up to, say, 4 to 8 colors. The Elementor color picker was recently updated to include this very time-saving feature as was the Beaver Builder a while back. From a lay perspective, the Elementor one looks almost identical to the GP one 🙂

    Perhaps an added feature to GP Premium only at some point?


    Tutorials and tips for GeneratePress, WP Show Posts, WordPress and Elementor

    Lead Developer
    Lead Developer

    Yep, a way to specify the palettes would be nice. A way to control the opacity would be nice as well 😉

    Working on it 🙂


    OK, thanks for your thoughts.

    The palette option is a good idea.

    Anyway, it seems I’m not the only one having thought of the variable idea: https://www.w3.org/TR/css-variables/. Support is on the way too: http://caniuse.com/#feat=css-variables.
    It’s still strange though that this didn’t exist in CSS from the get-go.

    Lead Developer
    Lead Developer

    I’m sure it will happen one day – although we’ll always have to deal with the internet explorers of the world not supporting it 🙂


    Hi Tom

    Is this option to set default colors in the palette likely to happen.



    Lead Developer
    Lead Developer

    Fantastic – many thanks Tom.

    Lead Developer
    Lead Developer

    Hey Tom!

    I’ve been using GeneratePress for a while and I use that filter to set my customizer palette. We are on 2021 now, and CSS variables are a real thing. Do you think it would be possible to use them for the customizer?

    This should include some panel where we can set a color palette (something similar as what Elementor Page Builder does) and then be able to assign those colors as if they were a variable. By this I mean that if we change the color in the palette, it would change for every option that used that color. For example:

    Primary Color
    Secondary Color
    Accent Color
    Text Color
    Extra Color #1
    Extra Color #2

    So that if we set green to the Primary Color and then we use the primary color for different styles in the customizer, If then we change that Primary Color from, lets say, green to blue, every GP customizer element that was using that color would change to blue.

    Customer Support

    Hi there,

    yes, this is something we’re looking into. It’s quite a complicated update and we want to make sure we do this right and its future proof.


    Hi David, is there a topic about this feature somewhere in this forum that I can follow-up?

Viewing 15 posts - 1 through 15 (of 20 total)
  • You must be logged in to reply to this topic.