The vf-cluster is a layout component that can be used when we need to give various content items (of indeterment sizes) an equaly spaced layout on the page that can respond to the browsers viewport width.
The main use case for vf-cluster
is to be mainly used when something the available grid systems are too 'rigid' because of the different widths of the content.
To use the vf-cluster
component we make use of the @extends
directive from Nunjucks to 'wrap' around the content we want this layout component to render.
To use the vf-cluster
component you must be using vX.X.X of vf-eleventy
.
In the .njk
file you are wanting to use the vf-cluster
you must include the following code to 'extend' the file with the vf-cluster
component.
{% raw %}
{% extends layout.cluster %}
{% endraw %}
You will then need to create a 'block' to put the relevant content inside so that it renders within the vf-cluster
layout when rendered.
{% raw %}
{% block cluster_content %}
...
{% endblock %}
{% endraw %}
To make use of .yml
to render the vf-cluster
to the variant you wish to use, you will have to 'set' the context in the .njk
file.
{% raw %}
{% set context = cluster1 %}
{% endraw %}
note: cluster1
is an example, please pick your own semantic, readable context names
With these set you can then add the relevant content as needed.
To use the vf-cluster
component you must be using vX.X.X of vf-wp
.
There are four spacing variants and three alignment variants available for this component as well as an option to define the width of the vf-cluster
s children.
custom property | options | default |
---|---|---|
spacing | small, medium, large | none |
alignment | start, center, end | none |
There are three spacing variants that determina the inline and block spacing between items of content inside of vf-cluster
.
This variant determines where the child components align in the vertical space available. When setting this in your .yml
file it will add the relevant CSS value as the inline CSS custom property -vf-cluster-alignment
.
custom property | options | example |
---|---|---|
--vf-cluster-alignment | could be used for a different vertical alignment value | baseline |
--vf-cluster-margin | can take a CSS size value to overide the defualt | 31px |
--vf-cluster__item--flex | can take a CSS flex value to determine the child widths | 210px 1 0 |
This is some more content that would be in the box.
This is some more content that would be in the box.
This is some more content that would be in the box.
This is some more content that would be in the box.
This is some more content that would be in the box.
This is some more content that would be in the box.
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": "layout",
"cluster_child_flex": "25% 1 0",
"cluster__spacing": 400
}
%}
{% include "../path_to/vf-cluster/vf-cluster.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-cluster', {
"component-type": "layout",
"cluster_child_flex": "25% 1 0",
"cluster__spacing": 400
} %}
<div class="vf-cluster vf-cluster--400" style=" --vf-cluster__item--flex: 25% 1 0;">
<div class="vf-cluster__inner">
<div class="vf-box vf-box-theme--primary vf-box--normal">
<h3 class="vf-box__heading">Did you know?</h3>
<p class="vf-box__text">This is some more content that would be in the box.</p>
</div>
<div class="vf-box vf-box-theme--primary vf-box--normal">
<h3 class="vf-box__heading">Did you know?</h3>
<p class="vf-box__text">This is some more content that would be in the box.</p>
</div>
<div class="vf-box vf-box-theme--primary vf-box--normal">
<h3 class="vf-box__heading">Did you know?</h3>
<p class="vf-box__text">This is some more content that would be in the box.</p>
</div>
<div class="vf-box vf-box-theme--secondary vf-box--normal">
<h3 class="vf-box__heading">Did you know?</h3>
<p class="vf-box__text">This is some more content that would be in the box.</p>
</div>
<div class="vf-box vf-box-theme--secondary vf-box--normal">
<h3 class="vf-box__heading">Did you know?</h3>
<p class="vf-box__text">This is some more content that would be in the box.</p>
</div>
<div class="vf-box vf-box-theme--secondary vf-box--normal">
<h3 class="vf-box__heading">Did you know?</h3>
<p class="vf-box__text">This is some more content that would be in the box.</p>
</div>
</div>
</div>
This is some more content that would be in the box.
This is some more content that would be in the box.
This is some more content that would be in the box.
This is some more content that would be in the box.
This is some more content that would be in the box.
This is some more content that would be in the box.
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": "layout",
"cluster_child_flex": "25% 1 0",
"cluster__spacing": 600
}
%}
{% include "../path_to/vf-cluster/vf-cluster.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-cluster', {
"component-type": "layout",
"cluster_child_flex": "25% 1 0",
"cluster__spacing": 600
} %}
<div class="vf-cluster vf-cluster--600" style=" --vf-cluster__item--flex: 25% 1 0;">
<div class="vf-cluster__inner">
<div class="vf-box vf-box-theme--primary vf-box--normal">
<h3 class="vf-box__heading">Did you know?</h3>
<p class="vf-box__text">This is some more content that would be in the box.</p>
</div>
<div class="vf-box vf-box-theme--primary vf-box--normal">
<h3 class="vf-box__heading">Did you know?</h3>
<p class="vf-box__text">This is some more content that would be in the box.</p>
</div>
<div class="vf-box vf-box-theme--primary vf-box--normal">
<h3 class="vf-box__heading">Did you know?</h3>
<p class="vf-box__text">This is some more content that would be in the box.</p>
</div>
<div class="vf-box vf-box-theme--secondary vf-box--normal">
<h3 class="vf-box__heading">Did you know?</h3>
<p class="vf-box__text">This is some more content that would be in the box.</p>
</div>
<div class="vf-box vf-box-theme--secondary vf-box--normal">
<h3 class="vf-box__heading">Did you know?</h3>
<p class="vf-box__text">This is some more content that would be in the box.</p>
</div>
<div class="vf-box vf-box-theme--secondary vf-box--normal">
<h3 class="vf-box__heading">Did you know?</h3>
<p class="vf-box__text">This is some more content that would be in the box.</p>
</div>
</div>
</div>
This is some more content that would be in the box.
This is some more content that would be in the box.
This is some more content that would be in the box.
This is some more content that would be in the box.
This is some more content that would be in the box.
This is some more content that would be in the box.
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": "layout",
"cluster_child_flex": "25% 1 0",
"cluster__spacing": 800
}
%}
{% include "../path_to/vf-cluster/vf-cluster.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-cluster', {
"component-type": "layout",
"cluster_child_flex": "25% 1 0",
"cluster__spacing": 800
} %}
<div class="vf-cluster vf-cluster--800" style=" --vf-cluster__item--flex: 25% 1 0;">
<div class="vf-cluster__inner">
<div class="vf-box vf-box-theme--primary vf-box--normal">
<h3 class="vf-box__heading">Did you know?</h3>
<p class="vf-box__text">This is some more content that would be in the box.</p>
</div>
<div class="vf-box vf-box-theme--primary vf-box--normal">
<h3 class="vf-box__heading">Did you know?</h3>
<p class="vf-box__text">This is some more content that would be in the box.</p>
</div>
<div class="vf-box vf-box-theme--primary vf-box--normal">
<h3 class="vf-box__heading">Did you know?</h3>
<p class="vf-box__text">This is some more content that would be in the box.</p>
</div>
<div class="vf-box vf-box-theme--secondary vf-box--normal">
<h3 class="vf-box__heading">Did you know?</h3>
<p class="vf-box__text">This is some more content that would be in the box.</p>
</div>
<div class="vf-box vf-box-theme--secondary vf-box--normal">
<h3 class="vf-box__heading">Did you know?</h3>
<p class="vf-box__text">This is some more content that would be in the box.</p>
</div>
<div class="vf-box vf-box-theme--secondary vf-box--normal">
<h3 class="vf-box__heading">Did you know?</h3>
<p class="vf-box__text">This is some more content that would be in the box.</p>
</div>
</div>
</div>
This is some more content that would be in the box.
This is some more content that would be in the box.
This is some more content that would be in the box.
This is some more content that would be in the box.
This is some more content that would be in the box.
This is some more content that would be in the box.
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": "layout",
"cluster_child_flex": "25% 1 0",
"cluster_custom_spacing": "3rem"
}
%}
{% include "../path_to/vf-cluster/vf-cluster.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-cluster', {
"component-type": "layout",
"cluster_child_flex": "25% 1 0",
"cluster_custom_spacing": "3rem"
} %}
<div class="vf-cluster" style=" --vf-cluster-margin: 3rem; --vf-cluster__item--flex: 25% 1 0;">
<div class="vf-cluster__inner">
<div class="vf-box vf-box-theme--primary vf-box--normal">
<h3 class="vf-box__heading">Did you know?</h3>
<p class="vf-box__text">This is some more content that would be in the box.</p>
</div>
<div class="vf-box vf-box-theme--primary vf-box--normal">
<h3 class="vf-box__heading">Did you know?</h3>
<p class="vf-box__text">This is some more content that would be in the box.</p>
</div>
<div class="vf-box vf-box-theme--primary vf-box--normal">
<h3 class="vf-box__heading">Did you know?</h3>
<p class="vf-box__text">This is some more content that would be in the box.</p>
</div>
<div class="vf-box vf-box-theme--secondary vf-box--normal">
<h3 class="vf-box__heading">Did you know?</h3>
<p class="vf-box__text">This is some more content that would be in the box.</p>
</div>
<div class="vf-box vf-box-theme--secondary vf-box--normal">
<h3 class="vf-box__heading">Did you know?</h3>
<p class="vf-box__text">This is some more content that would be in the box.</p>
</div>
<div class="vf-box vf-box-theme--secondary vf-box--normal">
<h3 class="vf-box__heading">Did you know?</h3>
<p class="vf-box__text">This is some more content that would be in the box.</p>
</div>
</div>
</div>
This is some more content that would be in the box. These examples also have make use of the --vf-cluster__item--width
to minimise the width so you can see the differences in alignment.
This is even more content that would be in the box. So much information it spans multiple lines.
This is some more content that would be in the box.
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": "layout",
"cluster_child_flex": "25% 1 0",
"cluster_custom_alignment": "flex-start"
}
%}
{% include "../path_to/vf-cluster/vf-cluster.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-cluster', {
"component-type": "layout",
"cluster_child_flex": "25% 1 0",
"cluster_custom_alignment": "flex-start"
} %}
<div class="vf-cluster" style="--vf-cluster-alignment: flex-start; --vf-cluster__item--flex: 25% 1 0;">
<div class="vf-cluster__inner">
<div class="vf-box vf-box-theme--primary vf-box--normal">
<h3 class="vf-box__heading">Did you know?</h3>
<p class="vf-box__text">This is some more content that would be in the box. These examples also have make use of the <code>--vf-cluster__item--width</code> to minimise the width so you can see the differences in alignment.</p>
</div>
<div class="vf-box vf-box-theme--primary vf-box--normal">
<h3 class="vf-box__heading">Did you know?</h3>
<p class="vf-box__text">This is even more content that would be in the box. So much information it spans multiple lines.</p>
</div>
<div class="vf-box vf-box-theme--primary vf-box--normal">
<h3 class="vf-box__heading">Did you know?</h3>
<p class="vf-box__text">This is some more content that would be in the box.</p>
</div>
</div>
</div>
This is some more content that would be in the box. These examples also have make use of the --vf-cluster__item--width
to minimise the width so you can see the differences in alignment.
This is even more content that would be in the box. So much information it spans multiple lines.
This is some more content that would be in the box.
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": "layout",
"cluster_child_flex": "25% 1 0",
"cluster_custom_alignment": "center"
}
%}
{% include "../path_to/vf-cluster/vf-cluster.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-cluster', {
"component-type": "layout",
"cluster_child_flex": "25% 1 0",
"cluster_custom_alignment": "center"
} %}
<div class="vf-cluster" style="--vf-cluster-alignment: center; --vf-cluster__item--flex: 25% 1 0;">
<div class="vf-cluster__inner">
<div class="vf-box vf-box-theme--primary vf-box--normal">
<h3 class="vf-box__heading">Did you know?</h3>
<p class="vf-box__text">This is some more content that would be in the box. These examples also have make use of the <code>--vf-cluster__item--width</code> to minimise the width so you can see the differences in alignment.</p>
</div>
<div class="vf-box vf-box-theme--primary vf-box--normal">
<h3 class="vf-box__heading">Did you know?</h3>
<p class="vf-box__text">This is even more content that would be in the box. So much information it spans multiple lines.</p>
</div>
<div class="vf-box vf-box-theme--primary vf-box--normal">
<h3 class="vf-box__heading">Did you know?</h3>
<p class="vf-box__text">This is some more content that would be in the box.</p>
</div>
</div>
</div>
This is some more content that would be in the box. These examples also have make use of the --vf-cluster__item--width
to minimise the width so you can see the differences in alignment.
This is even more content that would be in the box. So much information it spans multiple lines.
This is some more content that would be in the box.
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": "layout",
"cluster_child_flex": "25% 1 0",
"cluster_custom_alignment": "flex-end"
}
%}
{% include "../path_to/vf-cluster/vf-cluster.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-cluster', {
"component-type": "layout",
"cluster_child_flex": "25% 1 0",
"cluster_custom_alignment": "flex-end"
} %}
<div class="vf-cluster" style="--vf-cluster-alignment: flex-end; --vf-cluster__item--flex: 25% 1 0;">
<div class="vf-cluster__inner">
<div class="vf-box vf-box-theme--primary vf-box--normal">
<h3 class="vf-box__heading">Did you know?</h3>
<p class="vf-box__text">This is some more content that would be in the box. These examples also have make use of the <code>--vf-cluster__item--width</code> to minimise the width so you can see the differences in alignment.</p>
</div>
<div class="vf-box vf-box-theme--primary vf-box--normal">
<h3 class="vf-box__heading">Did you know?</h3>
<p class="vf-box__text">This is even more content that would be in the box. So much information it spans multiple lines.</p>
</div>
<div class="vf-box vf-box-theme--primary vf-box--normal">
<h3 class="vf-box__heading">Did you know?</h3>
<p class="vf-box__text">This is some more content that would be in the box.</p>
</div>
</div>
</div>
This is some more content that would be in the box. These examples also have make use of the --vf-cluster__item--width
to minimise the width so you can see the differences in alignment.
This is even more content that would be in the box. So much information it spans multiple lines.
This is some more content that would be in the box.
This is even more content that would be in the box. So much information it spans multiple lines.
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": "layout",
"cluster_child_flex": "25% 1 0",
"cluster_custom_alignment": "stretch"
}
%}
{% include "../path_to/vf-cluster/vf-cluster.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-cluster', {
"component-type": "layout",
"cluster_child_flex": "25% 1 0",
"cluster_custom_alignment": "stretch"
} %}
<div class="vf-cluster" style="--vf-cluster-alignment: stretch; --vf-cluster__item--flex: 25% 1 0;">
<div class="vf-cluster__inner">
<div class="vf-box vf-box-theme--primary vf-box--normal">
<h3 class="vf-box__heading">Did you know?</h3>
<p class="vf-box__text">This is some more content that would be in the box. These examples also have make use of the <code>--vf-cluster__item--width</code> to minimise the width so you can see the differences in alignment.</p>
</div>
<div class="vf-box vf-box-theme--primary vf-box--normal">
<h3 class="vf-box__heading">Did you know?</h3>
<p class="vf-box__text">This is even more content that would be in the box. So much information it spans multiple lines.</p>
</div>
<div class="vf-box vf-box-theme--primary vf-box--normal">
<h3 class="vf-box__heading">Did you know?</h3>
<p class="vf-box__text">This is some more content that would be in the box.</p>
</div>
<div class="vf-box vf-box-theme--primary vf-box--normal">
<h3 class="vf-box__heading">Did you know?</h3>
<p class="vf-box__text">This is even more content that would be in the box. So much information it spans multiple lines.</p>
</div>
</div>
</div>
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": "layout",
"cluster_child_flex": "25% 1 0"
}
%}
{% include "../path_to/vf-cluster/vf-cluster.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-cluster', {
"component-type": "layout",
"cluster_child_flex": "25% 1 0"
} %}
<div class="vf-cluster" style=" --vf-cluster__item--flex: 25% 1 0;">
<div class="vf-cluster__inner">
<figure class="vf-figure">
<img class="vf-figure__image" src="../../assets/vf-figure/assets/figure-example.png" alt="hello alt text" loading="lazy">
<figcaption class="vf-figure__caption">Version, 1982, Adenovirus with 217 dots</figcaption>
</figure>
<figure class="vf-figure">
<img class="vf-figure__image" src="../../assets/vf-figure/assets/figure-example.png" alt="hello alt text" loading="lazy">
<figcaption class="vf-figure__caption">Version, 1982, Adenovirus with 217 dots</figcaption>
</figure>
<figure class="vf-figure">
<img class="vf-figure__image" src="../../assets/vf-figure/assets/figure-example.png" alt="hello alt text" loading="lazy">
<figcaption class="vf-figure__caption">Version, 1982, Adenovirus with 217 dots</figcaption>
</figure>
<figure class="vf-figure">
<img class="vf-figure__image" src="../../assets/vf-figure/assets/figure-example.png" alt="hello alt text" loading="lazy">
<figcaption class="vf-figure__caption">Version, 1982, Adenovirus with 217 dots</figcaption>
</figure>
<figure class="vf-figure">
<img class="vf-figure__image" src="../../assets/vf-figure/assets/figure-example.png" alt="hello alt text" loading="lazy">
<figcaption class="vf-figure__caption">Version, 1982, Adenovirus with 217 dots</figcaption>
</figure>
</div>
</div>
This repository is distributed with npm. After installing npm and yarn, you can install vf-cluster
with this command.
$ yarn add --dev @visual-framework/vf-cluster
The source files included are written in scss
syntax of Sass. You can point your sass include-path
at your node_modules
directory and import it like this.
@import "@visual-framework/vf-cluster/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--600
and --800
variants.
File system location: components/vf-cluster
Find an issue on this page? Propose a change or discuss it.