# Override class list

**URL:** https://meta.discourse.org/t/override-class-list/166310
**Category:** Development
**Created:** [October 5, 2020, 9:00pm UTC](https://meta.discourse.org/t/override-class-list/166310 "2020-10-05T21:00:55Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![colinbethea](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/colinbethea/32/195791_2.png) [@colinbethea](https://meta.discourse.org/u/colinbethea)
#### Post date: [October 5, 2020, 9:00pm UTC](https://meta.discourse.org/t/override-class-list/166310/1 "2020-10-05T21:00:55Z")

</div>

Currently working out of an initializer for my custom plugin - I want to be able to add an arbitrary class (locked-category) for each _locked_ category, but can’t quite figure out how.

I’m aware that I can edit the template for `topic-list-item`, however the class is conditional, dependent on whether the topic is locked or not.

Here’s the code in question:  
` TopicStatus.reopen({ statuses(){ if (this.topic.is_locked_down) { // I'd like to add the class to topic's classList } ... })`

If anyone has ideas, anything is appreciated!

---

<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: [October 6, 2020, 2:47pm UTC](https://meta.discourse.org/t/override-class-list/166310/2 "2020-10-06T14:47:34Z")

</div>

If

> [@colinbethea](#):
>
> _locked_ category

in your post refers to categories with limited read permissions then something like this will work if you add it to your initializer.

```javascript
api.modifyClass("component:topic-list-item", {
  didInsertElement() {
    this._super(...arguments); // ensures core code runs first

    const privateCategory = this.topic.category.read_restricted;
    if (privateCategory) {
      // adds the class to topic list items that meet the conditional above 
      this.element.classList.add("locked-category");
    }
  }
});

```

---

<div class="post-metadata">

### Author: ![colinbethea](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/colinbethea/32/195791_2.png) [@colinbethea](https://meta.discourse.org/u/colinbethea)
#### Post date: [October 6, 2020, 8:03pm UTC](https://meta.discourse.org/t/override-class-list/166310/3 "2020-10-06T20:03:57Z")

</div>

Awesome, got it working, much appreciated!
