Components
Hero
Use the hero component to start an article.
Contents
HTML
<header class="tna-hero">
<figure class="tna-hero__figure">
<div class="tna-container tna-hero__inner">
<div class="tna-column tna-column--width-2-3 tna-column--full-small tna-column--full-tiny tna-hero__content">
<div class="tna-hero__content-inner">
<h1 class="tna-heading-xl tna-hero__heading">
This is a hero component
</h1>
<p>You can use it to introduce a new idea.</p>
</div>
</div>
</div>
<picture class="tna-hero__image">
<img src="https://picsum.photos/id/29/1200/480" alt="A mountain range" width="1200" height="480">
</picture>
</figure>
</header>
Nunjucks
Nunjucks options
Name | Type | Description |
---|---|---|
supertitle | string |
The smaller title to display above the main hero title. |
title | string |
The main title of the hero. If set, then |
headingLevel | number |
The heading level which represents an element from |
headingSize | string |
The physical size of the hero title ( Default: |
body | string | |
text | string | |
imageSrc | string |
Required. |
imageAlt | string |
Required. |
imageWidth | number |
Required. |
imageHeight | number |
Required. |
imageSources | array |
Required. Alternative sources of the image which can include WebP files. See imageSources. |
imageCaption | string | |
actions | array |
An array of actions to add at the bottom of the hero component. Each action is displayed as a button. See actions. |
style | string |
The style of hero to use. This can be |
layout | string |
An alternative layout of the hero component to use. This can be |
narrow | boolean |
If true, use a narrower style hero image. |
classes | string |
Classes to add to the hero. |
attributes | object |
HTML attributes (for example data attributes) to add to the hero. |
Name | Type | Description |
---|---|---|
src | string |
Required. |
type | string |
Required. |
media | string | |
width | number | |
height | number |
Name | Type | Description |
---|---|---|
text | string |
Required. The text for the action. |
href | string |
Required. The URL of the action. |
title | string |
An optional title for the action. |
icon | string |
The name of a Font Awesome icon, without the prefixed |
rightAlignIcon | boolean |
If true, align the icon to the right hand side of the button. |
classes | string |
Classes to add to the hero action. |
attributes | object |
HTML attributes (for example data attributes) to add to the hero action. |
{% from "nationalarchives/components/hero/macro.njk" import tnaHero %}
{{ tnaHero({
title: "This is a hero component",
text: "You can use it to introduce a new idea.",
imageSrc: "https://picsum.photos/id/29/1200/480",
imageAlt: "A mountain range",
imageWidth: 1200,
imageHeight: 480
}) }}
Status
- Status
- Ready for production
- Tested without CSS
- Yes
- WCAG 2.2 AA compliant
- Yes
- Analytics integrated
- In development
- Documentation complete
- No
Images
As the height of a hero component is defined by their content, the background image will sometimes be clipped.
Try to use an image with a 5:2 aspect ratio with a suggested resolution of 1200px wide and 480px tall.
The hero element can also accept images for other screen sizes so use a 3:2 aspect ratio with a suggested resolution of 600px wide and 400px tall for smaller screens.