I have been looking into using view formatting to alternate the colors of rows in order to recreate what came out of the box in the classic views. However it seems like I can't access the row ID as a criteria nor can I use Mod as an operator. I kinda found a work around using a calculated column to do the MOD, but it is not an elegant solution. Is there really no easy way to alternate the row colors?

  • Plain old CSS tr:nth-child(odd) and tr:nth-child(even) is not sufficient? Commented Dec 18, 2018 at 17:00
  • Sure, but how would I inject that on a modern list view? Commented Jan 19, 2019 at 12:39
  • Unfortunately, I couldn't tell you. I'm still stuck on 2013/2016 on-prem. Commented Jan 19, 2019 at 16:53

1 Answer 1


All Items, Format current view, put the following in the JSON box.

  "$schema": "https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json",
  "additionalRowClass": "=if(@rowIndex % 2 == 0,'ms-bgColor-themeLighter ms-bgColor-themeLight--hover','')"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.