Collapse element

Collapse and expand components are useful in a variety of utilitarian situations to show and hide information.

github location npm version



/* vf-collapse template file */
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" : "element",
{% include "../path_to/vf-collapse/vf-collapse.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-collapse', {
  "component-type" : "element",}
<div class="vf-collapse">
  /* vf-collapse template file */


Installation info

This repository is distributed with npm. After installing npm, you can install vf-collapse with this command.

$ yarn add --dev @visual-framework/vf-collapse


The style files included are written in Sass. If you're using a VF-core project, you can import it like this:

@import "@visual-framework/vf-collapse/index.scss";

Make sure you import Sass requirements along with the modules. You can use a project boilerplate or the vf-sass-starter




  • inital version


File system location: components/vf-collapse

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