Tachyons plugin

Integrate with the Tachyons library
The plugin supports Tachyons v4.10.0.

Usage

The following piece of code is the starting point to validate the form made in Tachyons:
<html>
<head>
<link rel="stylesheet" href="https://unpkg.com/tachyons@4.10.0/css/tachyons.min.css" />
<link rel="stylesheet" href="/vendors/@form-validation/umd/styles/index.min.css" />
</head>
<body>
<form id="demoForm" method="POST">...</form>
<script src="https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.35.3/es6-shim.min.js"></script>
<script src="/vendors/@form-validation/umd/bundle/popular.min.js"></script>
<script src="/vendors/@form-validation/umd/plugin-tachyons/index.min.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function(e) {
FormValidation.formValidation(
document.getElementById('demoForm'),
{
fields: {
...
},
plugins: {
tachyons: new FormValidation.plugins.Tachyons(),
...
},
}
);
});
</script>
</body>
</html>
The sample code above assumes that the FormValidation files are placed inside the vendors directory. You might need to change the path depending on where you place them on the server.
The next sections list out some examples of various forms made with Tachyons.

Using the npm packages

If you are using a bundler such as Webpack, Rollup, Parcel or Vite, etc., to bundle your application, then it's recommended to use the FormValidation NPM packages.
  • Install the packages:
$ npm install @form-validation/bundle
$ npm install @form-validation/plugin-tachyons
  • Import and use the Tachyons plugin:
import { formValidation } from '@form-validation/bundle/popular';
import { Tachyons } from '@form-validation/plugin-tachyons';
formValidation(
document.getElementById('demoForm'),
{
fields: {
...
},
plugins: {
tachyons: new Tachyons({
...
}),
...
},
}
);

Horizontal form

Horizontal form

Stacked form

You need to add the fv-stacked-form class to the form element such as:
<form class="fv-stacked-form">
<!-- The fields go here -->
...
</form>
In order to add the correct class for error message and the field element when it is a valid or invalid, we need to specify the CSS selector of the field container.
By default, the Tachyons plugin will look for the .fl element. But in the stacked form below, every field will be placed inside our own .row container.
We need to use the rowSelector option to help the plugin determine the field containers as following:
tachyons: new FormValidation.plugins.Tachyons({
rowSelector: function(field, ele) {
// field is the field name
// ele is the field element
return '.row';
}
// Or you can just simply pass it as a string:
// rowSelector: '.row',
}),
Stacked form

Multiple fields on the same row

Multiple fields on the same row

Changelog

v2.4.0
v2.0.0
  • Add the npm package
v1.2.0
  • Support Tachyons v4.10.0
v1.0.0
  • First release