Forms are an important ingredient for almost every web app. But they can get complex pretty fast, and you’ll have to work through the repetitive processes of handling, storing and validating your data for every custom form.
At some point, you'll be on the lookout for an efficient way to build forms without having to start from scratch. A good form library is built with best practices in mind and takes a lot of work off your hands.
In this article we’re going to take a look at some popular form libraries for Vue to give you a starting point! I'll keep the list updated. If you think I should include one in particular, reach out on Twitter @MadeWithVueJS!
There's a variety of form libraries available that all have a different focus. Before you throw yourself into your research, take a few minutes to think about what features are most important for your use-case. There are libraries handling validation, form UI libraries or full-blown form frameworks.
What do you need?
Form frameworks are more than a collection of input components. They do all the heavy lifting for you to ensure great developer experience and more efficiency when building forms. A form framework usually takes care about rendering including form generation, validation and data processing / error handling.
The form building framework FormKit is the Vue 3-based successor to the popular open-source form library Vue Formulate for Vue 2. Their creators took everything they learned and built a fully-featured form framework.
FormKit is also open-source and offers 24+ styled and themeable inputs, validation rules, form generation via JSON-compatible dynamic schemas and more features for data flow, error handling & state management.
They also offer a pro version for some additional, more advanced inputs like tag lists, repeatables, ratings.
There is a whole course on building robust Vue.js Forms with FormKit on VueSchool!
Vueform is an open-source form framework that focuses on developer productivity. It can be integrated in your project easily and works with popular UI frameworks like Tailwind or Bootstrap.
It's super flexible with support for complex forms, conditional rendering and form wizards with multiple steps. They also offer an easy to use form builder UI that lets you drag & drop form elements. Every form you create with Vueform can be stored as JSON, including all validation rules, submission endpoints etc.
Vueform also offers some of their Vue 3 form input components individually: Their multi-select, slider and toggle!
If you're already thinking about building your app using a Vue component framework, you can take a look at their built-in form functionalities to see if they fit your needs. All of the popular frameworks offer a range of styled form input components, layouts, validation rules and support for data handling, form submission & error handling out of the box.
Here are some of the most loved Vue component frameworks as a starting point:
In case you want to use your own design system and form UI components, you might prefer a standalone validation library instead.
In general, they are a lot more flexible and customizable than the built-in validation rules in ready-to-use form or UI frameworks. They allow you to define your own validation logic, which is especially useful if things are getting more complex - for example if you need to take external data sources into account.
For large-scale projects it might also be a good idea to separate your UI components from your validation logic, so it's more maintainable and reusable.
There are a range of validation libraries available. (As an alternative you can of course always DIY form validation!)
Vuelidate is a popular validation library offering some built-in validation rules for required fields, email fields, min / max length etc. and helper functions for displaying errors. It also supports custom and asynchronous validation rules.
With Vuelidate, validation rules are defined as functions attached to components.
The course about Vue.js Form Validation on VueSchool is showing how to validate your forms with Vuelidate!
VeeValidate is also one of the more popular validation libraries. It provides a range of ready-to-use validation rules, and supports custom / asynchronous rules as well.
VeeValidate defines validation rules as objects attached to components, letting you add conditions under which your inputs should be validated. Helper functions and directives help you with displaying validation errors.
Vorms is a more lightweight alternative. You might want to take a closer look if your use case is not too complex.
It does provide basic built-in validation rules, support for custom and asynchronous validation rules, as well as helper functions for displaying errors. Vorms also defines validation rules as objects attached to components.
It might not be as feature-rich, but might help you avoid unnecessary overhead while providing a solid feature set for basic form validation.
Vue Tiny Validate is (as the name already says) the most minimalistic alternative.
It defines validation rules as objects attached to components, providing a simple and straightforward API.
Vue Tiny Validate is indeed tiny - it's only 3.4KB minified / 1.4KB gzipped.
There are a lot more interesting libraries that can help you create unique form experiences. Here are some fun projects you might want to take a look at 🤸