Quantcast
Channel: Active questions tagged svelte - Stack Overflow
Browsing all 1539 articles
Browse latest View live
↧

Building Svelte custom elements will mixup styles and code

My project is a library of Web Components built with Svelte. The idea is to build a separate JavaScript file for each of the components.I have noticed an odd behavior when building this library and...

View Article


How can I define type for a component as an icon in svelte, typescript?

I am trying to build a navigation menu in SvelteKit.const navigationMenu: { path: string; label: string; icon:??? }[] = [ { path: '/', label: 'Home', icon: Home },I want to render the icon in each...

View Article


Svelte and form with dynamic inputs

I want to create a form to retrieve a person's name and country, but with the possibility of adding several lines of the same type on client side before submitting the form. Here is the code I use./*...

View Article

Where does the :not(#\#):not(#\#) selector come from?

My css as written:/* .elevation-0 {} */.elevation-1 { box-shadow: var(--elevation-color-1) 0px 2px 1px -1px, var(--elevation-color-2) 0px 1px 1px 0px, var(--elevation-color-3) 0px 1px 3px...

View Article

How to avoid duplication in VSCode intellisense when exporting defaults?

I have a directory structure like so:lib/assets/thing/index.tslib/assets/thing/stuff/A.sveltelib/assets/thing/stuff/B.sveltelib/assets/thing/stuff/C.sveltelib/assets/thing/stuff/D.svelteOne of these...

View Article


How to update a chart with data coming from an API endpoint in Svelte?

I am using the Svelte JS web framework with the Chart.js charting library to plot a bar chart. I have created a Skeleton project and installed the svelte-chartjs and the chart.js packages:npm install...

View Article

How to use local static images in Svelte

I was following the tutorial (https://svelte.dev/tutorial/dynamic-attributes) to import local image files. But it didn't work. The image was not found in the app. Where do I need to locate these images...

View Article

Cannot find $env package problem in sveltekit app

I'm trying to use environment variables in my svelte app following the sveltekit docs, but I keep getting the error message: Error [ERR_MODULE_NOT_FOUND]: Cannot find package '$env' imported from...I...

View Article


Updating a Svelte store value onMount doesn't work

In one of my Svelte components, I'm trying to reset the count value in the store to 0 upon mounting the component.Here's how I'm attempting to do it:<script> import { onMount } from "svelte";...

View Article


Svelte transition running function before and after

I have a use case where I want to expand a small image into something fullscreened.Kind of like what is done in Example3 as shown by this...

View Article

While looping an array of objects in Svelte, how can I display the iteration...

I am iterating a JSON with the help of Svelte's onMount method. I have displayed the data in a table.<script> import { onMount } from "svelte"; const apiURL =...

View Article

Global CSS in sveltekit + vite

I installed a library from my work that consists of fonts and css files. It was originaly made for Angular, but i need to use it inside my SvelteKit project.Despite looking for few hours, i cannot find...

View Article

Image may be NSFW.
Clik here to view.

How to extract a Chart.js chart with reactive attributes as a separate...

I have created a Skeleton Project using the npm create svelte@latest myapp command. Next, I installed the Chart.js with npm install svelte-chartjs chart.js and created a simple bar chart:<script>...

View Article


When using multiple stores in Svelte, the information from one store does not...

I'm having issues with stores in Svelte. Currently, I'm using derived to update a filter as the stores get updated.Here's an example of the function:export const FILTERED_SORTED_BIDS =...

View Article

How to avoid writing the same code for component in frontend frameworks?...

In a project I have two similar components for displaying/selecting time (hours, minutes and seconds). Both of them will look the same in the UI, here's an example when hours = 1, seconds = 20 and...

View Article


Styling Markdown output

I'm using Sveltekit & SCSS for my development.I've been trying to use the marked npm package to get Markdown onto my site. I've been able to get markdown working, but having trouble styling the...

View Article

Astro, seeing `X [ERROR] The build was canceled` in build output (npm run build)

I'm seeing the following the following error in the console logs on npm run build ("build": "astro check && astro build"). The build actually completes following this, but I don't like not...

View Article


SvelteKit Load data from backend to component

I have a Java Spring API i want to get data from , and display them in my component eg. Test.svelte i use in my +layout.svelte . I dont want to have a fetch directly to the Api But the svelte...

View Article

Svelte: How to use template expressions in a 'style' block?

I am trying to create a simple Svelte Component (NumberFormatting)<script lang="ts"> export let number: string ; const formatNumber = (value: string) => { return Number(value).toFixed(2); };...

View Article

How to update an array after splice in Svelte?

I'm learning Svelte, and read in the documentation that arrays need to be reassigned in order for a component or page to update it. For that they devised a more idiomatic solution. Instead of...

View Article
Browsing all 1539 articles
Browse latest View live


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