Svelte 5: Slot / children example
GreggHume

GreggHume @greggcbs

About: A developer who works with and on some of the worlds leading brands. My company is called Cold Brew Studios, see you out there :)

Joined:
Mar 10, 2021

Svelte 5: Slot / children example

Publish Date: Aug 21 '24
6 1

Svelte 5 has deprecated the slot tag. So now you have to use children, but its not clear how to do this.

Here is an example of how to use the slot / children in the layout component.

<script lang="ts">
  let { children } = $props();
</script>

{@render children()}
Enter fullscreen mode Exit fullscreen mode

Before doing this you will see errors like:
"Using <slot> to render parent content is deprecated. Use {@render ...} tags instead"

Comments 1 total

  • James Hets
    James HetsOct 27, 2024

    Thank you! I don't understand the reason why documentation doesn't make it explained like yours!

Add comment