Create custom color styles and assign them to existing tags.
The component ships with three example styles so you can see how it works (a yellow highlight, a subtle accent, and an outline). They don’t do anything until you assign tags to them, and you can edit or delete them freely.
Colors accept any CSS value, e.g. #ff7a00 or limegreen. You can also use Discourse color variables like var(--tertiary) — those automatically adapt to your color palette, dark mode included.
Site settings
Discourse has three base tag styles, simple, bullet and box. You can pick your base style in site settings:
On targeting tag groups: Right now tags only have a data attribute for their name and that’s what the component targets. I had posted a feature request for adding another attribute for their group a while ago, you can give it a like
On customizing colors: As of now you’d need to fork the component and hardcode other color values. If dropdown menus (to pick tags) would become available on the popup editors I guess I’ll re-factor the component with more customizable settings.
EDIT: Nevermind, I simply forgot to actually save the other “settings.yml” file, lol. Brain is fried.
Hi. When changing the code from the color yellow to purple, I get this error. All I did was simply swap any mention of “yellow” to “purple” and adjust the hex color value. Why?
Hi, this component isn’t working with my instance. I’ve added in the tags to be certain colors in the admin menu for the component but they are all still grey. I haven’t tweaked the component’s code at all and am just trying to use it as provided. Pictures below for example:
I’m afraid I can’t reproduce. It works for me on 3.5.
In any case, I published an updated component to a new repo on GitLab. No functional changes, just some house-keeping and re-factoring. The old GitHub repo should still work, but if you install afresh, please use the new repo, it’s also listed on the Summary topic.
I’m not a coding expert unfortunately… if a component doesn’t work plug-and-play I’m fairly sunk. I’ll just have to look for other options to get something like this to work.
Thanks for the reports, I guess I found the issue.. tags are case-sensitive now, but data-tag-name needs to be parsed a lower-case value. So it didn’t apply styles to upper-case tags.
Let me know if it works after updating the component @Ahmed26@Av8tion
I just updated and refactored this component. Previously it came with eight fixed color styles. Now you can create as many styles as you like, right in the theme settings UI
Read the updated component description
Updating an existing installation
Your existing configuration should be migrated automatically: tags you had assigned to the old color styles become equivalent styles with the same colors as before.
One thing to check before updating: if any of the old settings still reference tags that no longer exist on your site, remove those first. Stale tag names will cause the update to fail.
This new version requires Discourse 3.3.0 or later. Older sites will stay on the previous version of the component.