DEV Community

GreggHume
GreggHume

Posted on

6

Svelte 5: Slot / children example

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"

Top comments (1)

Collapse
 
james_hets_801d11230fe93f profile image
James Hets

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

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay