Does adding groups to CSS theme component still work?

AI-generated summary

The discussion revolves around whether the Theme Component “Discourse Groups CSS Classes in Body” still works. nathank initially reported that it didn’t work for them, but Johani found it to be functional. Johani explained that the component only adds the current user’s groups as CSS classes on the <body> tag and that Discourse only adds a single class for the current user’s primary group by default.

After testing, Johani found that the component works even in login-only sites and with group visibility set below “everyone.” nathank later revealed that the issue was due to user error, as they had added the component to the default Theme instead of their dev Theme. The discussion concluded with Johani agreeing that the component could benefit from documentation and sharing a link to a related topic.

Does this Theme Component still work?

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

It didn’t seem to do anything for me despite lots of groups being set to be visible to ‘logged in users’. It could be very handy for several things!

As far as I know, Discourse adds the user groups to the body tag without any theme component :thinking:

Captura

I just tried it, and it seems to work fine. Do you see any errors in the console?

To be clear, that component only adds the current user’s groups as CSS classes on the <body> tag.

We use that component here on Meta. Discourse only adds a single class for the current user’s primary group by default.

Interesting fact, I had seen it in other communities and assumed it was something by default :sweat_smile:

Hmmm - maybe it doesn’t work in login-only sites. Or if group visibility is set below everyone.

Just tested that, and it worked OK for me. As soon as the user is logged-in, the group classes get added to the <body> tag.

I also tested that, and it seems to work without issue. I tried all five visibility options.

Can you share a link to the site you’re seeing this issue on?

Actually, the problem was user stupidity!

I was adding it to the default Theme. Unfortunately I forgot that I was using a dev Theme for my own account. Doh!

Thanks for looking into it, and sorry to waste your time! It is a good TC - could do with some documentation, eh?

No worries, glad you got it sorted.

:+1: