All Questions
62 questions
0
votes
0
answers
11
views
Retrieving the scroll position when the component is removed
In svelte 5, I want to store window.scrollY before the component unmounts to be able to restore it later.
I tried console logging window.scrollY inside onDestroy, the cleanup functions of onMount and $...
0
votes
1
answer
22
views
Svelte:window component onload not triggering
In Svelte5, why is the onload event not triggering the function foo() in src/routers/+layout.svelte?
<script>
const foo = () => console.log('foo triggered')
</script>
<svelte:...
0
votes
1
answer
86
views
How to use a global $derived in Svelte 5?
I'm trying to create a global state with Svelte 5 and runes:
// store.svelte.ts
export const person = ({
name: '',
});
export const mrName = $derived('Mr. ' + person.name); // <-- problem!
I ...
0
votes
1
answer
32
views
How to data bind with pageData?
If I bind directly to data, like:
type Props = {
data: PageData;
};
let { data }: Props = $props();
<input bind:value={data.product.name} />
I get the following warning:
[svelte] ...
0
votes
1
answer
98
views
How to use Dynamic Components in Svelte 5 with Runes?
I have the following code:
<script lang="ts">
import type { SpaceAmenities } from "$src/spaces.d";
import {
Computer,
Plug,
Printer,
Box,
Droplet,
...
0
votes
2
answers
60
views
Svelte5/SvelteKit2 - $page.data vs let data: LayoutData = $props() in page.svelte?
It appears to me, that the data set by the return of an outer (for example the global) layout.server.ts file is accessible in two ways by it's children and nested components:
// outer layout.server.ts
...
1
vote
0
answers
31
views
eslint (with types) + svelte v5 fail?
seems like something is perhaps broken using svelte v5 with eslint rules (with type checking enabled):
(start with minimal app e.g. npx sv create foo (typescript + eslint))
minimally change eslint....
-2
votes
1
answer
14
views
Animate height resize on container with dynamic content
I am new to svelte and I was playing with the svelte/animate and svelte/transitions modules. The main question is how to animate container height when new content is added/removed.
I was trying a few ...
-1
votes
0
answers
24
views
$bindable and propagation don't seem work
I'm building a nested tree of objects. This is the structure:
ID: string;
indexes: number[];
title: string;
validated: boolean;
column: DescriptionElement[];
children: ...
0
votes
1
answer
29
views
Why can the $state rune not handle a boolean condition ($effect needed)
I am a bit confused as to why the $state rune cannot handle a boolean condition. Why is that something that requires a separate rune, in this case $effect? In the Svelte documentation, they put an ...
0
votes
1
answer
41
views
Use $derived based on current state of self
When modifying the height of a sticky header based on a threshold for the yScroll position, the animation can loop infinitely if scrolling is stopped close to the threshold, as the shrinking header ...
0
votes
1
answer
57
views
Svelte 5 and Superforms: Error Submiting Value of a DatePicker Component
I'm working with Svelte 5 and using Superforms for form handling. My goal is to bind a CalendarDate object from a custom DatePicker component to a Superforms field and then convert that CalendarDate ...
0
votes
1
answer
46
views
How to Wrap Each Child with a Tag in Svelte 5?
In Svelte 5, how can I wrap each child with a tag like the example below?
{#if children}
{#each children as child}
<button
onclick={() => {
handleClick();
}}
>
...
0
votes
1
answer
55
views
Why is my rune that holds an array, not being reactive?
In a separate .svelte.js file I have
export let allQuestionsRune = $state([new ObjectWithStringProperty("hi")])
Then in a button onClick method in some +page file I am doing
...
1
vote
1
answer
101
views
Svelte 5 dynamic component loading: TypeScript errors
In my Svelte 4 app I dynamically load components, all of which have different props. Very simple reproduction (also available on the Svelte Playground):
// App.svelte
<script lang="ts">...