You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, there appears to be no way to pass a transition to an element in a nested component. For a standard <button> DOM element, you could do something like this:
<script>
import { fade } from'svelte/transition';
</script>
<buttontrasition:fade>Gather ye rosebuds while ye may</button>
If you wanted to apply the same transition to a button element within a Button component, there is no way to forward that transition down, or even pass the transition down as a prop and then implement it in the nested button.
Describe the proposed solution
This would be an ideal implementation, being able to import the desired transition into the top-level component and then pass it into the component:
<!-- App.svelte -->
<script>
import { fade } from'svelte/transition';importButtonfrom'./Button.svelte';
</script>
<Buttontransition:fade>Old Time is still a-flying</Button>
<!-- Button.svelte -->
<script>
exportlet transition;
</script>
<buttontransition:{transition}><slot /></button>
Alternatives considered
The alternative I see, which is not idea, would be to wrap the component in a DOM element and apply the transition on the DOM element instead, like this:
<!-- App.svelte -->
<script>
import { fade } from'svelte/transition';importButtonfrom'./Button.svelte';
</script>
<divtransition:fade>
<Button>Old Time is still a-flying</Button>
</div>
<!-- Button.svelte -->
<button><slot /></button>
Importance
would make my life easier
The text was updated successfully, but these errors were encountered:
Describe the problem
Currently, there appears to be no way to pass a transition to an element in a nested component. For a standard
<button>
DOM element, you could do something like this:If you wanted to apply the same transition to a button element within a Button component, there is no way to forward that transition down, or even pass the transition down as a prop and then implement it in the nested button.
Describe the proposed solution
This would be an ideal implementation, being able to import the desired transition into the top-level component and then pass it into the component:
Alternatives considered
The alternative I see, which is not idea, would be to wrap the component in a DOM element and apply the transition on the DOM element instead, like this:
Importance
would make my life easier
The text was updated successfully, but these errors were encountered: