How to avoid manually passing props up the hierarchy in Svelte components
I have a Svelte component that accepts a prop for handling input changes, structured as follows:<!-- A.svelte --><script> export let onChange = (value) => {};</script><input...
View ArticleHow do you load and use a custom font in Svelte
I know it probably uses @font-face but I dont know where to put my woff files localy to get Svelte to use a custom font. I dont know where to put the @font-face either. Thanks in advance!
View ArticleHow to get exported value of svelte component?
The library flowbite-svelte has component Popover with open property. The property changing by click on button. In order to control external event listener (no in example) I need to know current value...
View ArticleText search is not filtering results in SvelteKit
I've build a sveltekit application to search for words in Sinhala and English. The search functionality worked fine and recently it stopped working. It doesn't show any errors. The application is not...
View ArticleHow to get api response in chunks
in my +layout.server.js I have this API call that is executed onMount:async function loadCustomerData() { if (loading) return; loading = true; const response = await...
View ArticleWhat's the best way to run some code only client side?
I'm trying to implement firebase in Sapper.I installed the modules (@firebase/app, @firebase/auth, @firebase/firestore) and then I wrote a configuration file:import firebase from '@firebase/app';import...
View ArticleHow do I fix "This Serverless Function has crashed" on vercel when deploying...
I am new to svelte and do not really understand how the server side code works.my projects works fine on local server but returns an error when deployed to vercel:I still have a build error trying to...
View ArticleConditional default slot detection in svelte
I have a svelte component with a default slot and a named slot. I have an instance of that component and use the named slot, and use the default slow inside an {#if} statement checking for a...
View ArticleVSCode can't find scss import in Svelte component if path contains $lib alias
Vite preprocess can handle $lib aliases inside component styles.I would like to use<style lang="scss"> @import '$lib/styles/mixins'; ...</styles>which works as expected.But VSCode with...
View ArticleRedirect sveltekit endpoint and pass data to page
I'm using oauth to signin to a service. Once signed in, the app redirects my app to the set redirect uri, which also points to my sveltekit endpoint (/callback). After I verify the code and get the...
View ArticleHow to show a loading state in sveltekit correctly?
I want to show a spinner in +layout.svelte, while the +page.js is fetching data. With the code below the navigating is not available until all api calls have finished. After the loading I see the...
View ArticleHow to target a component in svelte with css?
How would I do something like this:<style>Nested { color: blue;}</style><Nested />i.e. How do I apply a style to a component from its parent?
View ArticleHow to render text in Lottie if the letter consists of two elements
My task is to render text in lottie in thai language, but when it is rendered, some characters are displayed poorly, since the letter consists of two characters, is there a way to fix thisI do not have...
View ArticleHow to use Font Awesome 5 with Svelte/Sappe
I am writing a Server Side Rendered app with Svelte/Sapper and I am having trouble using Font Awesome fonts.I am using the following to load the font:<script> import Icon from "svelte-awesome";...
View ArticleHow to pass DaisyUI primary color to TailwindCSS config file?
I have a custom keyframe set in my tailwindcss config file. keyframes: {'grow-right-shorten-left': {'0%': { boxShadow: '30px 0px 100px -80px rgba(34, 211, 238, 0.4)' },'50%': { boxShadow: '30px 0px...
View ArticleWhy is this object a Proxy only when the page field is 1?
Steps to reproduce:Open the reproductionOpen the browser consoleWhen the project starts it will errors with:Uncaught (in promise) DOMException: Failed to execute 'put' on 'IDBObjectStore':...
View ArticleWhy does Sveltekit skip code block that would result in ReferenceError during...
By default sveltekit does SSR followed by CSR, so when I try to access window object from the server side I get an error as expected.<script lang="ts"> import { browser } from "$app/environment";...
View ArticleImporting UI external DOM manipulator to svelte client
I am not a frontend developer so I hope I use the right terms here.I am playing with sapper. I found a free jQuery, Bootstrap html template and migrate it to sapper. I extracted some code segment to be...
View ArticleHow to prevent unhandled exception from appearing in the UI?
I am using Svelte 4 with"@sveltejs/kit": "^2.0.0","@sveltejs/vite-plugin-svelte": "^3.0.0","svelte": "^4.2.7",When I run the app using:npm run devwhich calls vite dev underneathand try to access an...
View Articlesvelte: how to use event modifiers in my own components
I want to developt my own Button component and be able to handle event modifiers, like this:<MyButton on:click|preventDefault={handler}>Click me</MyButton>But I get the following...
View Article