by @antony
A toggle component for Svelte.
npm i -D @beyonk/svelte-toggle
Basic:
<Toggle bind:checked on:change={someFunction} />
<script>
import Toggle from '@beyonk/svelte-toggle'
let checked = false
</script>
Specify both on and off labels
<Toggle bind:checked onLabel="Checked" offLabel="Unchecked />
<script>
import Toggle from '@beyonk/svelte-toggle'
let checked = false
</script>
<Toggle bind:checked on:change={someFunction} />
<script>
import Toggle from '@beyonk/svelte-toggle'
function someFunction () {
console.log('Toggle changed value')
}
</script>
You can pass in some custom styling:
const css = {
fontSize: '1rem',
align: 'left',
checkedColor: '#bbe572'
}
<Toggle bind:checked {css} />