Home

Awesome

<p align="center"> <a href="#"> <img src="https://github.com/Carrene/vue-loading-checkbox/blob/master/src/assets/checkbox-demo.gif?raw=true" alt="vue-loading-checkbox" /> </a> </p> <h1 align="center" >vue-loading-checkbox</h1> <p align="center" class="badges" > <a href="https://www.npmjs.com/package/vue-loading-checkbox"><img src="https://badge.fury.io/js/vue-loading-checkbox.svg" alt="npm version" /></a> </p>

A vue UI component for loading checkbox

How to install

npm install vue-loading-checkbox --save

How to use

Inside your .vue files

<template>
  <div id="your-component">
    <!-- Using Component -->
    <loading-checkbox
      :checked="checked"
      :loading="loading"
      label="Title of checkbox"
      @click.native="toggleStatus"
    />
  </div>
</template>
<script>
// Importing Component and style
import LoadingCheckbox from 'vue-loading-checkbox'
import 'vue-loading-checkbox/dist/LoadingCheckbox.css'

export default {
  name: 'YourComponentName',
  data() {
    return {
      checked: false,
      loading: false
    }
  },
  methods: {
    toggleStatus() {
      this.loading = true
      setTimeout(() => {
        this.loading = false
        this.checked = !this.checked
      }, 2000)
    }
  },
  components: {
    LoadingCheckbox // Registering Component
  }
}
</script>

Component props

propdescriptiondefault
borderColorColor of checkbox borderblack
borderRadiusBorder radius of checkbox0
borderStyleStyle of checkbox border, (solid, dashed, dotted, ...)solid
borderWidthwidth of checkbox border. You have to insert unit (px,em...)1px
checkColorColor of check markwhite
checkedStatus of component. can be true(checked) or false(unchecked)false
checkedBackgroundColorBackground color of checkbox when status is checkedgray
checkedBorderColorBorder color of checkbox when status is checkednull (same as borderColor)
checkedBorderRadiusBorder radius of checkbox when status is checkednull (same as borderRadius)
checkedBorderStyleBorder style of checkbox when status is checkednull (same as borderStyle)
checkedBorderWidthBorder width of checkbox when status is checkednull (same as borderWidth)
checkIconCustom check mark image (.svg, png, etc). you have to pass it with require functionnull A default pure css check
checkIconPaddingPadding of the given custom check mark image (This will not affect the size)null
fontColorText color of labelblack
fontSizeFont size of labelnull (calculated based on size)
gapGap size between checkbox and its label in px.null (calculated based on size)
labelLabel of checkboxnull (no label)
loadingIf true component is in loading state. it has a higher priority than checkedfalse
loadingBackgroundColorBackground color of checkbox when status is loadingwhite
loadingBorderColorBorder color of checkbox when status is loadingnull (same as borderColor)
loadingBorderRadiusBorder radius of checkbox when status is loadingnull (same as borderRadius)
loadingBorderStyleBorder style of checkbox when status is loadingnull (same as borderStyle)
loadingBorderWidthBorder width of checkbox when status is loadingnull (same as borderWidth)
sizeSize of component in px.30
spinnerColorColor of spinnerblack
spinnerRingColorColor of loading ringlightgray
uncheckedBackgroundColorBackground color of checkbox when status is uncheckedwhite
uncheckedBorderColorBorder color of checkbox when status is uncheckednull (same as borderColor)
uncheckedBorderRadiusBorder radius of checkbox when status is uncheckednull (same as borderRadius)
uncheckedBorderStyleBorder style of checkbox when status is uncheckednull (same as borderStyle)
uncheckedBorderWidthBorder width of checkbox when status is uncheckednull (same as borderWidth)

:warning: Warning: You have to v-bind custom icon path with require function:

v-bind:checkIcon="require(@/assets/path/to/icon.svg)" :heavy_check_mark:

:checkIcon="require(@/assets/path/to/icon.svg)" :heavy_check_mark:

checkIcon="@/assets/path/to/icon.svg" :x:

checkIcon="require(@/assets/path/to/icon.svg)" :x:

Contributing

Visit CONTRIBUTING Page

Project setup

npm install

Compiles and hot-reloads for development

npm run serve

Compiles and minifies for production

npm run build-bundle

Lints and fixes files

npm run lint

License

MIT