New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@vueform/toggle

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vueform/toggle

Vue 3 toggle component

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source
CircleCI npm bundle size (scoped version) GitHub Discord npm

Vue 3 Toggle






Sponsors

Toggle features

  • Vue 2 & 3 support
  • No dependencies
  • Lightweight (~1 kB gzipped)
  • 100% coverage
  • ESM support
  • Fully configurable
  • Dynamic styles
  • On / Off labels

Demo

Check out our demo.

Installation

npm install @vueform/toggle

Usage with Vue 3

<template>
  <div>
    <Toggle v-model="value" />
  </div>
</template>

<script>
  import Toggle from '@vueform/toggle'

  export default {
    components: {
      Toggle,
    },
    data() {
      return {
        value: true
      }
    }
  }
</script>

<style src="@vueform/toggle/themes/default.css"></style>

Usage with Vue 2

When using with Vue 2 make sure to install @vue/composition-api first and change the imported module to:

import Toggle from '@vueform/toggle/dist/toggle.vue2.js'

Support

Join our Discord channel or open an issue.

Basic props

NameTypeDefaultDescription
idstringtoggleThe id attribute of input field. Make sure to customize when using more toggles on a single page.
namestringtoggleThe name attribute of input field.
falseValuestring|number|booleanfalseThe value when the toggle is off.
trueValuestring|number|booleantrueThe value when toggle is on.
offLabelstringThe label when toggle is off.
onLabelstringThe label when toggle is on.
widthnumber54The width of the toggle in px.
heightnumber24The height of the toggle in px.
speednumber300The speed of toggle switch in milliseconds.
offBackgroundstring#d4e0e7The color of background when toggle is off.
onBackgroundstring#41b883The color of background when toggle is on.
offTextColorstring#888888The color of text when toggle is off.
onTextColorstring#ffffffThe color of text when toggle is on.
handleColorstring#ffffffThe background color of toggle handle.
fontSizestring13pxThe font size of toggle labels.

Events

EventAttributesDescription
@changevalueEmitted when the toggle changes.

Slots

SlotAttributesDescription
offRendered when the toggle is off (by default offLabel).
onRendered when the toggle is on (by default onLabel).

Examples

Default toggle

<Toggle
  v-model="value"
/>

JSFiddle - Example #1

Toggle with labels

<Toggle
  v-model="value"
  on-label="On"
  off-label="Off"
  id="example2"
/>

JSFiddle - Example #2

Toggle with custom stylesg

<Toggle
  v-model="value"
  font-size="15px"
  on-background="#35495e"
  id="example3"
  :width="80"
  :height="30"
  :speed="500"
/>

JSFiddle - Example #3

About Vueform

Vueform streamlines the entire form building process in Vue 2 & 3. It comes with 30+ elements, file uploads, element nesting, 50+ validators, conditions, form steps, i18n including reactive configuration, API access, ESM modules and many more. Check out our live demos or see all the features and sign up for beta to get early access.

License

MIT

FAQs

Package last updated on 05 Jan 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc