Vuetensils 0.6: Simpler Forms, Better Accessibility, & Useful Filters!
Tags: development, javascript, vue, a11y
Published: 2020-05-01 22:57:24

---
title: Vuetensils 0.6: Simpler Forms, Better Accessibility, & Useful Filters!
published: true
tags: Development,JavaScript,Vue.js,a11y
canonical_url: https://stegosource.com/vuetensils-0-6-simpler-forms-better-accessibility-useful-filters/
cover_image: https://stegosource.com/wp-content/uploads/vue-blog-cover.svg
---

Some really cool news is coming to [Vuetensils](https://vuetensils.stegosource.com/) users. The latest version has some really cool features: new VForm component and other improvements to form authoring, really nice accessibility updates, and brand new filters to make life easier, as well as some important bug fixes.

Let’s take a look:

## Simplifying Forms with Automatic Validation

The new [VForm](https://vuetensils.stegosource.com/components/Form.html) component is one of my favorite new features. Combined with the latest updates to [VInput](https://vuetensils.stegosource.com/components/Input.html#installation) and you have a really excellent form authoring experience.

VInput had some basic form validation built in. It’s always been built on top of the [HTML5 validation standards](https://developer.mozilla.org/en-US/docs/Learn/Forms/Form_validation), so using it is great from an accessibility and semantic perspective, and it also make it super easy to get started. There is nothing more to learn than the native API.

```vue
<VInput label="Name" name="name" required minlength="2">
  <template #description="input">
    <template v-if="input.error">
      <small v-if="input.invalid.required">This field is required.</small>
      <small v-if="input.invalid.minlength">Must be more than 2 characters</small>
    </template>
  </template>
</VInput>
```

![](https://cdn.statically.io/img/stegosource.com/f=auto,w=1200,h=1200,q=70/wp-content/uploads/VInput-screenshot.png)

But the story doesn’t stop there. It’s one thing to validate a single input, but in many cases, you want to track the state of an entire form. That’s where VForm comes in.

VForm provides the same automated form validation for every input it wraps, based on the [HTML5 validation attributes](https://developer.mozilla.org/en-US/docs/Learn/Forms/Form_validation). This is helpful for preventing form submission if ANY of the inputs are invalid. And note that this feature is available for any HTML input, not just the ones provided by VInput. So if you want to use the native input, or inputs from a different library, you can do so.

```vue
<VForm @submit.prevent>
  <template #default="form">
    <label>
      Name:
      <input name="name" required />
    </label>

    <button type="submit" :disabled="!form.valid">Submit</button>

    <pre>{{ form }}</pre>
  </template>
</VForm>
```

![](https://cdn.statically.io/img/stegosource.com/f=auto,w=1200,h=1200,q=70/wp-content/uploads/VForm-screenshot.png)

Both of these components also track keep track on whether any of the input have received user focus. Once any input’s `blur` event is fired, the input will update it’s `dirty` state. This is helpful if you only want to show error messages after a user has interacted with the form. And there is a convenient `error` state which is `true` if the `valid` state is false and the `dirty` state is true.

## Accessibility Improvements

From the beginning, Vuetensils has simplified the process of creating accessible [Dialog](https://vuetensils.stegosource.com/components/dialog.html) and [Drawer](https://vuetensils.stegosource.com/components/Drawer.html#installation) components. These two include the right ARIA roles for the components themselves, but until now, there’s been something lacking. The `<button>` to toggle these elements always depended on the developer to implement. This usually meant missing other critical ARIA roles (`aria-haspopup` and `aria-expanded`).

Today, the recommended approach to adding these components is to take advantage of a new `toggle` slot which provides an easy way to create more accessible `<button>`. The resulting output looks like this:

```vue
<button type="button" role="button" aria-haspopup="true" aria-expanded="false">
  Open dialog
</button>
```

Another minor accessibility improvement is to change [VInput](https://vuetensils.stegosource.com/components/Input.html#installation)‘s implicit label to an explicit label. This was done without introducing a breaking change by leaving the wrapping `<label>` where it was, but simply adding the `for` attribute.

## Hello Filters

Prior to v0.6, Vuetensils did not provide any [filters](https://vuejs.org/v2/guide/filters.html). For those unfamiliar, filters provide a very easy way to manipulate content inside you templates. They’re great for common needs such as:

- [capitalize](https://vuetensils.stegosource.com/filters/capitalize.html): Capitalizes the first letter of a string.
- [currency](https://vuetensils.stegosource.com/filters/currency.html): Formats a string number to a currency number using the browser’s [Intl object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl).
- [number](https://vuetensils.stegosource.com/filters/number.html): Formats a string number to a user friendly number using the browser’s [Intl object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl).
- [placeholder](https://vuetensils.stegosource.com/filters/placeholder.html): Provides fallback content in the case of empty strings.
- [plural](https://vuetensils.stegosource.com/filters/plural.html): Provides options for pluralizing a string based on input count.
- [truncate](https://vuetensils.stegosource.com/filters/truncate.html): Truncates a string based on provided length.

## Bug Fixes

- Some elements had automated ID attributes for various reasons. The previous version had a small performance bug which is now fixed. 
- There was a small logical bug in the [VAsync](https://vuetensils.stegosource.com/components/Async.html) component which is now fixed.
- The [VInput](https://vuetensils.stegosource.com/components/Input.html) used to have some validation logic built in, but it’s been improved.

## Stay Updated

If you’re a Vuetensils user, please update to the latest version and let me know what you think. And if you’re new to the library or interested in getting started, then I’d love to hear how it can be improved. [GitHub](https://github.com/stegosource/vuetensils) is the best place to do so.

Also, I highly recommend you [sign up for my newsletter](https://3bb5fb5a.sibforms.com/serve/MUIEAAOwgrWtf43Lfv80ES_hibAhazPDEy4w9IxRIda1b8g1GNnmHYkDfvIKG-Ox35EtWkJfMyCMBTQ3nG2msGhc3WnHa7XKfkgBzYdL3ASbIEckbn47QtJDIvpOskWQuRIXYI-7dVuM5F25yKdcJch7VN8aAbrpEn8_PMXWpqENTJ6r9bOZgHj6vnAQwHDsdwXDOZIonAP3x3vx) of follow me on [Twitter](https://twitter.com/stegosource) to get notifications about the latest releases. The project is still pre-version 1, so there may be some breaking changes.