Vue Flow Form

Create conversational conditional-logic forms with Vue.js.

README

Vue Flow Form


Create conversational conditional-logic forms with Vue.js.

License Version cdnjs

v-form screenshots


Starting with v2.0.0, Vue Flow Form has migrated from Vue 2 to **Vue 3**. If you're looking for README for Vue Flow Form v1.1.7, which works with Vue 2, check it out here.

Live Demos



Project Documentation



Example Project


Requirements:

Node.js version 10.0.0 or above (12.0.0+ recommended)
npm version 5+ (or yarn version 1.16+)

After checking the prerequisites, follow these simple steps to install and use Vue Form:

  1. ``` sh
  2. # clone the repo
  3. $ git clone https://github.com/ditdot-dev/vue-flow-form.git myproject

  4. # go into app's directory and install dependencies:
  5. $ cd myproject
  6. ```

If you use npm:

  1. ``` sh
  2. $ npm install

  3. # serve with hot reload at localhost:8080 by default.
  4. $ npm run serve

  5. # build for production
  6. $ npm run build
  7. ```

If you use yarn:

  1. ``` sh
  2. $ yarn install

  3. # serve with hot reload at localhost:8080 by default.
  4. $ yarn serve

  5. # build for production
  6. $ yarn build
  7. ```

Made with Vue.js

Usage as npm Package


If you don't already have an existing Vue project, the easiest way to create one is to use Vue CLI:

(For issues with Vue 3.13 and CLI 4 check here)

  1. ``` sh
  2. $ npm install -g @vue/cli
  3. # OR
  4. $ yarn global add @vue/cli
  5. ```

And then create a project (refer to Vue CLI documentation and issue tracker for potential problems on Windows):

  1. ``` sh
  2. $ vue create my-project
  3. $ cd my-project
  4. ```

To add Vue Flow Form as a dependency to your Vue project, use the following:

  1. ``` sh
  2. $ npm install @ditdot-dev/vue-flow-form --save
  3. ```

And then in your App.vue file:

  1. ``` html
  2. <template>
  3.   <flow-form v-bind:questions="questions" v-bind:language="language" />
  4. </template>
  5. <script>
  6.   // Import necessary components and classes
  7.   import { FlowForm, QuestionModel, QuestionType, ChoiceOption, LanguageModel } from '@ditdot-dev/vue-flow-form'
  8.   export default {
  9.     name: 'example',
  10.     components: {
  11.       FlowForm
  12.     },
  13.     data() {
  14.       return {
  15.         language: new LanguageModel({
  16.           // Your language definitions here (optional).
  17.           // You can leave out this prop if you want to use the default definitions.
  18.         }),
  19.         questions: [
  20.           // QuestionModel array
  21.           new QuestionModel({
  22.             title: 'Question',
  23.             type: QuestionType.MultipleChoice,
  24.             options: [
  25.               new ChoiceOption({
  26.                 label: 'Answer'
  27.               })
  28.             ]
  29.           })
  30.         ]
  31.       }
  32.     }
  33.   }
  34. </script>
  35. <style>
  36.   /* Import Vue Flow Form base CSS */
  37.   @import '~@ditdot-dev/vue-flow-form/dist/vue-flow-form.css';
  38.   /* Import one of the Vue Flow Form CSS themes (optional) */
  39.   @import '~@ditdot-dev/vue-flow-form/dist/vue-flow-form.theme-minimal.css';
  40.   /* @import '~@ditdot-dev/vue-flow-form/dist/vue-flow-form.theme-green.css'; */
  41.   /* @import '~@ditdot-dev/vue-flow-form/dist/vue-flow-form.theme-purple.css'; */
  42. </style>
  43. ```

Usage with Plain JavaScript via CDN


HTML:

  1. ``` html
  2. <!DOCTYPE html>
  3. <html>
  4.   <head>
  5.     <meta charset="UTF-8">
  6.     
  7.     <script src="https://unpkg.com/vue@next"></script>
  8.     
  9.     <script src="https://unpkg.com/@ditdot-dev/vue-flow-form@2.3.1"></script>
  10.     
  11.     <link rel="stylesheet" href="https://unpkg.com/@ditdot-dev/vue-flow-form@2.3.1/dist/vue-flow-form.min.css">
  12.     
  13.     <link rel="stylesheet" href="https://unpkg.com/@ditdot-dev/vue-flow-form@2.3.1/dist/vue-flow-form.theme-minimal.min.css">
  14.     
  15.     <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;900&display=swap">
  16.   </head>
  17.   <body>
  18.     <div id="app"></div>
  19.     <script src="app.js"></script>
  20.   </body>
  21. </html>
  22. ```

JavaScript (content of app.js):

  1. ``` js
  2. var app = Vue.createApp({
  3.   el: '#app',
  4.   template: '<flow-form v-bind:questions="questions" v-bind:language="language" />',
  5.   data: function() {
  6.     return {
  7.       language: new VueFlowForm.LanguageModel({
  8.         // Your language definitions here (optional).
  9.         // You can leave out this prop if you want to use the default definitions.
  10.       }),
  11.       questions: [
  12.         new VueFlowForm.QuestionModel({
  13.           title: 'Question',
  14.           type: VueFlowForm.QuestionType.MultipleChoice,
  15.           options: [
  16.             new VueFlowForm.ChoiceOption({
  17.               label: 'Answer'
  18.             })
  19.           ]
  20.         })
  21.       ]
  22.     }
  23.   }
  24. }).component('FlowForm', VueFlowForm.FlowForm);

  25. const vm = app.mount('#app');
  26. ```

Changelog


Changes for each release are documented in the release notes.

Stay in Touch



License


MIT license.

Copyright (c) 2020 - present, DITDOT Ltd.