mirror of
https://github.com/tenrok/vue-form-wizard.git
synced 2026-06-06 10:52:23 +03:00
152 lines
3.8 KiB
Markdown
152 lines
3.8 KiB
Markdown
# 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.
|
|
|
|
Vue-form-wizard is inspired by [creative-tim wizards](https://www.creative-tim.com/bootstrap-themes/wizard) but simplified and
|
|
more customizable
|
|
|
|
# Demos
|
|
Basic [demo](https://jsfiddle.net/bt5dhqtf/97/)
|
|
|
|
Other demos:
|
|
* [Squared steps](https://jsfiddle.net/bt5dhqtf/98/)
|
|
* [Tabbed steps](https://jsfiddle.net/bt5dhqtf/99/)
|
|
* [Step index](https://jsfiddle.net/bt5dhqtf/100/) Start at any step. Note: start-index is zero-based and the count starts at 0
|
|
* [Custom button and title text](https://jsfiddle.net/bt5dhqtf/101/)
|
|
* [Custom title slot](https://jsfiddle.net/bt5dhqtf/102/)
|
|
* [Customized buttons with slots](https://jsfiddle.net/bt5dhqtf/103/) Replace stuff you don't like
|
|
* [Call a function before tab switch](https://jsfiddle.net/bt5dhqtf/105/)
|
|
* [Complete form example](https://jsfiddle.net/bt5dhqtf/150/) integrated with [vue-form-generator](https://github.com/icebob/vue-form-generator)
|
|
|
|
# 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)
|
|
```html
|
|
<link rel="stylesheet" href="vue-form-wizard.min.css">
|
|
<script src="vue-form-wizard.js"></script>
|
|
```
|
|
## Component registration
|
|
```js
|
|
//global registration
|
|
import 'vue-form-wizard'
|
|
import 'vue-form-wizard/dist/vue-form-wizard.min.css'
|
|
Vue.use(VueTabWizard)
|
|
|
|
//local registration
|
|
import {FormWizard, TabContent} from 'vue-form-wizard'
|
|
import 'vue-formwizard/dist/vue-form-wizard.min.css'
|
|
//component code
|
|
components: {
|
|
FormWizard,
|
|
TabContent
|
|
}
|
|
```
|
|
## Template usage
|
|
|
|
```html
|
|
<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
|
|
```js
|
|
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'
|
|
},
|
|
/***
|
|
* Applies to text, border and circle
|
|
*/
|
|
color: {
|
|
type: String,
|
|
default: '#e74c3c' //circle, border and text color
|
|
},
|
|
/**
|
|
* Can take one of the following values: 'circle|square|tab`
|
|
*/
|
|
shape: {
|
|
type: String,
|
|
default: 'circle'
|
|
},
|
|
/**
|
|
* name of the transition when transition between steps
|
|
*/
|
|
transition: {
|
|
type: String,
|
|
default: '' //name of the transition when transition between steps
|
|
},
|
|
/***
|
|
* Index of the initial tab to display
|
|
*/
|
|
startIndex: {
|
|
type: Number,
|
|
default: 0
|
|
}
|
|
}
|
|
```
|
|
|
|
## Tab content props
|
|
```js
|
|
props: {
|
|
title: {
|
|
type: String,
|
|
default: ''
|
|
},
|
|
/***
|
|
* Icon name for the upper circle corresponding to the tab
|
|
* Supports themify icons only for now.
|
|
*/
|
|
icon: {
|
|
type: String,
|
|
default: ''
|
|
},
|
|
/***
|
|
* Function to execute before tab switch. Return value must be boolean
|
|
* If the return result is false, tab switch is restricted
|
|
*/
|
|
beforeChange: {
|
|
type: Function
|
|
}
|
|
}
|
|
```
|
|
|
|
# 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
|