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>
let rows = [];
// Create 100 empty rows
for(let i = 0; i < 100; i++) {
rows[i] = [];
}
// Update every item in the table
function updateEverything() {
for(let row = 0; row < 100; row++) {
for(let col = 0; col < 10; col++) {
rows[row][col] = (Math.random() * 100).toPrecision(3);
}
}
}
// Update the values 100 times per second
setInterval(updateEverything, 1000 / 100);
</script>

<style>
table {
/* not sure if this matters much */
/*table-layout: fixed;*/
}
.red { color: red; }
.blue { color: blue; }
</style>

<table>
{#each rows as cells}
<tr>
{#each cells as cell}
<td class={cell < 50 ? "red" : "blue"}>{cell}</td>
{/each}
loading Svelte compiler...
/* Select a component to see its compiled code */
result = svelte.compile(source, {
generate: ,
});
/* Select a component to see its compiled code */