0.1.2 • Published 5 years ago

vue-toggle-btn v0.1.2

Weekly downloads
43
License
-
Repository
-
Last release
5 years ago

vue-toggle-btn

A Highly Customizable, easy-to-use elegant toggle/switch button component

MIT License view on npm

Demo

toggle-btn

Usage

Install via NPM npm i vue-toggle-btn

Then require in your project:

var VueToggleBtn = require('vue-toggle-btn');

or ES6 syntax:

import VueToggleBtn from 'vue-toggle-btn';

Then you can register the component globally:

Vue.component('vue-toggle-btn', VueToggleBtn);

Or in your Vue component:

components: {
  ToggleBtn
}

You can then use the following selector anywhere in your project:

  • To get up and running quick the package now supports rendering just the selector with default values
<vue-toggle-btn></vue-toggle-btn>

Properties

options is a full configuration object holding the toggle-button building blocks which are handle, track and isActive

propertyTypeDescription
optionsobjectholds all toggle button style configurations
isActivefalseholds the current boolean state of the button - can be false or true
handleobjectholds all handle style configurations
trackobjectholds all track style configurations

handle

propertyTypeDefaultDescription
diameternumber30Sets the handle diameter (the round button moving)
colorstring#fffSets the handle color
borderRadiusstring50%Sets the handle border radius

track

propertyTypeDefaultDescription
widthnumber70Sets the track width
heightnumber30Sets the track height
colorstring#cccSets the default track color
activeColorstring#2196F3Sets the active status track color(after toggled)
borderWidthnumber0Sets the track border width
borderRadiusstring34pxSets the track border radius

events

Event NameReturnsDescription
setIsActiveisActiveClicking the toggle button emits an its current isActive boolean state

Listening to the event e.g:

<vue-toggle-btn @isActive="myLocalSetterFunction($event)"></vue-toggle-btn>

Feedback would be much appreciated, questions, suggestions, issues are more than welcome.


If you like to support my open-source contributions and feeling generous, feel free to: