vue-form-wizard
A dynamic form wizard to split your forms easier
Vue-form-wizard is a vue based component with no external depenendcies which simplifies tab wizard management and allows you to focus on the functional part of your app rather than
wasting time on details. Just forget about id's, external scripts and jQuery dependencies
Demos & Playground
In browser playground
JSFiddle demos:
Basic demo
Other demos:
Usage
NPM
npm install vue-form-wizard
Or alternatively directly include the javascript
Download the css and js files from dist
folder or reference them directly from github (check jsfiddle links)
<link rel="stylesheet" href="vue-form-wizard.min.css">
<script src="vue-form-wizard.js"></script>
Component registration
import VueFormWizard from 'vue-form-wizard'
import 'vue-form-wizard/dist/vue-form-wizard.min.css'
Vue.use(VueFormWizard)
import {FormWizard, TabContent} from 'vue-form-wizard'
import 'vue-formwizard/dist/vue-form-wizard.min.css'
components: {
FormWizard,
TabContent
}
Template usage
<form-wizard>
<tab-content title="Personal details">
My first tab content
</tab-content>
<tab-content title="Additional Info">
My second tab content
</tab-content>
<tab-content title="Last step">
Yuhuuu! This seems pretty damn simple
</tab-content>
</form-wizard>
Props
Form Wizard props
props: {
title: {
type: String,
default: 'Awesome Wizard'
},
subtitle: {
type: String,
default: 'Split a complicated flow in multiple steps'
},
nextButtonText: {
type: String,
default: 'Next'
},
backButtonText: {
type: String,
default: 'Back'
},
finishButtonText: {
type: String,
default: 'Finish'
},
validateOnBack: Boolean,
color: {
type: String,
default: '#e74c3c'
},
errorColor: {
type: String,
default: '#8b0000'
},
shape: {
type: String,
default: 'circle'
},
transition: {
type: String,
default: ''
},
startIndex: {
type: Number,
default: 0
}
}
Tab content props
props: {
title: {
type: String,
default: ''
},
icon: {
type: String,
default: ''
},
beforeChange: {
type: Function
}
}
Events
Vue-form-wizard emits certain events when certain actions happen inside the component. The events can be noticed in some of the demos and especially in the async validation demo
- on-complete Called when the finish button is clicked and the
before-change
for the last step (if present) was executed. No params are sent together with this event. this.$emit('on-complete')
- on-loading Called whenever an async
before-change
is executed. This event is emitted before executing before-change
and after finishing execution of before-change
method. on-loading
is emitted together with a Boolean value. this.$emit('on-loading', value)
- on-validate Called whenever the execution of a
before-change
method is completed. The event sends along a Boolean which represents the validation result as well as an int with te tab index. this.$emit('on-validate', validationResult, this.activeTabIndex)
- on-error Called when
before-change
is a promised and is rejected with a message. The message is passed along this.$emit('on-error', error)
See async validation fiddle
Slots
- Default - Used for tab-contents
- title - Upper title section including sub-title
- prev - Previous button content (no need to worry about handling the button functionality)
- next - Next button content
- finish - Finish button content
Contribution
- Fork the repo
- run
npm install
npm run dev
for launching the dev example- After making your changes make sure to pull the changes from the source repo to avoid conflicts
npm run build
to generate the new js and css bundles- Commit your changes + the js and css bundles so it's easy to test them right away in fiddles, codepen etc
- Open a Pull Request. For more information refer to github forking workflow