1.0.0 • Published 3 years ago

@shapla/vue-switch v1.0.0

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

Shapla Switch

Switch is an enhanced version of the standard HTML input checkbox element for Vue 3

Table of contents

Installation

npm install --save @shapla/vue-switch

Usage

Add the component:

import ShaplaSwitch from '@shapla/vue-switch';

export default {
  name: 'Hello',

  components: {
    ShaplaSwitch
  },

  data() {
    return {
      singleSwitch: false
    }
  }
}
<shapla-switch v-model="singleSwitch">Enable this</shapla-switch>

Props

PropertyTypeRequiredDefaultDescription
labelStringno | Switch label
valueStringnoonThe default value for the switch
trueValueStringnotrueThe value when user checked the switch
falseValueStringnofalseThe value when user unchecked the switch
disabledBooleannofalseIf set true, box-shadow will be added around button.
readonlyBooleannofalseIf set true, you cannot change the value.

Listeners

The switch component fires the following events:

update:modelValue: When switch is clicked, it fires the event.

<!-- template -->
<shapla-button @update:modelValue="handleChange"></shapla-button>


<!-- method -->
methods: {
handleChange(newValue){
// Handle change event
}
}