# Does adding groups to CSS theme component still work?

**URL:** https://meta.discourse.org/t/does-adding-groups-to-css-theme-component-still-work/226065
**Category:** Support
**Created:** [May 4, 2022, 2:44am UTC](https://meta.discourse.org/t/does-adding-groups-to-css-theme-component-still-work/226065 "2022-05-04T02:44:12Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![nathank](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nathank/32/290039_2.png) [@nathank](https://meta.discourse.org/u/nathank)
#### Post date: [May 4, 2022, 2:44am UTC](https://meta.discourse.org/t/does-adding-groups-to-css-theme-component-still-work/226065/1 "2022-05-04T02:44:12Z")

</div>

Does this Theme Component still work?

[https://github.com/discourse/discourse-groups-css-classes-in-body](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!

---

<div class="post-metadata">

### Author: ![Alexander](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alexander/32/497634_2.png) [@Alexander](https://meta.discourse.org/u/Alexander)
#### Post date: [May 4, 2022, 2:47am UTC](https://meta.discourse.org/t/does-adding-groups-to-css-theme-component-still-work/226065/2 "2022-05-04T02:47:14Z")

</div>

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

![Captura](https://global.discourse-cdn.com/meta/original/4X/0/c/7/0c79988b3497b93adee72799611dfba7e7aa3d72.png)

---

<div class="post-metadata">

### Author: ![Johani](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/johani/32/176920_2.png) [@Johani](https://meta.discourse.org/u/Johani)
#### Post date: [May 4, 2022, 2:55am UTC](https://meta.discourse.org/t/does-adding-groups-to-css-theme-component-still-work/226065/3 "2022-05-04T02:55:52Z")

</div>

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.

> [@Alexander](#):
>
> Discourse adds the user groups to the body tag without any theme component

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

---

<div class="post-metadata">

### Author: ![Alexander](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alexander/32/497634_2.png) [@Alexander](https://meta.discourse.org/u/Alexander)
#### Post date: [May 4, 2022, 2:58am UTC](https://meta.discourse.org/t/does-adding-groups-to-css-theme-component-still-work/226065/4 "2022-05-04T02:58:26Z")

</div>

> [@Johani](#):
>
> only adds a single class

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

---

<div class="post-metadata">

### Author: ![nathank](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nathank/32/290039_2.png) [@nathank](https://meta.discourse.org/u/nathank)
#### Post date: [May 4, 2022, 3:05am UTC](https://meta.discourse.org/t/does-adding-groups-to-css-theme-component-still-work/226065/5 "2022-05-04T03:05:29Z")

</div>

> [@Johani](#):
>
> Discourse only adds a single class for the current user’s primary group by default.

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

---

<div class="post-metadata">

### Author: ![Johani](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/johani/32/176920_2.png) [@Johani](https://meta.discourse.org/u/Johani)
#### Post date: [May 4, 2022, 3:16am UTC](https://meta.discourse.org/t/does-adding-groups-to-css-theme-component-still-work/226065/6 "2022-05-04T03:16:17Z")

</div>

> [@nathankershaw](#):
>
> maybe it doesn’t work in login-only sites

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.

> [@nathankershaw](#):
>
> Or if group visibility is set below `everyone`

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?

---

<div class="post-metadata">

### Author: ![nathank](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nathank/32/290039_2.png) [@nathank](https://meta.discourse.org/u/nathank)
#### Post date: [May 4, 2022, 3:29am UTC](https://meta.discourse.org/t/does-adding-groups-to-css-theme-component-still-work/226065/7 "2022-05-04T03:29:02Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![Johani](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/johani/32/176920_2.png) [@Johani](https://meta.discourse.org/u/Johani)
#### Post date: [May 4, 2022, 4:07am UTC](https://meta.discourse.org/t/does-adding-groups-to-css-theme-component-still-work/226065/8 "2022-05-04T04:07:30Z")

</div>

> [@nathankershaw](#):
>
> Thanks for looking into it

No worries, glad you got it sorted.

> [@nathankershaw](#):
>
> could do with some documentation, eh?

:+1:

> [@CSS Classes for Current User's Groups](https://meta.discourse.org/t/css-classes-for-current-users-groups/226068):
>
> discourse2Summary CSS Classes for Current User’s Groups adds the groups that a member is a part of as CSS classes on the \<body\> tag.eyeglassesPreview [Preview on theme-creator.discourse.org](https://discourse.theme-creator.io/theme/Johani/user-groups-css-classes)hammer_and_wrenchRepository Link [https://github.com/discourse/discourse-groups-css-classes-in-body](https://github.com/discourse/discourse-groups-css-classes-in-body)open_bookNew to Discourse Themes? [Beginner’s guide to using Discourse Themes](https://meta.discourse.org/t/beginners-guide-to-using-discourse-themes/91966) Install this theme component Before: [image] After: [image] Discourse only adds the current us…

---

<div class="post-metadata">

### Author: ![Johani](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/johani/32/176920_2.png) [@Johani](https://meta.discourse.org/u/Johani)
#### Post date: [May 4, 2022, 8:07am UTC](https://meta.discourse.org/t/does-adding-groups-to-css-theme-component-still-work/226065/9 "2022-05-04T08:07:41Z")

</div>

This topic was automatically closed after 4 hours. New replies are no longer allowed.
