Nova · Layouts
Index
Inside a loop, $index is the position of the element, counted from zero.
{
id: 'loop-index',
data: { steps: ['Book', 'Pay', 'Go'] },
layout: {
component: 'Stack',
children: [
{
for: '$.steps',
as: 'step',
do: { component: 'Text', children: '{{$index}}: {{$step}}' },
},
],
},
}0: Book
1: Pay
2: Go
Nothing. It is only drawn.
{ steps: ['Book', 'Pay', 'Go'] }0: Book 1: Pay 2: Go
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.