Hero

A large opening banner: image, short text and a call to action.

When to use it

The opening of a home page or a landing page: a large image, the promise in a sentence and the main action.

When not to

Inner pages that need to get to their content quickly, and more than one per page.

Accessibility

The image is loaded at once with high priority, because it is the first thing seen; describe it, or leave its description empty when it only sets the mood. With the dark variant, the text sits on a shade that keeps it readable over any photo.

See it live

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

The hero 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. One row, its cells in the order of the fields.

Field

Key

Kind

Required

Image

image

An image from the assets, with its description

No

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

Full width

hero (full)

Dark

hero (dark)

In Google Docs

A component is a table. Its first cell names it; the rows below hold its fields. This is the example table: The first row of the table here only names the columns; the Doc table is the rows below it.

Image

Text

Link

hero

[Image]

Find your trail — Guided trips for every level.

Explore trips (https://example.com/adventures/)

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": "hero",
  "variants": [
    "full"
  ],
  "rows": [
    [
      {
        "image": "Mountain ridge at dawn"
      },
      {
        "title": "Find your trail",
        "text": "Guided trips for every level."
      },
      {
        "link": "Explore trips",
        "href": "https://example.com/adventures/"
      }
    ]
  ]
}

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

hero

The component

hero__body

A part of it

hero__media

A part of it

hero--full

A variant

hero--dark

A variant

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

html
<div class="hero">
  <div class="hero__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="100vw" alt="Mountain ridge at dawn" width="1800" height="900" fetchpriority="high" decoding="async"></div>
  <div class="hero__body"><p><strong>Find your trail</strong></p><p>Guided trips for every level.</p><a class="button" href="https://example.com/adventures/">Explore trips</a></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/hero.js
  • src/components/hero/content.liquid
  • src/components/hero/hero.liquid
  • src/components/hero/media.liquid