Lightweight Toggle Switches For Vue.js 3

Description:

A lightweight customizable toggle switch with on/off labels for Vue.js 2 & Vue.js 3 apps.

How to use it:

1. Import and register the component.

<style src="@vueform/toggle/themes/default.css"></style>
import Toggle from '@vueform/toggle'
export default {
  components: {
    Toggle,
  }
}

2. Add the toggle switch component to the app template.

<Toggle v-model="value" />

3. Config the toggle switch with the following props.

id: {
  type: [String, Number],
  required: false,
  default: 'toggle'
},
name: {
  type: [String, Number],
  required: false,
  default: 'toggle'
},
falseValue: {
  type: [String, Number, Boolean],
  required: false,
  default: false,
},
trueValue: {
  type: [String, Number, Boolean],
  required: false,
  default: true,
},
offLabel: {
  type: [String, Object],
  required: false,
  default: ''
},
onLabel: {
  type: [String, Object],
  required: false,
  default: ''
},
width: {
  type: Number,
  required: false,
  default: 54
},
height: {
  type: Number,
  required: false,
  default: 24
},
speed: {
  type: Number,
  required: false,
  default: 300
},
offBackground: {
  type: String,
  required: false,
  default: '#d4e0e7'
},
onBackground: {
  type: String,
  required: false,
  default: '#41b883'
},
offTextColor: {
  type: String,
  required: false,
  default: '#888888'
},
onTextColor: {
  type: String,
  required: false,
  default: '#ffffff'
},
handleColor: {
  type: String,
  required: false,
  default: '#ffffff'
},
fontSize: {
  type: String,
  required: false,
  default: '13px'
},

Preview:

Lightweight Toggle Switches For Vue.js 3

Changelog:

v1.1.0 (01/06/2020)

  • restructured colors property

Download Details:

Author: vueform

Live Demo: https://jsfiddle.net/p60t2bs4/2/

Download Link: https://github.com/vueform/toggle/archive/main.zip

Official Website: https://github.com/vueform/toggle

Install & Download:

# Yarn
$ yarn add @vueform/toggle

# NPM
$ npm i @vueform/toggle

You Might Be Interested In:

Tags:

Add Comment