In Svelte 5+, this concept is obsolete. Snippets don’t create a wrapping element, so
<svelte:fragment> is no longer necessary.<svelte:fragment> element allows you to place content in a named slot without wrapping it in a container DOM element. This keeps the flow layout of your document intact.
Attributes
The name of the slot to place this fragment’s content into.
Optional let directives to receive slot props from the component.
Usage
Basic named slot without wrapper
Why use svelte:fragment?
Without<svelte:fragment>, you’d need to wrap the content in an element:
<div> might interfere with your layout or styling. <svelte:fragment> solves this:
With slot props
Migration to Svelte 5
In Svelte 5, use snippets instead of slots. Snippets don’t create wrapper elements, making<svelte:fragment> unnecessary: