Svelte & SvelteKit (50 Qs)•Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)
Svelte Transitions & Animations: `in:`, `out:`, `transition:`, and FLIP `animate:`.
senior LevelCode ExampleSystem DesignSvelte 5
In Simple Words: Svelte has built-in declarative transitions that require zero third-party CSS libraries:
transition:fade: Plays on both mount and unmount.in:fly/out:slide: Separate distinct entrance and exit animations.animate:flip: Smoothly animates reordering of items in{#each ... (key)}blocks using the First-Last-Invert-Play technique.
svelte
<script>
import { fade, fly } from 'svelte/transition';
import { flip } from 'svelte/animate';
let items = $state([1, 2, 3]);
</script>
{#each items as item (item)}
<div in:fly={{ y: 20 }} out:fade animate:flip={{ duration: 300 }}>
Item {item}
</div>
{/each}