Code · 1 file

Sample Svelte File

Svelte components compile to plain JavaScript. This sample uses Svelte 5 runes. The Svelte sample is a small program — a customer record, a VIP check and a formatted total — that is the same in every language we offer, so you can compare them side by side.

Svelte · 397 B

Sample Svelte component file

An idiomatic Svelte component example: a customer record type, a VIP check, a total and a formatted loop — the same program in every language we offer.

CC0 · free for any use · Verified by an independent tool · Report a problem

Sample.svelte — first linesSvelte
<!-- Sample Svelte 5 component — samplefiles.com -->
<script>
  let { customers } = $props();
  let vipOnly = $state(false);
  let shown = $derived(vipOnly ? customers.filter((c) => c.balance >= 10000) : customers);
</script>

<label><input type="checkbox" bind:checked={vipOnly} /> VIP only</label>
<ul>
  {#each shown as c (c.id)}
    <li>{c.name}: {c.balance.toFixed(2)}</li>
  {/each}
</ul>

File details

Size
397 B (397 bytes)
MIME type
text/plain
SHA-256
c4ee0056d2dc942d171a47e065b0241d61363e60a9b9a8b89197cb79bc412f3e
MD5
eedf1bd1f058017c1c12ae8e5b5f2654

Download from the command line

curl -L -o Sample.svelte https://files.samplefiles.com/code/svelte/Sample.svelte

Or check the download in your browser with the checksum calculator.