1.0.16 • Published 3 years ago

vue-toggle-component v1.0.16

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

vue-toggle-component makes an ease to use, lightweight and highly customizable toggle component for Vue.js. This component is available in both light and dark mode and it supports Vue 3.

npm bundle size npm GitHub issues npm GitHub Repo stars

Light theme Dark theme

Features

  • 🍞 Easy: Easy use with minimal required properties.
  • 🍤 Tiny: Small footprint < 4kb which makes your apps faster to load.
  • ✅ Accessible: ARIA attributes in the component which makes it very accessible.

Getting Started

Installation

Installing the package

# install with yarn
yarn add vue-toggle-component

# install with npm
npm install vue-toggle-component --save

Usage

Example

<template>
  <VueToggle title="Toggle me" name="VueToggle"/>
</template>

<script>
import VueToggle from "vue-toggle-component";

export default {
  name: 'App',
  components: {
    VueToggle
  }
}
</script>

Properties that vue-toggle-component uses

Property nameTypeDefaultRequiredDescription
nameString✅️Set's the name value of the input (checkbox). Useful for persisting data.
titleStringThe title that is displayed next to the toggle.
activeColorString#9FD6AEThe color that is displayed when the toggler is active.
darkThemeBooleanfalseSet's dark mode to active. (note that this will not change the background like in the preview GIF)
disabledNumberfalseDisables the toggler.
fontSizeString16pxSets the font size of the text next to the toggle
fontWeightBooleannormalSets the font weight of the text next to the toggle.
toggledBooleantrueSets the default value for the toggler.

Events

When you toggle the component the component emits the toggle event. You can use the event using the example below. The value in the event is the whether the toggler is toggled or not.

<template>
  <VueToggle title="Toggle me" name="VueToggle" @toggle="doSomething"/>
</template>

<script>
import VueToggle from "vue-toggle-component";

export default {
  name: 'App',
  components: {
    VueToggle
  },
  methods: {
    doSomething(value) {
      // value = true || false.
    }
  },
}
</script>

Vue version support

The main v1 version supports Vue 3.x only, for previous versions of Vue, check the following the table.

Vue versionvue-toggle-component version
2.x0.1.x
3.x1.x

Authors

Niels Bosman

www.github.com/niels-bosman

https://nielsbosman.dev

Mike van Egmond

www.github.com/mve

https://egmond.dev

License

MIT

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

1.0.16

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

0.1.2

4 years ago

0.1.1

4 years ago