<content-hero-block>
A full width section with an image or video behind, or above, its text. Usually the first block on a page.
import '@content-blocks/js/components/content-hero-block';Examples
Background image
The simplest hero: a photo behind a heading and a line of text, at the bottom with vertical="bottom".
<content-hero-block>
<content-image
slot="background"
alt="A castle in mist at the end of a stone road"
src="https://images.unsplash.com/photo-1514539079130-25950c84af65?w=900&h=675&fit=crop&auto=format&q=75"
aspect-ratio="4/3"
></content-image>
<content-text-block slot="content" vertical="bottom" padding="1.5rem">
<content-line tag="h3">The road to Hollowmere</content-line>
<content-line tag="p">The last keep still stands. Its gates wait for one rider.</content-line>
</content-text-block>
</content-hero-block>h3 {
font-size: 1.5rem;
font-weight: 700;
}
content-text-block {
color: #fff;
background: linear-gradient(0deg, rgb(0 0 0 / 70%), transparent 65%);
}// $ npm install @content-blocks/js
import '@content-blocks/js/components/content-hero-block';
import '@content-blocks/js/components/content-image';
import '@content-blocks/js/components/content-text-block';
import '@content-blocks/js/components/content-line';<script type="module"
src="https://cdn.jsdelivr.net/npm/@content-blocks/js/dist/content-blocks/content-blocks.esm.js"></script>Looping video
Give content-image an .mp4 and it plays muted on a loop, like a GIF, behind the text.
<content-hero-block>
<content-image slot="background" alt="" src="https://videos.pexels.com/video-files/13438865/13438865-sd_640_360_25fps.mp4" aspect-ratio="4/3"></content-image>
<content-text-block slot="content" vertical="center" text-align="center" padding="1.5rem">
<content-line tag="h3">The world burns</content-line>
<content-line tag="p">Ragnarök has begun. Someone has to answer.</content-line>
</content-text-block>
</content-hero-block>h3 {
font-size: 1.5rem;
font-weight: 700;
}
content-text-block {
color: #fff;
background: rgb(0 0 0 / 40%);
}// $ npm install @content-blocks/js
import '@content-blocks/js/components/content-hero-block';
import '@content-blocks/js/components/content-image';
import '@content-blocks/js/components/content-text-block';
import '@content-blocks/js/components/content-line';<script type="module"
src="https://cdn.jsdelivr.net/npm/@content-blocks/js/dist/content-blocks/content-blocks.esm.js"></script>Film in an overlay
The button opens a video in a content-overlay, and fill="#ex-hero-film" makes it cover the hero.
<content-hero-block id="ex-hero-film">
<content-image
slot="background"
alt="A lone figure with a lantern on a sea cliff at night"
src="https://images.unsplash.com/photo-1728997150636-91ef00ba7e59?w=900&h=675&fit=crop&auto=format&q=75"
aspect-ratio="4/3"
></content-image>
<content-text-block slot="content" vertical="center" text-align="center" padding="1.5rem">
<content-line tag="h3" padding="0 0 1rem">The long watch</content-line>
<content-button href="#ex-hero-film-video" link-label="Play the film">▶</content-button>
</content-text-block>
</content-hero-block>
<content-overlay id="ex-hero-film-video" fill="#ex-hero-film" label="The film">
<script slot="content" type="text/template">
<content-video fit-container="true" autoplay="true" src="https://www.youtube.com/watch?v=eRsGyueVLvQ"></content-video>
</script>
</content-overlay>h3 {
font-size: 1.5rem;
font-weight: 700;
}
content-text-block {
color: #fff;
background: rgb(0 0 0 / 40%);
}
content-button a {
width: 3.25rem;
height: 3.25rem;
color: #111;
text-decoration: none;
background: #fff;
border-radius: 50%;
}// $ npm install @content-blocks/js
import '@content-blocks/js/components/content-hero-block';
import '@content-blocks/js/components/content-image';
import '@content-blocks/js/components/content-text-block';
import '@content-blocks/js/components/content-line';
import '@content-blocks/js/components/content-button';
import '@content-blocks/js/components/content-overlay';
import '@content-blocks/js/components/content-video';<script type="module"
src="https://cdn.jsdelivr.net/npm/@content-blocks/js/dist/content-blocks/content-blocks.esm.js"></script>Anatomy
Content goes into the component's slots, chosen with the slot attribute on each child.
flowchart LR root["#lt;content-hero-block#gt;"]:::component root --> s0["<b>no slot (default)</b><br/>Default slot, same as content slot"] root --> s1["<b>slot=#quot;background#quot;</b><br/>This slot is usually either a video or image component."] root --> s2["<b>slot=#quot;content#quot;</b><br/>This slot will usually serve a text block."] classDef component fill:#141413,color:#faf9f5,stroke:#141413
| Slot | What goes in it |
|---|---|
(default) | Default slot, same as content slot |
slot="background" | This slot is usually either a video or image component. |
slot="content" | This slot will usually serve a text block. |
Properties
Set them as attributes. Those marked responsive take a value per breakpoint, separated by pipes and named or in order: 1|tablet=2 or 1|2. Seeresponsive values.
| Attribute | Type | Default | Description |
|---|---|---|---|
classesresponsive | String | – | Classes to add to the component. Use pipes for different classes per breakpoint, by name or in order: classes="stacked|laptop=side-by-side". |
content-positionresponsive | Select | 'above' | Where the content sits: above, over the media, or below it. Over the media by default. Use pipes to change it per breakpoint, such as below|above for the text below the media on phones and over it from tablets. |
paddingresponsive | String | – | Padding around the component, written as CSS padding. Use pipes for different padding per breakpoint, by name or in order: padding="1rem|tablet=2rem 4rem" or padding="1rem|2rem 4rem|3rem 5rem 4rem". |
Events and methods
sequenceDiagram participant Page participant C as content-hero-block Page->>C: open event


