Teaser

An image and text leading to another page; a link alone is filled from that page.

When to use it

One highlighted page: an image and text leading to it. Give it only the link and it fills its title, text and image from that page.

When not to

Many pages in a row (use cards or list-pages) and links outside the site with no image or text.

Accessibility

The whole teaser leads to the page through one link named by its title, so screen readers do not hear the same link twice.

See it live

The component library shows this component in the default theme, in every variant: open it in the component library

The teaser example as the component library shows it in the default theme

Where it is used

The starter sites that use it, each at a page that shows it:

Fields

What the component’s dialog asks for. In a Doc, keyed rows start with the key; rows in order follow the order below. Each row is a key and its value, in any order.

Field

Key

Kind

Required

Image

image

An image from the assets, with its description

No

Text above the title

pretitle

Plain text, one line

No

Title

title

Plain text, one line

Yes

Text

text

Text with headings, lists, links and bold

No

Link

link

A link: its text and address

No

Variants

A variant changes how the component looks. Write it in parentheses after the name in the table’s first cell, several separated by commas.

Variant

Write in the first cell

Large

teaser (hero)

Featured

teaser (featured)

Image on the right

teaser (image-right)

Warnings it can raise

The editor and the build say these when a block of this component needs a fix. All warnings are listed in the warnings reference.

Code

What it says

empty_teaser

A teaser has no image, title, text or link and was left out.

In Google Docs

A component is a table. Its first cell names it; the rows below hold its fields. This is the example table:

teaser

image

[Image]

pretitle

Magazine

title

Surfing the cold north

text

Wetsuits, waves and northern light.

link

Read more (https://example.com/magazine/)

In a page file

In a site kept as a folder or in Git, the same component is a block of the page’s JSON file:

JSON
{
  "name": "teaser",
  "variants": [
    "hero"
  ],
  "rows": [
    [
      "image",
      {
        "image": "Surfer on a cold beach"
      }
    ],
    [
      "pretitle",
      "Magazine"
    ],
    [
      "title",
      "Surfing the cold north"
    ],
    [
      "text",
      "Wetsuits, waves and northern light."
    ],
    [
      "link",
      {
        "link": "Read more",
        "href": "https://example.com/magazine/"
      }
    ]
  ]
}

Markup and classes

What the component writes takes these classes, for a theme’s CSS: the component’s own name, name__part for its parts and name--variant for each variant (the variant’s plain name is there too).

Class

What it marks

teaser

The component

teaser__actions

A part of it

teaser__body

A part of it

teaser__media

A part of it

teaser__pretitle

A part of it

teaser__text

A part of it

teaser__title

A part of it

teaser--hero

A variant

teaser--featured

A variant

teaser--image-right

A variant

The HTML the example above writes, as the component library builds it in the default theme:

html
<div class="teaser">
<div class="teaser__media"><img src="/assets/img/5521e01d770e-1600.webp" srcset="/assets/img/5521e01d770e-400.webp 400w, /assets/img/5521e01d770e-800.webp 800w, /assets/img/5521e01d770e-1600.webp 1600w" sizes="(max-width: 800px) 100vw, 800px" alt="Surfer on a cold beach" width="1800" height="900" fetchpriority="high" decoding="async"></div>
<div class="teaser__body">
<p class="teaser__pretitle">Magazine</p>
<h3 class="teaser__title"><a href="https://example.com/magazine/">Surfing the cold north</a></h3>
<div class="teaser__text"><p>Wetsuits, waves and northern light.</p></div>
<div class="teaser__actions"><a class="button" href="https://example.com/magazine/">Read more</a></div>
</div>
</div>

Extending it

Its files in SeedPage. A theme or a site changes the markup by giving a file of the same name (the Liquid part), and a new component can extend this one.

  • src/components/teaser.js
  • src/components/teaser/actions.liquid
  • src/components/teaser/media.liquid
  • src/components/teaser/pretitle.liquid
  • src/components/teaser/teaser.liquid
  • src/components/teaser/text.liquid
  • src/components/teaser/title.liquid