beta This component version is ready to be used but is still in active development.

Helper form

The vf-form__helper can be used to add more descriptive, explanatory text to help guide the site visitor.

github location npm version

Usage

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.

Variants

Form helper text

Nunjucks syntax

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.

Using 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" %}
                

Using 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",}
%}
                
HTML
<p class="vf-form__helper">Form helper text</p>
              

You have done something wrong.

Nunjucks syntax

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.

Using 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" %}
                

Using 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,}
%}
                
HTML
<p class="vf-form__helper vf-form__helper--error">You have done something wrong.</p>
              

Examples

Installation info

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

Sass/CSS

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

Changelog

Changelog

3.0.0-alpha.0

  • reworks the helper to make more use of nunjucks
  • restyles the helper to match latest design direction
  • adds better documentation

2.0.1

  • changes any set- style functions to cleaner version

2.0.0

  • Makes the font size larger.
  • Changes the red to use the red from the EMBL palette.
  • https://github.com/visual-framework/vf-core/pull/1228/

1.0.0

  • adds error helper text when form input is invalid

1.0.0-alpha.8

  • Version bump only for package @visual-framework/vf-form__helper

1.0.0-alpha.7

  • Version bump only for package @visual-framework/vf-form__helper

Assets



File system location: components/vf-form__helper

Find an issue on this page? Propose a change or discuss it.