-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Closed
Description
Describe the problem
In svelte 4, it was not possible to use multiple slots in the layout.
Snippets have appeared in svelte 5, which should replace slots, and for myself I found such an option for several snippets in the layout. It works fine, maybe it will be useful to someone.
I wanted to ask, how valid is this?
My store file (store.ts):
import type { Snippet } from 'svelte';
import { writable, type Writable } from 'svelte/store';
export let Header: Writable<Snippet> = writable();
export let Footer: Writable<Snippet> = writable();My +layout.svelte:
<script lang="ts">
import { Footer, Header } from '$lib/scripts/store';
let { children } = $props();
</script>
{@render $Header?.()}
{@render children?.()}
{@render $Footer?.()}My +page.svelte
<script lang="ts">
import { Header, Footer } from '$lib/scripts/store';
$Header = header;
$Footer = footer;
</script>
{#snippet header()}
Header
{/snippet}
<div>Content</div>
{#snippet footer()}
Footer
{/snippet}Describe the proposed solution
I wanted to ask, how valid is this?
Importance
would make my life easier
Metadata
Metadata
Assignees
Labels
No labels