docs: add shared state example for bind:group & add labels #14905
+46
−7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In the last couple of days I tried to learn the new Svelte v5 $state (notes). I did some small hobby projects with v4 before.
I mainly stumbled over the lack of examples for
bind:group
with shared state, since object wrapping is needed here when usingexport
. My current guess is that other developers will face the same challenge in future when they just check the docs forbind:group
for v5 and try to use it with shared state on their own (like I did). Took me multiple days and support on Discord/Bluesky to get it right.PR changes to bind-group docs:
bind:group
does not work with nested components #2308<label>
to the whole example to be a11y-complicantREPL for submitted code
As alternative, a link to a tutorial might help as well.
Keep up the awesome work with Svelte and much success in 2025! 🎉
PS: I know that there is also the section bind:property for components, but I just noticed it afterwards + it's very technical. Wouldn't have helped me. https://svelte.dev/tutorial/svelte/group-inputs also doesn't cover shared state.
Before submitting the PR, please make sure you do the following
feat:
,fix:
,chore:
, ordocs:
.packages/svelte/src
, add a changeset (npx changeset
).Tests and linting
pnpm test
and lint the project withpnpm lint
Couldn't run
pnpm lint
on node v23.5.0 and withpnpm 9.15.3
Error: Cannot find module '/Users/XXX/webserver/svelte/node_modules/.pnpm/[email protected]_svelte@packages+svelte/node_modules/svelte/compiler/index.js'