Quantcast
Channel: Active questions tagged svelte - Stack Overflow
↧

Svelte adds spaces when I start inline conditional on a new line. Any way to...

I have a Svelte component with logic that's structured like this. See in playground here.<script> let a = true let b = false</script><p>Hover over the asterisk at the end of this...

View Article


How can I update the client with information about the state of the currently...

I am making a web app which sends some requests to external APIs which can take some time to complete. The user types information in a form, which is received by a +page.server.ts file in the default...

View Article


How to use RXJs Subject like store variable in Svelte [closed]

How to use RXJs Subject like store variable in Svelte? You can use the Subject variable in Svelte with $ prefix. But when you bind the variable to input it throws an exception: "Error: name.set is not...

View Article

Svelte 5, Problem with tests, why am I getting this overload error in my...

Github Repo: https://github.com/Gaban-Ventures/crypto-basis-frontendWith the latest commit you have to run npm install --legacy-peer-depsTo run normal before the breaking tests, do:git co...

View Article

India map rendering issue on d3 + svelte

I'm an absolute beginner when it comes to d3 + svelte and I'm trying to render a map of Indian districts in d3 in svelte framework. The json I'm accessing is from here. I'm trying to render the...

View Article


Image may be NSFW.
Clik here to view.

SvelteKit use prop for background-image [duplicate]

I am using SvelteKit and I have a component that displays a CSS background-image - see picture. I have this working with a hard-coded image but I need to vary the image from card to card.Here is my...

View Article

Cross-site POST form submissions are forbidden

My sveltekit app has a form which sends a POST request to server. The app is working fine on dev server but when I build and run the app it fails to send the form data via POST request. It shows the...

View Article

Install Tailwind v4 Theme Settings from External Package

I have a packaged library that contains svelte components that are using tailwind v4. While the components themselves are utilizing the theme settings correctly, I can't seem to access the theme...

View Article


How can i navigate to different path on click in svelte?

Currently in having on:click | preventDefault="{() => showDetail({id})}"and in showDetail function i want to naviagte to particular id which in i am passing on click of button.I tried regular...

View Article


Detection of an external (non-package, static) source outside the project

TL;DR: Inside a shared UI library in a Turborepo, styling a component inline with Tailwind CSS classes in @repo/ui does not render the component properly in web, whereas styling the component through...

View Article

pattern of reactive svelte context state

What's a good way to pass reactive state that's derived from some $props() in grand-parent components?For example, how do I pass derived states calculated from Grandparent's $props(), with components...

View Article

Why button using 'focus-within' is not working on iOS

I need a hidden delete button to appear and work when a input is focused using markup and CSS in Svelte.I got it all working in browsers for OS X and Raspberry Pi OS (Chrome, Chromium, Safari and...

View Article

Phoenix: Unknown hook found for "SvelteHook"

I am trying to integrate live_svelte in my existing liveview app which already has a couple of JS hooks as well. I've followed the official Readme file of live_svelte library.I am trying to render...

View Article


Ways to make layout load data both reactive + changeable?

I am returning a bunch of data from my +layout.tsI want the data to change when the url changesI also want to be able to modify filter, search, tag etc from the UI via input, dropdown...

View Article

Conditional typescript in this Svelte 5 component

I have this Svelte 5 code:<script lang="ts"> type BaseProps = { required?: boolean; }; type SingleDateProps = BaseProps & { range?: false | undefined; dates?: Date | null; onchange?: (e: Date...

View Article


Image may be NSFW.
Clik here to view.

Why does Chrome black out, or crash with "aw, snap - out of memory" when...

I'm developing a Svelte-based Javascript single-page app with a lot of Apache ECharts displays in it that is fairly heavy in both DOM elements and array data, but generally stays in the 400-500MB range...

View Article

Svelte 5 raw state and context is not behaving as expected

I have a plain JS API that uses class objects. I am making a SvelteKit app that uses the API. I'd like to make use of Svelte $state along with setContext and getContext to enable application-wise state...

View Article


vitest crypto.randomUUID() is not a function

vite.config.tsimport { sveltekit } from '@sveltejs/kit/vite';const config = { plugins: [sveltekit()], test: { include: ['**/*.spec.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], environment: 'jsdom', globals:...

View Article

Event Propagation in Svelte

When interacting with a child component, the parent component's event triggers. Below is an example of my code:<!-- Parent Component --><div class="parent" on:click={toggle}> {#if...

View Article

Svelte form on:submit type TypeScript

I am trying to build a simple form in Svelte TypeScript.My on:submit looks like this: <form on:submit={onSubmit}>, and my onSubmit function is defined as:const onSubmit = (event: HTMLFormElement)...

View Article

Removing SCSS included file warnings

I am building a Svelte project which relies on GDS components and styling from GOV UK frontend, and I get a lot of error messages similar to the one in the Warning message section below.Is there a way...

View Article


How can I dynamically import images stored in $lib within a component in Svelte?

I'm using an array of dummy data to test how I could display information from an api. In that data, I have a relative image path, for some images I've stored locally in $lib for simplicity in testing.I...

View Article


Delaying render of webcomponent content

I have a website that uses webcomponents to add some extra interactivity.In this case a carousel created in Svelte<svelte:options customElement={{ tag: "carousel", shadow: "open"}} />The nice...

View Article

ELKjs multi direction [closed]

I would like to do the same thing as this example: https://svelteflow.dev/examples/layout/elkjs with ELKjs, but when adding nodes or changing nodeNodeBetweenLayers, the orphan nodes no longer align...

View Article

Is this object created only once or every time I import it? [duplicate]

Since I'm having a bug that I can't figure out, a cold doubt has assailed me:.I have the below code in a Svelte 5 SvelteKit app.And I'm importing import { queryClient } from './src/query.ts from...

View Article


How do I combine i18n-ally with Kaisermann/svelte-i18n library

I'm doing some internationalization with a Svelte project, and I'm using i18n-ally to do the language editing. i18n-ally does a great job of turning a block of code from:<p>Copyright &copy;...

View Article

Astro with Node Standalone Adapater for API - CORS issues

I'm working on a small Astro test project that uses the Node standalone adapter for an API endpoint.Then I'm using a Svelte form to POST to that endpoint like in this tutorial.I'm running the Node...

View Article

Svelte-flow async integration with indexedDB

ContextI'm using Svelte-Flow with Sevelte 5 for some project. To scale I want to have the object defining my node pushed to indexedDB. To keep it in sync and don't dodata handling twice, I want to sync...

View Article

Svelte 5 - using $state for class field in TypeScript

I have a class:class TestClass { prop = $state('test');}It works in .svelte.js and .svelte files with <script lang="js">, but doesn't work in .svelte.ts and .svelte files with <script...

View Article



Timeout error on mounting Svelte components in Playwright

I am trying to use Playwright for component testing.this is my test code:import { test, expect } from '@playwright/experimental-ct-svelte';import Button from '../Button.svelte';test('renders with...

View Article


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>