Send snippets (that are not children) to +layout.svelte
Author: feuersteinerCreated Sep 26, 2024Updated Sep 27, 2026
Labelsload / layout
Describe the problem
I am creating a base page layout, that has different "slots", say a sidebar, a "main" content container, maybe a righthand sidebar ...
Content in these elements change frequently, hence the need to make sure that the layout is uniform for all of them.
one other reason that might be not relevant to everywhere, is that I need to initialize a
canvascomponent in the layout and send somemanagerand somestoredownstream using the context API.
Describe the proposed solution
the ability for the layout page to receive multiple snippets:
<script>
let {snippetA, snippetB} = $props();
</script>
<div>
{@render snippetA()}
</div>
<div>
the stuff I want to do
</div>
<div>
{@render snippetB()}
</div>Alternatives considered
Currently the 2 things possible are:
- reverting back to using named slots
- only using
children()snippet with layout.
Importance
would make my life easier
Additional Information
discord : https://discord.com/channels/457912077277855764/1288862792887308410
Source: sveltejs/kit