Svelte and SvelteKit 5 · Template syntax
Reusable markup with snippets
Define a snippet once and render it where you need it, with parameters.
{#snippet row(item)}
<li>{item.name} - {item.price}</li>
{/snippet}
<ul>
{#each products as product}
{@render row(product)}
{/each}
</ul>
Official Svelte and SvelteKit 5 documentation
More template syntax commands
- Show content conditionally
- Loop over a list
- Show an async result
- Bind form inputs
- Handle events
- Toggle classes
All template syntax commands · Svelte and SvelteKit 5 cheatsheet