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

Hero container

The vf-hero component is to be used as a visual queue and page header. As needed, it can take a kicker, heading, sub-heading, text content, and a 'call to action' link.

github location npm version

Usage

By default the vf-hero makes use of the roundels background image. To keep the raw structure of the HTML and CSS the same this is applied using a CSS custom property. The default variant is equivalent to vf-hero--1200.

Hero background images

You can bring your own image to use with the vf-hero.

  • Size: recommended image size for a typical hero is 3000 by 1000 pixels.
  • Positioning: people and other important imagery should be placed on the right side. The image will, by default, vertically centre and align to the right side.
  • Imagery: most of the image should be abstract as to not visually compete with the text in the hero box.
  • Text: do not use raster text as part of the image.
  • Consult design: the image should be made in consultation with your organisation's design team for brand alignment and input on how best to create it.

Content

Content name Usage .yml key
Heading To be used for the heading of the page. vf_hero_heading
Heading HREF To be used as a 'return to home' link for the micro site. vf_hero_heading_href
Subheading Optional content to be used along with the Heading for a terse explainer. vf_hero_subheading
Kicker Optional content that helps define the context of overall content of the page. vf_hero_kicker
Text Optional content that can help explain the page content in a brief paragraph. vf_hero_text
Link Text The text for the hero 'call to action' link. Only works if there is associated Link HREF. vf_hero_link_text
Link HREF The url that the Link Text would be pointing to and opens in the same browser tab. This only works if there is associated Link Text vf_hero_link_href
Content name .yml key CSS classname
Kicker vf_hero_kicker vf-hero__kicker
Heading vf_hero_heading vf-hero__heading
Heading HREF vf_hero_heading_href vf-hero__heading_link
Subheading vf_hero_subheading vf-hero__subheading
Text vf_hero_text vf-hero__text
Link Text vf_hero_link_text vf-hero__link
Link HREF vf_hero_link_href n/a

CSS Custom Properties

--vf-hero--bg-image — this is for the url for the background image. It can either be added, inline if you're writing the HTML, using the .yml data source of vf_hero_image, or by other needs (a input or upload in WordPress, for example).

---vf-hero--bg-image-size — this is to determine the sizing of the background image. As group sites are using the roundel image it needs specific dimensions so that it works. These dimensions are auto 28.5rem. We use a fallback here as background images in vf-hero should be full bleed by default so the fall back in the CSS is for cover — var(---vf-hero--bg-image-size, cover).

Internet Explorer support

IE 11 will get the background colour and the "roundels" image. Under the approach of progressive enhancement, IE 11 will not paint a different background image if added.

EMBL usage

For EMBL sites, the vf-hero can take an image (provided by Design) which should be uploaded to the files site and applied using the custom property available (--vf-hero--bg-image).

Variants

VF Hamburg | Structural Biology

About the Hentze group!

an example of some ancillary text

The Hentze group combines biochemical and systems–level approaches to investigate the connections between gene expression and cell metabolism, and their roles in human disease.

Learn more
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": "container",
  "vf_hero_kicker": "<a href=\"JavaScript:Void(0);\">VF Hamburg</a> | Structural Biology",
  "vf_hero_heading": "About the Hentze group!",
  "vf_hero_heading_href": "JavaScript:Void(0);",
  "vf_hero_subheading": "an example of some ancillary text",
  "vf_hero_text": [
    "The Hentze group combines biochemical and <a href=\"JavaScript:Void(0);\">systems–level approaches</a> to investigate the connections between <a href=\"JavaScript:Void(0);\">gene expression</a> and <a href=\"JavaScript:Void(0);\">cell metabolism</a>, and their roles in human disease."
  ],
  "vf_hero_link_text": "Learn more",
  "vf_hero_link_href": "JavaScript:Void(0);",
  "vf_hero_image_size": "auto 28.5rem"
}
 %}
{% include "../path_to/vf-hero/vf-hero.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-hero', {
  "component-type": "container",
  "vf_hero_kicker": "<a href=\"JavaScript:Void(0);\">VF Hamburg</a> | Structural Biology",
  "vf_hero_heading": "About the Hentze group!",
  "vf_hero_heading_href": "JavaScript:Void(0);",
  "vf_hero_subheading": "an example of some ancillary text",
  "vf_hero_text": [
    "The Hentze group combines biochemical and <a href=\"JavaScript:Void(0);\">systems–level approaches</a> to investigate the connections between <a href=\"JavaScript:Void(0);\">gene expression</a> and <a href=\"JavaScript:Void(0);\">cell metabolism</a>, and their roles in human disease."
  ],
  "vf_hero_link_text": "Learn more",
  "vf_hero_link_href": "JavaScript:Void(0);",
  "vf_hero_image_size": "auto 28.5rem"
} %}
                
HTML
<section class="vf-hero | vf-u-fullbleed" style=" --vf-hero--bg-image-size: auto 28.5rem">
  <div class="vf-hero__content | vf-box | vf-stack vf-stack--400">
    <p class="vf-hero__kicker"><a href="JavaScript:Void(0);">VF Hamburg</a> | Structural Biology</p>
    <h1 class="vf-hero__heading"><a class="vf-hero__heading_link" href="JavaScript:Void(0);">About the Hentze group!</a></h1>

    <p class="vf-hero__subheading">an example of some ancillary text</p>
    <p class="vf-hero__text">The Hentze group combines biochemical and <a href="JavaScript:Void(0);">systems–level approaches</a> to investigate the connections between <a href="JavaScript:Void(0);">gene expression</a> and <a href="JavaScript:Void(0);">cell metabolism</a>, and their roles in human disease.</p> <a class="vf-hero__link" href="JavaScript:Void(0);">Learn more<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">
        <path d="M0 12c0 6.627 5.373 12 12 12s12-5.373 12-12S18.627 0 12 0C5.376.008.008 5.376 0 12zm13.707-5.209l4.5 4.5a1 1 0 010 1.414l-4.5 4.5a1 1 0 01-1.414-1.414l2.366-2.367a.25.25 0 00-.177-.424H6a1 1 0 010-2h8.482a.25.25 0 00.177-.427l-2.366-2.368a1 1 0 011.414-1.414z" fill="" fill-rule="nonzero"></path>
      </svg>
    </a>
  </div>
</section>
              

VF Hamburg | Structural Biology

About the Hentze group!

an example of some ancillary text

The Hentze group combines biochemical and systems–level approaches to investigate the connections between gene expression and cell metabolism, and their roles in human disease.

Learn more
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": "container",
  "vf_hero_kicker": "<a href=\"JavaScript:Void(0);\">VF Hamburg</a> | Structural Biology",
  "vf_hero_heading": "About the Hentze group!",
  "vf_hero_subheading": "an example of some ancillary text",
  "vf_hero_text": [
    "The Hentze group combines biochemical and <a href=\"JavaScript:Void(0);\">systems–level approaches</a> to investigate the connections between <a href=\"JavaScript:Void(0);\">gene expression</a> and <a href=\"JavaScript:Void(0);\">cell metabolism</a>, and their roles in human disease."
  ],
  "vf_hero_link_text": "Learn more",
  "vf_hero_link_href": "JavaScript:Void(0);",
  "vf_hero_image": "url('https://acxngcvroo.cloudimg.io/v7/https://www.embl.org/files/wp-content/uploads/vf-hero-intense.png');"
}
 %}
{% include "../path_to/vf-hero/vf-hero.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-hero', {
  "component-type": "container",
  "vf_hero_kicker": "<a href=\"JavaScript:Void(0);\">VF Hamburg</a> | Structural Biology",
  "vf_hero_heading": "About the Hentze group!",
  "vf_hero_subheading": "an example of some ancillary text",
  "vf_hero_text": [
    "The Hentze group combines biochemical and <a href=\"JavaScript:Void(0);\">systems–level approaches</a> to investigate the connections between <a href=\"JavaScript:Void(0);\">gene expression</a> and <a href=\"JavaScript:Void(0);\">cell metabolism</a>, and their roles in human disease."
  ],
  "vf_hero_link_text": "Learn more",
  "vf_hero_link_href": "JavaScript:Void(0);",
  "vf_hero_image": "url('https://acxngcvroo.cloudimg.io/v7/https://www.embl.org/files/wp-content/uploads/vf-hero-intense.png');"
} %}
                
HTML
<section class="vf-hero | vf-u-fullbleed" style="--vf-hero--bg-image: url('https://acxngcvroo.cloudimg.io/v7/https://www.embl.org/files/wp-content/uploads/vf-hero-intense.png');">
  <div class="vf-hero__content | vf-box | vf-stack vf-stack--400">
    <p class="vf-hero__kicker"><a href="JavaScript:Void(0);">VF Hamburg</a> | Structural Biology</p>
    <h1 class="vf-hero__heading">About the Hentze group!</h1>

    <p class="vf-hero__subheading">an example of some ancillary text</p>
    <p class="vf-hero__text">The Hentze group combines biochemical and <a href="JavaScript:Void(0);">systems–level approaches</a> to investigate the connections between <a href="JavaScript:Void(0);">gene expression</a> and <a href="JavaScript:Void(0);">cell metabolism</a>, and their roles in human disease.</p> <a class="vf-hero__link" href="JavaScript:Void(0);">Learn more<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">
        <path d="M0 12c0 6.627 5.373 12 12 12s12-5.373 12-12S18.627 0 12 0C5.376.008.008 5.376 0 12zm13.707-5.209l4.5 4.5a1 1 0 010 1.414l-4.5 4.5a1 1 0 01-1.414-1.414l2.366-2.367a.25.25 0 00-.177-.424H6a1 1 0 010-2h8.482a.25.25 0 00.177-.427l-2.366-2.368a1 1 0 011.414-1.414z" fill="" fill-rule="nonzero"></path>
      </svg>
    </a>
  </div>
</section>
              

A journey through bioinformatics

Explore resources from EMBL-EBI

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": "container",
  "spacing": 400,
  "vf_hero_heading": "A journey through bioinformatics",
  "vf_hero_text": [
    "Explore resources from EMBL-EBI"
  ],
  "vf_hero_image_size": "auto 28.5rem"
}
 %}
{% include "../path_to/vf-hero/vf-hero.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-hero', {
  "component-type": "container",
  "spacing": 400,
  "vf_hero_heading": "A journey through bioinformatics",
  "vf_hero_text": [
    "Explore resources from EMBL-EBI"
  ],
  "vf_hero_image_size": "auto 28.5rem"
} %}
                
HTML
<section class="vf-hero vf-hero--400 | vf-u-fullbleed" style=" --vf-hero--bg-image-size: auto 28.5rem">
  <div class="vf-hero__content | vf-box | vf-stack vf-stack--400">
    <h1 class="vf-hero__heading">A journey through bioinformatics</h1>

    <p class="vf-hero__text">Explore resources from EMBL-EBI</p>
  </div>
</section>
              

About the Hentze group!

Learn more
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": "container",
  "spacing": 800,
  "vf_hero_heading": "About the Hentze group!",
  "vf_hero_link_text": "Learn more",
  "vf_hero_link_href": "JavaScript:Void(0);",
  "vf_hero_image_size": "auto 28.5rem"
}
 %}
{% include "../path_to/vf-hero/vf-hero.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-hero', {
  "component-type": "container",
  "spacing": 800,
  "vf_hero_heading": "About the Hentze group!",
  "vf_hero_link_text": "Learn more",
  "vf_hero_link_href": "JavaScript:Void(0);",
  "vf_hero_image_size": "auto 28.5rem"
} %}
                
HTML
<section class="vf-hero vf-hero--800 | vf-u-fullbleed" style=" --vf-hero--bg-image-size: auto 28.5rem">
  <div class="vf-hero__content | vf-box | vf-stack vf-stack--400">
    <h1 class="vf-hero__heading">About the Hentze group!</h1>

    <a class="vf-hero__link" href="JavaScript:Void(0);">Learn more<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">
        <path d="M0 12c0 6.627 5.373 12 12 12s12-5.373 12-12S18.627 0 12 0C5.376.008.008 5.376 0 12zm13.707-5.209l4.5 4.5a1 1 0 010 1.414l-4.5 4.5a1 1 0 01-1.414-1.414l2.366-2.367a.25.25 0 00-.177-.424H6a1 1 0 010-2h8.482a.25.25 0 00.177-.427l-2.366-2.368a1 1 0 011.414-1.414z" fill="" fill-rule="nonzero"></path>
      </svg>
    </a>
  </div>
</section>
              

About the Hentze group!

an example of some ancillary text

Learn more
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": "container",
  "spacing": 1200,
  "vf_hero_heading": "About the Hentze group!",
  "vf_hero_subheading": "an example of some ancillary text",
  "vf_hero_link_text": "Learn more",
  "vf_hero_link_href": "JavaScript:Void(0);",
  "vf_hero_image_size": "auto 28.5rem"
}
 %}
{% include "../path_to/vf-hero/vf-hero.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-hero', {
  "component-type": "container",
  "spacing": 1200,
  "vf_hero_heading": "About the Hentze group!",
  "vf_hero_subheading": "an example of some ancillary text",
  "vf_hero_link_text": "Learn more",
  "vf_hero_link_href": "JavaScript:Void(0);",
  "vf_hero_image_size": "auto 28.5rem"
} %}
                
HTML
<section class="vf-hero vf-hero--1200 | vf-u-fullbleed" style=" --vf-hero--bg-image-size: auto 28.5rem">
  <div class="vf-hero__content | vf-box | vf-stack vf-stack--400">
    <h1 class="vf-hero__heading">About the Hentze group!</h1>

    <p class="vf-hero__subheading">an example of some ancillary text</p> <a class="vf-hero__link" href="JavaScript:Void(0);">Learn more<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">
        <path d="M0 12c0 6.627 5.373 12 12 12s12-5.373 12-12S18.627 0 12 0C5.376.008.008 5.376 0 12zm13.707-5.209l4.5 4.5a1 1 0 010 1.414l-4.5 4.5a1 1 0 01-1.414-1.414l2.366-2.367a.25.25 0 00-.177-.424H6a1 1 0 010-2h8.482a.25.25 0 00.177-.427l-2.366-2.368a1 1 0 011.414-1.414z" fill="" fill-rule="nonzero"></path>
      </svg>
    </a>
  </div>
</section>
              

Examples

Installation info

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

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

Sass/CSS

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-hero/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.3.4

  • Changing from h1 to h2
  • https://github.com/visual-framework/vf-core/issues/1762

3.3.3

  • Improve docs on vf-hero image sizing
  • https://github.com/visual-framework/vf-core/issues/1641

3.3.2

  • Drop use of vf-stack-margin--custom.
  • https://github.com/visual-framework/vf-core/pull/1698

3.3.1

  • Reduces vf-hero bottom margin.
  • Makes vf-hero bottom margin "smarter" by no applying when the following element uses vf-u-fullwidth or vf-navigation. In these cases vf-stack is sufficient.

3.3.0

  • Updates the default hero spacing to be equivalent to 1200 (was: 800). This better matches the actual default usage in practice and is based off design feedback for consistency.
  • Hides 1600 variant that has gone unused.
  • Readme updated to note that most uses will want a background image at 3000 by 1000 pixels.
  • https://github.com/visual-framework/vf-core/pull/1614

3.2.3

  • Fixes width issue on mobile introduced when making the hero content a little wider.
  • Removes unused vf-intro-group.png sample hero image.

3.2.2

  • Allows html (for links) in vf-hero__subheading (and a few other fields) when using the Nunjucks template.
  • https://github.com/visual-framework/vf-core/pull/1485

3.2.1

  • Resolves a Nunjucks bug on vf_hero_text from a yaml file under certain contexts.
  • https://github.com/visual-framework/vf-core/pull/1462
  • Allows vf_hero_heading_href to be passed in yaml.
  • Gobbles much of the whitespace.

3.2.0

  • adds thinner vf-hero--400 variant.
  • fixes vf-hero__content vf-box sizing padding calculaton for vf-hero--800 variant.
  • makes the maximum width of the vf-hero__content wider, but make smaller widths max-content.

3.1.0

  • adds link styles to the vf-hero__heading
  • updated the documentation to include the vf-hero__heading_link details.

3.0.1

  • changes any set- style functions to cleaner version

3.0.0

  • removes all design variants.
  • replaces vf-hero__heading__additional with vf-hero__kicker.
  • makes the call to action link a separate entity as there would be a conflict with vf-hero__text.
  • adds a little more documentation.

2.0.6

  • fixed an issue where vf_hero_href had no context option for use in vf-11ty.

2.0.5

  • adds a flex property to the SVG so that it's always visible and doesn't get cut off.

2.0.4

  • fixes missing context rule for hero__text and hero__heading--additional.

2.0.3

  • adds the context options so the component can be used in 11ty with content seperation.
  • changes max-content to fit-content so the __content element adapts to smaller viewports.
  • removes left padding from --block variant as it 'looked weird'.

2.0.2

  • adds a width of max-content to the __content part of the component so short titles don't look silly.

2.0.1

  • adds the option to add an url to vf-hero__heading with nunjucks/yaml.
  • gives the element a classname.

2.0.0

  • introduces new naming convention for design variants.
  • --inverted: that inverts the foreground and background colours
  • --flush: pulls the vf-hero__content to the bottom of the vf-hero.
  • --offset: pulls the vf-hero__content below the vf-hero container.
  • --centered: centres the vf-hero__content component.
  • --block: makes the vf-hero__content bleed all the way ot the left of the page.
  • --striped: inverts the vf-hero__text to that of what's set in vf-hero__content.
  • --800, --1200, and --1600 spacing variants.
  • replaces vf-hero-theme-- with vf-hero-- for the primary, secondary, and tertiary variants.
  • removes the 'Mortal Kombat' naming convention.
  • reduces visible options of the new vf-hero.
  • older versions (v2) degrade gracefully to the default variant.

1.8.0

  • deprecates the --intense variant.

1.7.1

  • removes CSS for 'inlayed' design as no longer in use
  • https://github.com/visual-framework/vf-core/pull/1204

1.7.0

  • makes the padding on --intense standardised to our spacing units
  • reduces height of all other variants
  • currently this is the 'maximum space' the component will get to allow it's content to be readable

1.6.0

  • adds loading="lazy" to the img element for better performance

1.5.0

  • makes theme variant naming and decisions consistent

1.4.6

  • updates max-width of component

1.4.5

  • adds an if statement for contextual data if applicable

1.4.4

  • fixes issue with --intense variant so parallax image is full width

1.4.3

  • replaces margin shorthand so it doesn't remove bottom margin when using --inlay modifier

1.4.2

  • fixes an issue with vf-hero--inlay and the background image width

1.4.0

  • Adds ability to specify height of the image
  • Improves leading for text with link icon
  • Gives content a max-width to remove need for Media Query
  • Makes the positioning of the content depend upon the image height
  • small update to documentation

1.3.1

  • reverts naming convention for background image reference to vf_hero_image
  • updates key/value pair and classes for the sub-heading

1.3.0

  • The vf-hero component snaps to the viewport boundaries on smaller screens
  • splits out variants using .yml instead of hard coding
  • removes search example
  • makes --extreme variant match designs

1.2.0

  • Removes --medium variants
  • Introduces --very-easy variant
  • Pulls all design variants back one

Assets



File system location: components/vf-hero

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