sveltejs / sveltejs/kit

Send snippets (that are not children) to +layout.svelte

Open
#12,722 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
20.8k
Forks
2.3k
Avg merge
1d 16h
Merged PRs (30d)
156

Description

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 canvas component in the layout and send some manager and some store downstream 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:

  1. reverting back to using named slots
  2. only using children() snippet with layout.
Importance

would make my life easier

Additional Information

discord :
https://discord.com/channels/457912077277855764/1288862792887308410

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the +layout.svelte entry point and the issue's proposed $props()/@render snippet example. Determine how non-child snippets would be passed to layouts alongside children(); done means a layout can receive and render multiple named snippets while preserving the existing alternatives.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.