# Template Repeater Alternate Background Color

**URL:** <https://forum.inductiveautomation.com/t/template-repeater-alternate-background-color/104654>\
**Category:** Ignition\
**Tags:** ignition81, vision\
**Created:** [April 3, 2025, 3:29pm UTC](https://forum.inductiveautomation.com/t/template-repeater-alternate-background-color/104654 "2025-04-03T15:29:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [April 3, 2025, 3:29pm UTC](https://forum.inductiveautomation.com/t/template-repeater-alternate-background-color/104654/1 "2025-04-03T15:29:36Z")

</div>

It would be nice to have the option to alternate background colors on template repeater instances. I end up using these for tables quite often. I can, of course, have another boolean parameter to the template for background color toggle, but it would be nice if this were a default option.

Is there a way to do that with the component as-is?

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [April 3, 2025, 3:32pm UTC](https://forum.inductiveautomation.com/t/template-repeater-alternate-background-color/104654/2 "2025-04-03T15:32:01Z")

</div>

Pull the index value into the template, then have an expression of `if ({templateIdx} % 2, color1, color2)` on the background color of the template.

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [April 3, 2025, 3:32pm UTC](https://forum.inductiveautomation.com/t/template-repeater-alternate-background-color/104654/3 "2025-04-03T15:32:42Z")

</div>

Right, so inside the template itself. Whether that be through a parameter in dataset mode or through the index in count mode.

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [April 3, 2025, 3:36pm UTC](https://forum.inductiveautomation.com/t/template-repeater-alternate-background-color/104654/4 "2025-04-03T15:36:04Z")

</div>

Correct. Its the simplest because you don't have to assign a boolean specifically when creating the dataset for the instances, just include the index number, which a `for ndx, value in enumerate(values)` loop will give.

If its any sort of data entry I normally pass `index` to my instances anyway, so I can know who fired a change or action.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [April 3, 2025, 3:54pm UTC](https://forum.inductiveautomation.com/t/template-repeater-alternate-background-color/104654/5 "2025-04-03T15:54:56Z")

</div>

I mean, Vision is Vision - you absolutely _could_ inject a different background color to alternating rows from the outside. Whether that's a good idea or not is up to you. Look for TemplateHolder class instances as inner Swing components of the outer template repeater, and then set a different background color on the odd rows.
