When using a grouping field in an HTML list, is there a way to determine the group/loop number of the current content being rendered? I want to be able to determine what group number is currently being processed to that I can treat the output of the first group differently than subsequent groups.
Unlike rows, I do not see a way to find the current count of groups or loops through the view such that I could, for instance, do something like the following (i.e., classing group content by group iteration) -
&lt;div class=&quot;item-list&quot;&gt;
  &lt;h3 class=&quot;group-1&quot;&gt;{{ title }}&lt;/h3&gt;
  &lt;ul class=&quot;group-1&quot;&gt;
    {% for row in rows %}
      &lt;li{{ row.attributes }}&gt;
        {{- row.content -}}
      &lt;/li&gt;
    {% endfor %}
  &lt;/ul&gt;
&lt;/div&gt;
&lt;div class=&quot;item-list&quot;&gt;
  &lt;h3 class=&quot;group-2&quot;&gt;{{ title }}&lt;/h3&gt;
  &lt;ul class=&quot;group-2&quot;&gt;
    {% for row in rows %}
      &lt;li{{ row.attributes }}&gt;
        {{- row.content -}}
      &lt;/li&gt;
    {% endfor %}
  &lt;/ul&gt;
&lt;/div&gt;
...
&lt;div class=&quot;item-list&quot;&gt;
  &lt;h3 class=&quot;group-n&quot;&gt;{{ title }}&lt;/h3&gt;
  &lt;ul class=&quot;group-n&quot;&gt;
    {% for row in rows %}
      &lt;li{{ row.attributes }}&gt;
        {{- row.content -}}
      &lt;/li&gt;
    {% endfor %}
  &lt;/ul&gt;
&lt;/div&gt;
I don't know of a way to get the group number from within the grouping (e.g. views-view-list) template, but I would look to do this  split between two templates: views-view and views-view-list.
First, in the views-view template, e.g. views-view--my-view-id.html.twig.
{# ... etc ... #}
{# Loop through the rows, aka groups, and add a wrapper with index identifier. #} 
{% for row in rows %}
  &lt;div class=&quot;item-list group--{{ loop.index }}&quot;&gt;
    {{ row }}
  &lt;/div&gt;
{% endfor %}
{# ... etc ... #}

Second, create your views-view-list template, e.g. views-view--my-view-id.html.twig to build the content for each group:
&lt;h3&gt;{{ title }}&lt;/h3&gt;
&lt;ul&gt;
  {% for row in rows %}
  &lt;li{{ row.attributes }}&gt;
      {{- row.content -}}
    &lt;/li&gt;
  {% endfor %}
&lt;/ul&gt;

Then you can target the contents of each group in css like:
.group--1 h3 { }
.group--1 ul { }
.group--2 h3 { }
.group--2 ul { }
.etc { }