Add a data-tag-group attribute for tags

AI-generated summary

manuel proposes adding a data-tag-group attribute to tags for easier styling and distinction, especially useful for setups relying solely on tags. JammyDodger suggests using it for assigning tag icons based on groups, which manuel agrees could be implemented with adjustments to existing components. ncaming215 also supports this idea, highlighting the potential to significantly reduce their tag icon settings. tobiaseigen notes that this feature was previously worked on but is currently not a priority for the team.

Right now tags have their name stored in the data attribute data-tag-name:

Screenshot from 2022-07-29 15-50-16

Could there also be an attribute data-tag-group? It would make it easy to style and distinguish tags from different groups on the ux. A use-case where I find this especially helpful is on setups that only use tags. Then you likely have some top-level tags and it makes navigation more intuitive when tags from that group stand out with a distinct look.

I saw there was a request years ago for adding a css class. Bringing this up again as things might have changed and maybe it’s more straightforward to implement with data attributes as well?

13 Likes

Could this be used to assign Tag Icons based on tag group as well? My Tag Icon settings are pretty brutal right now, and something to slim those down would be :chefs_kiss:

3 Likes

I’d believe so. As well as other components that change tag styles, as Discourse Coloring Tag or Colored Tag Styles.

The components would need to be adjusted to implement it. In the case of tag styles that would be pretty straightforward though.

2 Likes

Same. I have almost a thousand lines that would become 8. :sweat_smile:

2 Likes

Just a note to share that this was worked on but then was found to be a big change, so closed. It’s a great idea but it’s not certain that it will be picked up by the team anytime soon unfortunately.

https://github.com/discourse/discourse/pull/27949

4 Likes