1.0.3 • Published 3 years ago

vue3-toggle-button v1.0.3

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

Vue 3 Toggle Button

For use with Vue 3, TypeScript and the Composition API. Feedback welcome.

Example

Usage

Install via NPM

npm install vue3-toggle-button

Then require in your project:

import { Vue3ToggleButton } from 'vue3-toggle-button'
import '../node_modules/vue3-toggle-button/dist/style.css'

Then use it

<Vue3ToggleButton v-model:isActive="isActive" :handleColor="'#cc00cc'"> </Vue3ToggleButton>

Properties

propertyTypeDefaultDescription
isActivebooleanfalseholds the current boolean state of the button - can be false or true
handleDiameternumber30Sets the handle diameter (the round button moving)
handleColorstring#fffSets the handle color
handleBorderRadiusstring50%Sets the handle border radius
trackWidthnumber70Sets the track width
trackHeightnumber30Sets the track height
trackColorstring#cccSets the default track color
trackColorstring#2196F3Sets the active status track color(after toggled)
trackBorderWidthnumber0Sets the track border width
trackBorderRadiusstring34pxSets the track border radius

See App.vue for a sample. There is also a folder called local-example with a stand alone example.

<script setup lang="ts">
import { ref } from 'vue'
import Vue3ToggleButton from './components/Vue3ToggleButton.vue'

const isActive = ref(true);

function toggle(value :boolean) {
  isActive.value = !isActive.value;
}
</script>

<template>

  <Vue3ToggleButton v-model:isActive="isActive" :handleColor="'#cc00cc'"> </Vue3ToggleButton>
  <p  @on-change="toggle">Value:  {{isActive}}</p>
</template>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
}
</style>


This is a Vue 3 version of [vue-toggle-btn](https://www.npmjs.com/package/vue-toggle-btn)
Some code was based on work by [Max Leiter](https://maxleiter.com/)
1.0.3

3 years ago

1.0.0

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago

0.0.3

3 years ago