The vf-form__helper
can be used to add more descriptive, explanatory text to help guide the site visitor.
If you need to include more descriptive explanations of what the input requires make use of the component <span class="vf-form__helper"></span>
where you can add more text.
If your form has any type of validation (either on the client or server) you can make use of vf-form__helper--error
to help with inputs that do not have the correct content.
Form helper text
Depending on your environment you'll want to use render
or include
. As a rule of thumb: server-side use include
, precompiled browser use render
. If you're using vf-eleventy you should use include
.
include
You'll need to pass a context object from your code or Yaml file (example), as well as the path to the Nunjucks template. Nunjucks' include
is an abstraction of render
and provides some additional portability.
{% set context fromYourYamlFile %}
- or -
{% set context = {
"component-type" : "form",
"helper_text" : "Form helper text",
}
%}
{% include "../path_to/vf-form__helper/vf-form__helper.njk" %}
render
This approach is best for bare-bones Nunjucks environments, such as precompiled templates with the Nunjucks slim runtime where include
is not be available.
{% render '@vf-form__helper', {
"component-type" : "form",
"helper_text" : "Form helper text",}
%}
<p class="vf-form__helper">Form helper text</p>
You have done something wrong.
Depending on your environment you'll want to use render
or include
. As a rule of thumb: server-side use include
, precompiled browser use render
. If you're using vf-eleventy you should use include
.
include
You'll need to pass a context object from your code or Yaml file (example), as well as the path to the Nunjucks template. Nunjucks' include
is an abstraction of render
and provides some additional portability.
{% set context fromYourYamlFile %}
- or -
{% set context = {
"component-type" : "form",
"helper_text" : "You have done something wrong.",
"error" : true,
}
%}
{% include "../path_to/vf-form__helper/vf-form__helper.njk" %}
render
This approach is best for bare-bones Nunjucks environments, such as precompiled templates with the Nunjucks slim runtime where include
is not be available.
{% render '@vf-form__helper', {
"component-type" : "form",
"helper_text" : "You have done something wrong.",
"error" : true,}
%}
<p class="vf-form__helper vf-form__helper--error">You have done something wrong.</p>
This component is distributed with npm. After installing npm, you can install the vf-form__helper
with this command.
$ yarn add --dev @visual-framework/vf-form__helper
The source files included are written in Sass(scss
). You can point your Sass include-path
at your node_modules
directory and import it like this.
@import "@visual-framework/vf-form__helper/index.scss";
Make sure you import Sass requirements along with the modules. You can use a project boilerplate or the vf-sass-starter
set-
style functions to cleaner version
File system location: components/vf-form__helper
Find an issue on this page? Propose a change or discuss it.