# How to add a class to category tr to optionally apply CSS

**URL:** <https://meta.discourse.org/t/how-to-add-a-class-to-category-tr-to-optionally-apply-css/318438>\
**Category:** Development\
**Created:** [July 25, 2024, 8:55pm UTC](https://meta.discourse.org/t/how-to-add-a-class-to-category-tr-to-optionally-apply-css/318438 "2024-07-25T20:55:47Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [July 25, 2024, 8:55pm UTC](https://meta.discourse.org/t/how-to-add-a-class-to-category-tr-to-optionally-apply-css/318438/1 "2024-07-25T20:55:47Z")

</div>

I’m adding some stuff to the in the topic list. I need to apply CSS only to the categories that I’m supposed to be affecting.

I think I need to do that by adding a “can-rate” class to the `<tr>` of I the categories that I want to affect.

I think I can do it in my glimmer component (which might know if it should apply the change?), though I’d be just as happy to do it in the initializer.

I’ve tried some things that didn’t work. Can someone throw me a bone or point me to an example? Like [https://github.com/discourse/discourse-groups-css-classes-in-body/blob/main/common/header.html](https://github.com/discourse/discourse-groups-css-classes-in-body/blob/main/common/header.html) seems like the right track, but I don’t know how to find out in the initializer if the category is one that I want to change (so I guess the initializer is the wrong place?)

Maybe [Override class list](https://meta.discourse.org/t/override-class-list/166310)

---

_[View the full topic](https://meta.discourse.org/t/how-to-add-a-class-to-category-tr-to-optionally-apply-css/318438)._
