Skip to main content
Create new
Introduction
Reactivity
Props
Logic
Events
Bindings
Lifecycle
Stores
Motion
Transitions
Animations
Easing
SVG
Actions
Classes
Component composition
Context API
Special elements
Module context
Debugging
7GUIs
Miscellaneous
App.svelte
<script>
import {flip} from 'svelte/animate';
let horizontal = false;
let next = 1;
let list = [];
const addItem = () => list = [next++, ...list];
const removeItem = number => list = list.filter(n => n !== number);
const options = {};
</script>

<label>
Horizontal
<input type="checkbox" bind:checked={horizontal} />
</label>
<button on:click={addItem}>Add</button>
{#each list as n (n)}
<div animate:flip={options} class:horizontal class="container">
<button on:click={() => removeItem(n)}>{n}</button>
</div>
{/each}

<style>
.container {
width: fit-content; /* necessary for correct button sizes */
}
.horizontal {
display: inline-block;
margin-left: 10px;
}
</style>
loading Svelte compiler...
/* Select a component to see its compiled code */
result = svelte.compile(source, {
generate: ,
});
/* Select a component to see its compiled code */