1.1.1 • Published 3 years ago

@2alheure/vue-toggle v1.1.1

Weekly downloads
-
License
WTFPL
Repository
github
Last release
3 years ago

Vue.js Toggle button

A simple Vue.js toggle button.
This component is compatible with Vue 3.

It has been inspired by this article by ALEXANDRU STRATULAT, so check it out if you wish to understand how it works.

Simple usage

First run npm install @2alheure/vue-toggle.
Then its usage is simple :

<template><Toggle v-model="isToggled" /></template>

<script>
import Toggle from "@2alheure/vue-toggle";

export default {
  components: {
    Toggle
  },
  data() {
    return {
      isToggled: false
    }
  }
};
</script>

Please note the v-model directive, as it is usable as an input (and is one, intrinsically).

Props

NameTypeDefault valueDescription
nameStringSome random stringThe name of the inner input.
colorOKString#0d9488The color of the toggle when it is toggled ON.
colorKOString#6b7280The color of the toggle when it is toggled OFF.
widthString3remThe width of the toggle.
heightString1.5remThe height of the toggle.
modelValueBooleanfalseThe prop lnked to the v-model directive. (mandatory)

Events

Events

NameValue typeValueDescription
update:modelValueBooleanThe toggle valueEmitted each time the toggle switches