Discourse groepen css classes in body

AI-generated summary

Ed_Bobkov discusses a Discourse component that adds CSS classes for user groups to the body tag, crediting Johani and Falco for its creation. He initially encountered an issue where newly added groups weren’t appearing in the body tag, but discovered the cause was the group’s visibility settings—specifically, when set to ‘Visible to group owners and Admin,’ the component didn’t include the group in the body classes. Falco confirmed this behavior is expected, as it prevents information leaks by not exposing groups a user cannot see. Ed_Bobkov appreciated the component’s functionality and suggested it should be listed among official components.

Thanks to @Johani I found this great theme component made by @Falco :pray: Now all groups of a user are set in the body tag. I was searching for a solution but didn’t find any mention of this component.

https://github.com/discourse/discourse-groups-css-classes-in-body

I found a strange thing about the component (except admin user). When I add a user to a group, the body tag is not changing - a newly added group is not showed in the body tag.

I refreshed the page, logout, checked in incognito, switched between browsers, checked on different servers… nothing helps.

@Falco, can you please check the problem?

Update: the problem is caused because of the Visibility status of the chosen groups. I had set: Visible to group owners and Admin. That’s why the component couldn’t show the group name in the body tag. If I set to Visibility: Everyone - it started working correctly.

I think this is not a correct work of the component. Am I right?

That is the expected behavior of the component. If a group is not visible to the current user it won’t be added to the body class list, as that would be an information leak.

Thank you! I understood. By the way, you component solve a very important task. It should be at least in the components list.