Svelte · Middle · Question 14 of 75

How do you pass named content areas (formerly named slots) to a component?

<Table data={rows}>
  {#snippet header()}
    <th>Name</th>
  {/snippet}
  {#snippet row(item)}
    <td>{item.name}</td>
  {/snippet}
</Table>

Explanation

Inside Table they are received with $props() and rendered with {@render header()} and {@render row(item)}.

Further reading

Problem with a question

Svelte · Middle · question 14

Test yourself

Take the Svelte · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz