Questions tagged [svelte-component]

In Svelte, an application is composed of one or more components. A component is a reusable self-contained block of code that encapsulates HTML, CSS and JavaScript that belong together, written into a .svelte file.

192 questions
18
votes
3 answers

How can I export a function from a Svelte component that changes a value in the component?

I have a component called WastedTime.svelte with a value wastedTime. There's also a function to change the value to 50 (in my real code, this does an animation but this is a reduced test case for Stack Overflow). To allow the child function to be…
mikemaccana
  • 81,787
  • 73
  • 317
  • 396
15
votes
6 answers

How to target a component in svelte with css?

How would I do something like this: i.e. How do I apply a style to a component from its parent?
Dextication
  • 715
  • 1
  • 8
  • 23
8
votes
1 answer

How to have a conditional attribute in Svelte 3?

Is there a simpler way to write the following checkbox component: {#if disabled} {:else} …
batisteo
  • 284
  • 3
  • 8
8
votes
2 answers

How to create and style svelte 3 custom elements with nested components?

I'm trying to create custom-element (web component) in svelte 3. I can't find any way to style nested components from css. Svelte removes styles before injecting them to