Skip to content

Instantly share code, notes, and snippets.

@alejovdev
Created January 28, 2020 17:53
Show Gist options
  • Save alejovdev/423be59825219c6bc4c6cf954bb694b8 to your computer and use it in GitHub Desktop.
Save alejovdev/423be59825219c6bc4c6cf954bb694b8 to your computer and use it in GitHub Desktop.
<script>
export let dark;
function handleToggle() {
dark = !dark;
}
</script>
<style>
.container {
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
}
.toggle {
border: none;
outline: none;
border-radius: 5px;
padding: 10px;
color: white;
}
.toggle:hover {
cursor: pointer;
}
.dark {
background-color: #3b5998;
color: white;
}
.light {
background-color: #ffffff;
color: black;
}
</style>
<div class="container {dark ? 'dark' : 'light'}">
<button class="toggle {dark ? 'light' : 'dark'}" on:click={handleToggle}>
Toggle background
</button>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment