# Custom Module - Separate styles for an object in repeater

**URL:** <https://community.hubspot.com/t/custom-module-separate-styles-for-an-object-in-repeater/117153>\
**Category:** CMS Development\
**Created:** [September 26, 2024, 5:52pm UTC](https://community.hubspot.com/t/custom-module-separate-styles-for-an-object-in-repeater/117153 "2024-09-26T17:52:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jestlinbaum](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jestlinbaum/32/68653_2.png) [@jestlinbaum](https://community.hubspot.com/u/jestlinbaum)\
**Post date:** [September 26, 2024, 5:52pm UTC](https://community.hubspot.com/t/custom-module-separate-styles-for-an-object-in-repeater/117153/1 "2024-09-26T17:52:49Z")

</div>

Hi!

I’m building a custom module that has a repeater field. In the repeater are a series of number fields for the user to enter numbers (as %). I want to use those numbers to make a pie chart. So for each number(%) I am setting variables to convert the % to degrees (like x of 360) like this:

`{% set use_brny = 3.6 * item.recommendation.use_brny %}`

I’m making the pie chart with something like this:

```lia-code-sample
.piechart {
width: 200px;
height: 200px;
padding:30px;
border-radius: 50%;
background-image: conic-gradient(
pink 54deg,
lightblue 0 126deg,
purple 0 144deg,
blue 0
);
}

```

So I want to use the data from the repeater in the css:

```lia-code-sample
.piechart {
width: 200px;
height: 200px;
padding:30px;
border-radius: 50%;
background-image: conic-gradient(
pink {{ use_brny }}deg,
lightblue 0 126deg,
purple 0 144deg,
blue 0
);
}

```

So the question is, is it possible to have the class .piechart css dynamically change based on the {% for item in … %} loop?

---

<div class="post-metadata">

**Author:** ![Anton](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/anton/32/103167_2.png) [@Anton](https://community.hubspot.com/u/Anton)\
**Post date:** [September 27, 2024, 7:58am UTC](https://community.hubspot.com/t/custom-module-separate-styles-for-an-object-in-repeater/117153/2 "2024-09-27T07:58:02Z")

</div>

Hi @jestlinbaum,

yes it’s possible but since you can’t access loop-data from outside, you have to do it like this:

```lia-code-sample
{% for item in module.recommendations %}
{% set use_brny = 3.6 * item.recommendation.use_brny %}

{% require_css %}
<style>
{% scope_css %}
.piechart.instance-{{loop.index}}{
width: 200px;
height: 200px;
padding:30px;
border-radius: 50%;
background-image: conic-gradient(
pink {{ use_brny }}deg,
lightblue 0 126deg,
purple 0 144deg,
blue 0
);
}
{% end_scope_css %}
</style>
{% end_require_css %}

<div class="piechart instance-{{loop.index}}"></div>
{% endfor %}

```

If you’d like to have your code to be more readable you can do it like this:

```lia-code-sample
{% for item in module.recommendations %}
{% set use_brny = 3.6 * item.recommendation.use_brny %}

{% require_css %}
<style>
{% scope_css %}
.piechart.instance-{{loop.index}}{
width: 200px;
height: 200px;
padding:30px;
border-radius: 50%;
background-image: conic-gradient(
pink {{ use_brny }}deg,
lightblue 0 126deg,
purple 0 144deg,
blue 0
);
}
{% end_scope_css %}
</style>
{% end_require_css %}
{% endfor %}
...

{% for item in module.recommendations %}
<div class="piechart instance-{{loop.index}}"></div>
{% endfor %}

```

best,

Anton

---

<div class="post-metadata">

**Author:** ![jestlinbaum](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jestlinbaum/32/68653_2.png) [@jestlinbaum](https://community.hubspot.com/u/jestlinbaum)\
**Post date:** [September 27, 2024, 2:59pm UTC](https://community.hubspot.com/t/custom-module-separate-styles-for-an-object-in-repeater/117153/3 "2024-09-27T14:59:00Z")

</div>

@Anton Makes sense and works perfectly!! Thank you so much 👍
