Guide › Templates

Lists

Repeat content with @for.

<ul>
  @for (post of posts; track post.id) {
    <li>{{ $index + 1 }}. {{ post.title }}</li>
  } @empty {
    <li>No posts yet.</li>
  }
</ul>

Inside an interactive component, rows with the same key keep their elements when the list changes; new rows are rendered and removed rows are cleaned up. The to-do list on the home page is built this way.