@beyonk/svelte-toggle

1.4.0 • Public • Published

Beyonk

Svelte Toggle

by @antony

js-standard-style CircleCI svelte-v3

A toggle component for Svelte.

Installation

npm i -D @beyonk/svelte-toggle

Usage

Basic:

<Toggle bind:checked on:change={someFunction} />

<script>
  import Toggle from '@beyonk/svelte-toggle'

  let checked = false
</script>

Labels

Specify both on and off labels

<Toggle bind:checked onLabel="Checked" offLabel="Unchecked />

<script>
  import Toggle from '@beyonk/svelte-toggle'

  let checked = false
</script>

Change event

<Toggle bind:checked on:change={someFunction} />

<script>
  import Toggle from '@beyonk/svelte-toggle'

  function someFunction () {
    console.log('Toggle changed value')
  }
</script>

Styling

You can pass in some custom styling:

  const css = {
    fontSize: '1rem',
    align: 'left',
    checkedColor: '#bbe572'
  }

  <Toggle bind:checked {css} />

Package Sidebar

Install

npm i @beyonk/svelte-toggle

Weekly Downloads

14

Version

1.4.0

License

none

Unpacked Size

21.6 kB

Total Files

6

Last publish

Collaborators

  • jedwoodcock
  • leandro.silva
  • alex.dilley
  • antony
  • adampond