Use the vf-form__fieldset
component to display a relationship between multiple form inputs. You can also need use a vf-form__fieldset
inside of another vf-form__fieldset
, this would be good to group multiple vf-form__checkbox
inputs and allow for a vf-form__legend
to give the inputs a heading or question. To make it more obvious what we are asking the site visitor to fill out and why, it is recommened to use a vf-form__legend
within each vf_form__fieldset
.
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",
"fieldset_legend" : [object Object],
}
%}
{% include "../path_to/vf-form__fieldset/vf-form__fieldset.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__fieldset', {
"component-type" : "form",
"fieldset_legend" : [object Object],}
%}
<fieldset class="vf-form__fieldset | vf-stack vf-stack--400">
<legend class="vf-form__legend">A Fieldset Legend</legend>
</fieldset>
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",
"fieldset__error" : [object Object],
"fieldset_legend" : [object Object],
}
%}
{% include "../path_to/vf-form__fieldset/vf-form__fieldset.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__fieldset', {
"component-type" : "form",
"fieldset__error" : [object Object],
"fieldset_legend" : [object Object],}
%}
<fieldset class="vf-form__fieldset | vf-stack vf-stack--400">
<legend class="vf-form__legend">Another Fieldset Legend</legend>
<p class="vf-form__helper vf-form__helper--error">Something has gone terribly wrong.</p>
</fieldset>
This repository is distributed with [npm][https://www.npmjs.com/]. After [installing npm][https://www.npmjs.com/get-npm] and yarn, you can install vf-form__fieldset
with this command.
$ yarn add --dev @visual-framework/vf-form__fieldset
fieldset
outside of vf-form
folder.vf-form__label
when inside a fieldset.v2.0.0
of the vf-design-tokens
package or newer
File system location: components/vf-form__fieldset
Find an issue on this page? Propose a change or discuss it.