Scalable Forms in Vue

Rate this content
Bookmark

Discover the art of creating scalable forms in Vue using FormKit — ideal for teams with complex form-heavy projects. This talk delves into strategies for decomposing forms into smaller, composable components, simplifying development, and enhancing team efficiency.

This talk has been presented at Vue.js Live 2024, check out the latest edition of this JavaScript Conference.

FAQ

Scalability in client-side code refers to the ability of the code to be reused effectively across teams of varying sizes, from small teams to large organizations. It involves promoting best practices, ensuring code is approachable for all skill levels, and being conducive to collaborative development.

Justin Schrader is a developer known for his involvement in open-source projects like FormKit, Arrow.js, AutoAnimate, Tempo, and Drag'n'Drop. You can follow him on social media at JPSchrader.

FormKit is a comprehensive solution for creating scalable and reusable forms in Vue.js. It provides a wide range of form components and a unique tree architecture to manage form data and validation efficiently.

Code reuse is important for scalable front-ends because it allows teams to efficiently and effectively use existing code across different parts of a project. This reduces redundancy, promotes consistency, and saves development time.

The FormData API has several limitations, including the inability to structure data, limited native validation options, lack of interactivity without JavaScript, and incompatibility with many modern server setups.

FormKit improves form handling by providing a comprehensive set of form components with built-in accessibility and validation features. It uses a tree architecture to manage form data efficiently, eliminating the need for prop drilling and manual data binding.

Key features of FormKit include a wide range of form components, a tree architecture for managing form data, built-in accessibility, validation handling, support for deeply nested structures, and the ability to serialize forms as JSON.

Tempo is a date manipulation library similar to Day.js or Date.fns, while Drag'n'Drop is an easy-to-use drag-and-drop library. Both are open-source projects created by Justin Schrader.

The main advantage of using FormKit over other form libraries like vValidate is its comprehensive approach to handling forms. FormKit not only provides validation but also addresses deeply nested structures, reusable components without prop drilling, and built-in accessibility.

FormKit supports accessibility by shipping form components with accessible HTML out of the box, including ARIA attributes and other best practices to ensure that forms are usable by people with disabilities.

Justin Schroeder
Justin Schroeder
23 min
25 Apr, 2024

Comments

Sign in or register to post your comment.

Video Summary and Transcription

Scalable forms in Vue, approachable for all skill levels, with code reusability and best practices. Front-ends divided into websites and applications, with forms being highly interactive and logic-heavy. Form Components in Vue provide accessible markup, delightful validation, and customizable props. Using vModeling encourages code reuse and collaboration. FormKit offers a comprehensive solution to form problems, including structured data, unique form keys, and robust validation UX. It simplifies form creation, supports CMS-like experiences, and provides advanced features and TypeScript support.
Available in Español: Formularios escalables en Vue

1. Introduction to Scalable Forms in Vue

Short description:

Scalable Forms in Vue. Scalability on the client side. Code reusability and size of organization as metrics. Vue 2 scalability issues. Extract and reuse components. Rubric for measuring scalability: code reuse and best practices. Approachable for all skill levels.

Hi, I'm UJSlive, and thank you so much for coming to my talk, Scalable Forms in Vue. Now scalability brings up a question right away. What is scalability? And generally when we think about scalability, we think about sort of back-end tools, right? From the server side, it might look like load balancers and horizontal versus vertical scaling. Perhaps the requests per second in a traditional web application might be the way that you think about scalability, horizontal versus vertical scaling, things like that.

But I want to talk about a different kind of scalability today. And that's on the client side. What does scalability mean in your client side code? In your Vue code, what does scalability mean? Well, it means things like code reusability and the size of your organization plays a role, how big of an organization can use your front-end code and developers per project might be a good key metric to sort of be able to measure your scalability. Does this front-end code work great for a team of five people? How about a team of 100 people? And this is one of the key drivers behind Vue 3. On a podcast recently, Evan Yu was quoted as saying Vue 2 has scalability issues. We have a huge Vue product and we have these huge components that nobody wants to touch anymore. We don't know how to extract and reuse things. Interesting.

So, let's use what Evan is saying. But first, real quick, who am I? My name is Justin Schrader. You can follow me on the socials at JPSchrader. And if you do happen to know me, it's probably from one of these open source tools that I have either created or am involved with, FormKit, Arrow.js, AutoAnimate, Tempo, and Drag'n'Drop. The last two, Tempo and Drag'n'Drop, are brand spanking new. If you haven't checked them out, you should totally go check them out. Tempo is sort of a Day.js or Date.fns alternative and Drag'n'Drop is a really easy to use little Drag'n'Drop library. But that's enough about me. Let's get back to what Evan was saying there. Scalable front-ends. Basically, I think if we distill down what Evan is saying about a scalable front-end and what we sort of know from our own intuition, we can come up with maybe like a rubric to measure scalability. First of all, I think it should enable code reuse, good code reuse. We all kind of know that this is something that is true. When you write code, you should be able to reuse it effectively and efficiently across your team, and that is part of what makes scalable code. Also, it should encourage best practices. Scalable front-ends should encourage best practices. Your code isn't very scalable if, in order to add accessibility, it requires a full rewrite. Also, it should be approachable for all skill levels.

2. Scalability and Skill Diversity

Short description:

Scalability with diverse skill levels. Approachable for all developers. Tailwind's scalability due to standardized set of class names.

This is actually a really big deal when you think about it, especially with a large team. The bigger your team gets, the more likely it is that it's not just going to be a bunch of super senior front-end engineers. No, it's more likely that you have a big diversity of skill levels. Some people who are brand new and some people who maybe have been doing it for a long time. A good, scalable front-end should be able to work well for all of those people. Everybody should find it approachable.

And finally, is it conducive to a team of developers? This is sort of maybe a summation of what we're saying here. How many people can you put on front-ends in order to make them and still have them work efficiently? I think this is maybe one of the biggest drivers behind Tailwind being so successful, is the fact that anybody can step into Tailwind and you don't have to go relearn all of the class names that exist in an existing project. There could be thousands of them. You have a standardized set. Anybody can get in and make modifications. They know the modifications are limited to something local, so on and so forth. This talk's not about Tailwind, but it is to say, I think that's one of the reasons why you can make the claim that Tailwind is scalable.

QnA