Skip to content

eperedo/vue-toggle

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

v-toggle

a simple a simple toggle component for Vue 2.x.x

design from here

Demo in codepen

v-toggle

Usage

  1. Install from npm
npm install v-toggle

If you are using plain html you can use the umd version from here

<script src="https://unpkg.com/v-toggle/dist/v-toggle.umd.min.js"></script>
  1. Include as a component in your app
import v-toggle from 'v-toggle';

export default {
  name: 'my-component',
  data() {
    return {
      toggleValue: true,
    };
  },
  components: {
    vToggle, // window.vToggle.default for umd version
  },
};
  1. Include the component in your template, do not forget the id and v-model property!
<v-toggle id="v-t-default" v-model="toggleValue" />
  1. That's it! Now you have a simple toggle in your app! 😏

Build Setup

# install dependencies
npm install

# serve with hot reload at localhost:8080
npm run dev

# build for production with minification
npm run component