Lists element

Classic html list <li> and <dl> types: order, unordered, bulleted, inline and definition.

github location npm version

Variants

  • a list item
  • another list item
  • and another list item
  • yet another list item
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",
"list" : a list item,another list item,and another list item,yet another list item,
 }
%}
{% include "../path_to/vf-list/vf-list.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-list', {
  "component-type" : "element",
  "list" : a list item,another list item,and another list item,yet another list item,}
%}
                
HTML
 <ul class="vf-list">
   <li class="vf-list__item "> a list item </li>
   <li class="vf-list__item "> another list item </li>
   <li class="vf-list__item "> and another list item </li>
   <li class="vf-list__item "> yet another list item </li>
 </ul>
              
  • a list item
  • another list item
  • and another list item
  • yet another list item
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",
"list_type" : "default",
"override_class" : "vf-list--tight",
"list" : a list item,another list item,and another list item,yet another list item,
 }
%}
{% include "../path_to/vf-list/vf-list.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-list', {
  "component-type" : "element",
  "list_type" : "default",
  "override_class" : "vf-list--tight",
  "list" : a list item,another list item,and another list item,yet another list item,}
%}
                
HTML
 <ul class="vf-list vf-list--default | vf-list--tight">
   <li class="vf-list__item "> a list item </li>
   <li class="vf-list__item "> another list item </li>
   <li class="vf-list__item "> and another list item </li>
   <li class="vf-list__item "> yet another list item </li>
 </ul>
              
  • a list item
  • another list item
  • and another list item
  • yet another list item
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",
"list_type" : "l",
"list" : a list item,another list item,and another list item,yet another list item,
 }
%}
{% include "../path_to/vf-list/vf-list.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-list', {
  "component-type" : "element",
  "list_type" : "l",
  "list" : a list item,another list item,and another list item,yet another list item,}
%}
                
HTML
 <ul class="vf-list vf-list--l">
   <li class="vf-list__item "> a list item </li>
   <li class="vf-list__item "> another list item </li>
   <li class="vf-list__item "> and another list item </li>
   <li class="vf-list__item "> yet another list item </li>
 </ul>
              
  • a list item
  • another list item
  • and another list item
  • yet another list item
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",
"list_type" : "inline",
"list" : a list item,another list item,and another list item,yet another list item,
 }
%}
{% include "../path_to/vf-list/vf-list.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-list', {
  "component-type" : "element",
  "list_type" : "inline",
  "list" : a list item,another list item,and another list item,yet another list item,}
%}
                
HTML
 <ul class="vf-list vf-list--inline">
   <li class="vf-list__item "> a list item </li>
   <li class="vf-list__item "> another list item </li>
   <li class="vf-list__item "> and another list item </li>
   <li class="vf-list__item "> yet another list item </li>
 </ul>
              
  • a list item
  • another list item
  • and another list item
  • yet another list item
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",
"list_type" : "ordered",
"list" : a list item,another list item,and another list item,yet another list item,
 }
%}
{% include "../path_to/vf-list/vf-list.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-list', {
  "component-type" : "element",
  "list_type" : "ordered",
  "list" : a list item,another list item,and another list item,yet another list item,}
%}
                
HTML
 <ul class="vf-list vf-list--ordered">
   <li class="vf-list__item "> a list item </li>
   <li class="vf-list__item "> another list item </li>
   <li class="vf-list__item "> and another list item </li>
   <li class="vf-list__item "> yet another list item </li>
 </ul>
              
  • a list item
  • another list item
  • and another list item
  • yet another list item
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",
"list_type" : "unordered",
"list" : a list item,another list item,and another list item,yet another list item,
 }
%}
{% include "../path_to/vf-list/vf-list.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-list', {
  "component-type" : "element",
  "list_type" : "unordered",
  "list" : a list item,another list item,and another list item,yet another list item,}
%}
                
HTML
 <ul class="vf-list vf-list--unordered">
   <li class="vf-list__item "> a list item </li>
   <li class="vf-list__item "> another list item </li>
   <li class="vf-list__item "> and another list item </li>
   <li class="vf-list__item "> yet another list item </li>
 </ul>
              
Beast of Bodmin
A large feline inhabiting Bodmin Moor.
Morgawr
A sea serpent.
Owlman
A giant owl-like creature.
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",
"list_type" : "definition",
"list" : [object Object],[object Object],[object Object],
 }
%}
{% include "../path_to/vf-list/vf-list.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-list', {
  "component-type" : "element",
  "list_type" : "definition",
  "list" : [object Object],[object Object],[object Object],}
%}
                
HTML
 <dl class="vf-list vf-list--definition">
   <dt class="vf-list__item vf-list--definition__term"> Beast of Bodmin </dt>
   <dd class="vf-list__item vf-list--definition__details"> A large feline inhabiting Bodmin Moor. </dd>
   <dt class="vf-list__item vf-list--definition__term"> Morgawr </dt>
   <dd class="vf-list__item vf-list--definition__details"> A sea serpent. </dd>
   <dt class="vf-list__item vf-list--definition__term"> Owlman </dt>
   <dd class="vf-list__item vf-list--definition__details"> A giant owl-like creature. </dd>
 </dl>
              

Examples

Installation info

This component is distributed with npm. After installing npm, you can install the vf-list with this command.

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

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-list/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

1.1.0

  • Add support to inherit context templates from Nunjucks.
  • Expose example of large variant (vf-list-l).
  • Add tight variant (vf-list--tight).
  • Add support for definition lists.
  • https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dl
  • https://github.com/visual-framework/vf-core/issues/914

1.0.0

  • Initial stable release

Assets



File system location: components/vf-list

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