Skip to content

Instantly share code, notes, and snippets.

@thawkin3
Last active July 9, 2020 21:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thawkin3/4c512d0109db701c26faa3cecd556813 to your computer and use it in GitHub Desktop.
Save thawkin3/4c512d0109db701c26faa3cecd556813 to your computer and use it in GitHub Desktop.
Svelte Web Component Example
<svelte:options tag="my-counter" />
<script>
let count = 0;
function inc() {
count++;
}
function dec() {
count--;
}
</script>
<style>
* {
font-size: 200%;
}
span {
width: 4rem;
display: inline-block;
text-align: center;
}
button {
width: 64px;
height: 64px;
border: none;
border-radius: 10px;
background-color: seagreen;
color: white;
}
</style>
<button on:click={dec}>
-
</button>
<span>{count}</span>
<button on:click={inc}>
+
</button>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment