<content-tout-block>
A card that promotes something: an image or video with text below it, and an optional layer over the media that can show on hover.
import '@content-blocks/js/components/content-tout-block';Examples
Product card
An image with its name and price below. The whole card is one link, from content-button.
<content-button href="#" link-label="Steel helm, 180 gold">
<content-tout-block hover="false">
<content-image slot="media" alt="" src="https://images.unsplash.com/photo-1680888757148-0d0c31d99d7c?w=600&h=750&fit=crop&auto=format&q=75" aspect-ratio="4/5"></content-image>
<content-text-block slot="content" padding="0.75rem 0 0">
<content-line tag="h3">Steel helm</content-line>
<content-line tag="p">180 gold</content-line>
</content-text-block>
</content-tout-block>
</content-button>h3 {
font-size: 1.5rem;
font-weight: 700;
}
a {
color: inherit;
text-decoration: none;
}// $ npm install @content-blocks/js
import '@content-blocks/js/components/content-button';
import '@content-blocks/js/components/content-tout-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
The card's media is a muted .mp4 on a loop, with a label laid over it in the mediaContent slot and its title below.
<content-tout-block hover="false">
<content-image slot="media" alt="" src="https://videos.pexels.com/video-files/1879456/1879456-sd_640_360_30fps.mp4" aspect-ratio="4/5"></content-image>
<content-text-block slot="mediaContent" full-height="true" vertical="bottom" padding="1.25rem">
<content-line tag="p">Omen</content-line>
</content-text-block>
<content-text-block slot="content" padding="0.75rem 0 0">
<content-line tag="h3">The serpent stirs</content-line>
<content-line tag="p">The sea rises, fjord by fjord.</content-line>
</content-text-block>
</content-tout-block>h3 {
font-size: 1.5rem;
font-weight: 700;
}
content-text-block[slot='mediaContent'] {
color: #fff;
background: linear-gradient(0deg, rgb(0 0 0 / 70%), transparent 65%);
font-size: 0.75rem;
font-weight: 700;
}// $ npm install @content-blocks/js
import '@content-blocks/js/components/content-tout-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 play button opens a video in a content-overlay, and fill="#ex-tout-film" makes it cover the card. hover="false|true" shows the button on phones and on hover from 768px.
<content-tout-block id="ex-tout-film" hover="false|true">
<content-image
slot="media"
alt="A raven flying low over snow"
src="https://images.unsplash.com/photo-1610961388965-129b15e46a2c?w=600&h=750&fit=crop&auto=format&q=75"
aspect-ratio="4/5"
></content-image>
<content-text-block slot="mediaContent" full-height="true" vertical="bottom" padding="1rem">
<content-button href="#ex-tout-film-video" link-label="Play the film">▶</content-button>
</content-text-block>
<content-text-block slot="content" padding="0.75rem 0 0">
<content-line tag="h3">The raven’s message</content-line>
<content-line tag="p">See what the ravens saw.</content-line>
</content-text-block>
</content-tout-block>
<content-overlay id="ex-tout-film-video" fill="#ex-tout-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-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-tout-block';
import '@content-blocks/js/components/content-image';
import '@content-blocks/js/components/content-text-block';
import '@content-blocks/js/components/content-button';
import '@content-blocks/js/components/content-line';
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-tout-block#gt;"]:::component root --> s0["<b>no slot (default)</b><br/>Default slot, same as content slot."] root --> s1["<b>slot=#quot;content#quot;</b><br/>This slot will usually serve a text block."] root --> s2["<b>slot=#quot;media#quot;</b><br/>This slot is usually a video or image component."] root --> s3["<b>slot=#quot;mediaContent#quot;</b><br/>This is a layer that floats the media layer and is revealed on hover."] classDef component fill:#141413,color:#faf9f5,stroke:#141413
| Slot | What goes in it |
|---|---|
(default) | Default slot, same as content slot. |
slot="content" | This slot will usually serve a text block. |
slot="media" | This slot is usually a video or image component. |
slot="mediaContent" | This is a layer that floats the media layer and is revealed on hover. |
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". |
hoverresponsive | Boolean | 'false|true' | If true, the media content will show only on hover |
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". |
flowchart LR v["hover=#quot;false|true#quot;"]:::value v --> b0["mobile, from 0px: false"] v --> b1["tablet and up, from 768px: true"] classDef value fill:#1d4ed8,color:#fff,stroke:#1d4ed8


