vue-button-spinner

A simple button spinner.
16,948 35
Install
npm install vue-button-spinner
Latest Version:2.2.1
Vue:2
License:MIT
Last Updated:Mar 15, 2024
Links: GitHub  ·  npm
Maintainer: jnieto

VueButtonSpinner

npm version

Simple VUE 2 component to create a button spinner. The perfect solution for your submit buttons!

alt tag

Features

  • Show an css loader into the button to indicate the request status.
  • Add a custom html inside the component.
  • Pure CSS loaders, no fonts or images have been used.
  • Different styles for each state: loading, success, error.
  • Available props:
    • 'isLoading' (boolean) to show the spinner
    • 'status' (String | Boolean) allow 'success' or true and 'error' or false.
  • Remember use the .native modifier for the events (docs)

Install

npm install vue-button-spinner

Usage

Example:

[Your .vue component (vue-loader with webpack or use vue-cli projects)]


import VueButtonSpinner from 'vue-button-spinner';

export default {
		name: 'events-form',
		data() {
			return {
				isLoading: false,
				status: '',
			}
		},
		components: {	
			VueButtonSpinner
		},
		methods: {
			onSubmit() {
			    this.isLoading = true
				$someRequest('/url', 'GET')
				.then(response => {
					this.isLoading = false
					this.status = true // or success
					setTimeout(() => { this.status = '' }, 2000) // to clear the status :)
				})
				.catch(error => {
					console.error(error)
					this.isLoading = false
					this.status = false //or error
				})
			}
		}
}

[Your HTML code]


<button-spinner
	:is-loading="isLoading" 
	:disabled="isLoading"
	:status="status">
	<span>Submit</span>
</button-spinner>

Related Packages

node-esm-loader

A webpack-like loader for Node

48,094 8
vue-event-handler

Global event bus for Vue 1 and Vue 2.

2,456 15
vue-bus

A event bus for Vue.js

338,089 309
http-vue-loader

Load .vue files directly from your html/js. No node.js environment, no build ste...

52,627 1,477
mpvue-loader

mpvue single-file component loader for Webpack

20,800 46

Version History

Version Released Vue License
2.2.1 ^2.5.2 MIT
2.2.0 ^2.5.2 MIT
2.1.0 ^2.5.2 MIT
2.0.0
1.2.0 MIT