Nova · Layouts

Index

Inside a loop, $index is the position of the element, counted from zero.

The action, as it is written
{
  id: 'loop-index',
  data: { steps: ['Book', 'Pay', 'Go'] },
  layout: {
    component: 'Stack',
    children: [
      {
        for: '$.steps',
        as: 'step',
        do: { component: 'Text', children: '{{$index}}: {{$step}}' },
      },
    ],
  },
}
Running herepress it

0: Book

1: Pay

2: Go

What is done to it
Nothing. It is only drawn.
What it then holds
{ steps: ['Book', 'Pay', 'Go'] }
What it then says
0: Book
1: Pay
2: Go
Output matches the expected value

Left: the action as the package ships it. Right: the same action running in this page, rendered with this site’s components. Below: the action run as the example specifies, on the installed package.