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.
Questions tagged [svelte-component]
464 questions
37
votes
7 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?

Jacques Amsel
- 1,061
- 2
- 14
- 30
27
votes
4 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
- 110,530
- 99
- 389
- 494
23
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
- 453
- 1
- 4
- 10
16
votes
1 answer
How should I use Svelte Reactivity with DOM getElementById?
I have a div element where it is scrollable