I’ve been struggling to find out how to change the category color background for category boxes:
The goal is to inherit the main category color and add transparency to the background:
Does anyone know how I can achieve this?
Change category background color for boxes
MarcP is trying to change the category background color for category boxes to inherit the main category color and add transparency. Don suggests using CSS and template modification, introducing the --category-color variable, which can be used with a ::before pseudo to set opacity. Don shares a component that can be installed or forked to achieve this, providing links to the CSS and template modifications for both desktop and mobile. MarcP appreciates the explanation and is going to experiment with it. Don updates the desktop CSS to work with Category Boxes, and MarcP thanks Don and mentions that they were already figuring it out, but appreciates the help.
I’ve been struggling to find out how to change the category color background for category boxes:
The goal is to inherit the main category color and add transparency to the background:
Does anyone know how I can achieve this?
Hello,
This is possible with css and little bit template modification. ![]()
On desktop, categories border has a color variable which you can use for background too.
This is the --category-color variable which is the border-color.

But because this variable is a hex value you can’t make it transparency. However you can add this to a ::before pseudo where you can set opacity too.
I made this as a component so you can install it or fork and modify what you want. ![]()
Component: GitHub - VaperinaDEV/discourse-category-background-color · GitHub
Desktop CSS looks like this:
On mobile this color variable is missing from the template so you have to add this style here:
After this you can use the --category-color variable and do the similar like on desktop:
Desktop
Mobile
You are the best!
Thanks for the explanation, I’m gonna play with this for a while!
Hey @MarcP, Sorry I totally missed you want to this for category boxes.
I have updated the desktop css to work with Category Boxes too.
Ah thanks, I was already figuring out how to get the boxes working! This was more complicated then I thought. Very much appreciated!