Skip to main content
In Svelte 5+, this concept is obsolete. Snippets don’t create a wrapping element, so <svelte:fragment> is no longer necessary.
The <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

string
required
The name of the slot to place this fragment’s content into.
any
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:
The extra <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:

Important Notes

<svelte:fragment> must be the direct child of a component. It cannot be used in other contexts.
<svelte:fragment> can only have a slot attribute and (optionally) let: directives. No other attributes or directives are allowed.