Marketing sectionsHeroCover
Searchastronomic.dev# HeroCover
At the top of a page, for the main heading, one line on what you offer and one or two actions, on a full image.
Static: no JavaScript.
## Usage
```astro
import HeroCover from "@astronomic-dev/ui/components/HeroCover.astro";
```
## Examples
### Studio home page
Edge to edge: placed outside the Container, the image fills the page's width. The text sits at the foot, on the scrim.
```astro
---
import Badge from "@astronomic-dev/ui/components/Badge.astro";
import HeroCover from "@astronomic-dev/ui/components/HeroCover.astro";
// Your own image file.
import shelves from "../../photos/studio-shelves.webp";
const actions = [
{ label: "Start a project", href: "#start" },
{ label: "See our work", href: "#work" },
];
---
<!-- Outside the Container, so the image runs edge to edge. -->
<HeroCover
heading="Brand and web design for firms that sell expertise."
text="We help consultancies and studios explain what they do, and win the clients they want."
actions={actions}
image={{ src: shelves, alt: "" }}
>
<Badge slot="eyebrow" status="positive">Taking new projects</Badge>
</HeroCover>
```
### Framed, in a Container
With framed, the card corners; inside a Container it keeps the page's width.
```astro
---
import Container from "@astronomic-dev/ui/components/Container.astro";
import HeroCover from "@astronomic-dev/ui/components/HeroCover.astro";
// Your own image file.
import stairway from "../../photos/white-stairway.webp";
const actions = [
{ label: "See our work", href: "#work" },
{ label: "Book a call", href: "#call" },
];
---
<Container class="py-12">
<HeroCover
framed
heading="Design that holds up after launch."
text="A small studio for brands that would rather be clear than loud."
actions={actions}
image={{ src: stairway, alt: "" }}
/>
</Container>
```
### Your own images
Astro's <Image> draws the photo (imageComponent={Image}), with no wrapper, and gets sizes="100vw". Astro writes a srcset when your astro.config sets image.layout. For EmDash or another CMS, see "Your own images" in the kit README.
```astro
---
import HeroCover from "@astronomic-dev/ui/components/HeroCover.astro";
// Astro's <Image> draws the photo, with no wrapper; HeroCover passes it sizes="100vw".
// For a srcset, set image: { layout: "constrained" } in your astro.config.
import { Image } from "astro:assets";
// Your own image file.
import shelves from "../../photos/studio-shelves.webp";
const actions = [
{ label: "Start a project", href: "#start" },
{ label: "See our work", href: "#work" },
];
---
<!-- Outside the Container, so the image runs edge to edge. -->
<HeroCover
heading="Brand and web design for firms that sell expertise."
text="We help consultancies and studios explain what they do, and win the clients they want."
actions={actions}
image={{ src: shelves, alt: "" }}
imageComponent={Image}
/>
```
## Props
### HeroCover
| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `heading` | `string` | None | Required. The main heading. |
| `emphasis` | `boolean` | `false` | Turn one *phrase* in the heading into <em>: exactly two asterisks around text with no space inside, as in "Built for *the long run*". Any other asterisks show as typed. Off by default, so the heading shows as typed. How the <em> looks is the theme's. |
| `text` | `string` | None | One or two sentences under the heading. |
| `actions` | `Omit<NavAction, "size">[]` | `[]` | Buttons, always in the large size. NavAction is { label, href, variant? }. The first is `primary` and the rest `secondary`, unless you set variant. |
| `headingTag` | `"h1" \| "h2" \| "h3" \| "h4"` | `"h1"` | The heading element. Keep `h1` when the hero opens the page. |
| `image` | `MediaImage` | None | Required. The image behind the text. It fills the hero and is cropped, so its `ratio` is not used. MediaImage is { src, alt, width?, height?, ratio?, loading?, focalPoint? }; here loading defaults to eager, fetched at high priority. There is no media slot; the image is always the cover. |
| `imageComponent` | `ImageComponent` | None | Your image component for the photo: Astro's <Image>, or a small wrapper for your CMS. It gets src as you gave it, alt, width, height, loading, fetchpriority, decoding, sizes="100vw", a class that fills the hero, and style with only the focal point. Without it, a plain <img>. |
| `framed` | `boolean` | `false` | Card corners. Off, the hero fills its parent box: place it outside the Container to go edge to edge. |
| `class` | `string` | None | More classes on the <section>, merged with cn(), so yours win on conflicts. The hero always clips its overflow and has a minimum height, so the image shows. |
| Slot | Description |
| --- | --- |
| `eyebrow` | A short line above the heading, such as a Badge. |
| `default` | More content under the actions, on the scrim. It inherits the scrim text color, and a plain link (no class) is underlined; a kit part keeps its own colors. |
Any other attribute goes on the <section>.
## Accessibility
- Renders a <section> named by its heading, so it is a region landmark.
- The heading is an h1 by default. Use one h1 per page; set headingTag when the hero sits lower.
- The heading and the subtitle are in --ui-scrim-fg on --ui-scrim at 60% or more (60% at the top of the text, rising below it, over a light veil on the whole image), so they read at 4.5:1 or more on any image, black or white, in every kit preset, light and dark. The actions use the on-image Button colors (tone="image"): each label reads at 4.5:1 and each edge at 3:1 there, at rest and on hover. Tests check it.
- The image sits behind the heading, so it is usually decoration: set alt="" when it adds nothing to the heading. The alt you give is passed through as it is.
- Every focusable element in the text (the actions, and links or buttons you put in the slots) gets a focus ring that shows on any image: a light line on a dark edge.
- Actions are links that look like buttons. Give each a label that says where it goes.
- To go edge to edge, place the hero outside the Container. Its text keeps a reading width at any page width.
- The <em> is read as part of the heading. Use plainHeading() (lib/emphasis.ts) for the page <title>.
HeroCover
FreeAt the top of a page, for the main heading, one line on what you offer and one or two actions, on a full image.
- File
- HeroCover.astro
- Group
- Marketing sections
- Kind
- Static: no JavaScript
- Examples
- 3
Examples
Drag the orange handle to set the width. Frames get real breakpoints.
- Static
- Interactive
- Framed
Studio home page
Edge to edge: placed outside the Container, the image fills the page's width. The text sits at the foot, on the scrim.
This preview did not load.
examples/herocover/main.astro
---
import Badge from "@astronomic-dev/ui/components/Badge.astro";
import HeroCover from "@astronomic-dev/ui/components/HeroCover.astro";
// Your own image file.
import shelves from "../../photos/studio-shelves.webp";
const actions = [
{ label: "Start a project", href: "#start" },
{ label: "See our work", href: "#work" },
];
---
<!-- Outside the Container, so the image runs edge to edge. -->
<HeroCover
heading="Brand and web design for firms that sell expertise."
text="We help consultancies and studios explain what they do, and win the clients they want."
actions={actions}
image={{ src: shelves, alt: "" }}
>
<Badge slot="eyebrow" status="positive">Taking new projects</Badge>
</HeroCover>Framed, in a Container
With framed, the card corners; inside a Container it keeps the page's width.
This preview did not load.
examples/herocover/framed.astro
---
import Container from "@astronomic-dev/ui/components/Container.astro";
import HeroCover from "@astronomic-dev/ui/components/HeroCover.astro";
// Your own image file.
import stairway from "../../photos/white-stairway.webp";
const actions = [
{ label: "See our work", href: "#work" },
{ label: "Book a call", href: "#call" },
];
---
<Container class="py-12">
<HeroCover
framed
heading="Design that holds up after launch."
text="A small studio for brands that would rather be clear than loud."
actions={actions}
image={{ src: stairway, alt: "" }}
/>
</Container>Your own images
Astro's <Image> draws the photo (imageComponent={Image}), with no wrapper, and gets sizes="100vw". Astro writes a srcset when your astro.config sets image.layout. For EmDash or another CMS, see "Your own images" in the kit README.
This preview did not load.
examples/herocover/image-component.astro
---
import HeroCover from "@astronomic-dev/ui/components/HeroCover.astro";
// Astro's <Image> draws the photo, with no wrapper; HeroCover passes it sizes="100vw".
// For a srcset, set image: { layout: "constrained" } in your astro.config.
import { Image } from "astro:assets";
// Your own image file.
import shelves from "../../photos/studio-shelves.webp";
const actions = [
{ label: "Start a project", href: "#start" },
{ label: "See our work", href: "#work" },
];
---
<!-- Outside the Container, so the image runs edge to edge. -->
<HeroCover
heading="Brand and web design for firms that sell expertise."
text="We help consultancies and studios explain what they do, and win the clients they want."
actions={actions}
image={{ src: shelves, alt: "" }}
imageComponent={Image}
/>