1.0.1 • Published 4 years ago

svelte-checkbox v1.0.1

Weekly downloads
158
License
MIT
Repository
github
Last release
4 years ago

svelte-checkbox

A checkbox component for Svelte (Cool animation, Customizable).

☑️ Demo

Installation

yarn add svelte-checkbox

Usage

<script>
  import Checkbox from "svelte-checkbox";

  let checked = false;
</script>

<Checkbox bind:checked></Checkbox>

Props

PropTypeDefaultDescription
sizeString3remComponent width & height
nameString-Input name
idString-Component id
classString-Component class
primaryColorString#242432Primary color
secondaryColorString#d8d8eaSecondary color
checkedBooleanfalseChecked input

Events

Event NameCallbackDescription
change(event) => event.detailfires when checked/unchecked
<script>
  import Checkbox from "svelte-checkbox";

  function handleChange({ detail }) {
    console.log("checked", detail);
  }
</script>

<Checkbox on:change="{handleChange}" />

Full Usage

<script>
  import Checkbox from "svelte-checkbox";

  let checked = false;
</script>

<style>
  :global(.main__checkbox) {
    margin: 0.5rem;
  }
</style>

<Checkbox
  class="main__checkbox"
  size="5rem"
  bind:checked
  name="inputName"
  secondaryColor="rgba(1, 50, 67,0.2)"
  primaryColor="rgb(77, 5, 232)"
/>

Join Our Telegram Community