Marketing sectionsHero
Searchastronomic.dev# Hero
To build your own hero layout: the heading, a line on what you offer, actions and media, in a fixed order.
Static: no JavaScript.
## Usage
```astro
import Hero from "@astronomic-dev/ui/components/Hero.astro";
```
## Examples
### Slots
The hero is a shell: the eyebrow, the heading, the subtitle, the actions and the default slot always show in that order, with the media block after the text. The shell sets the type and the gaps; contentClass lays out the row. HeroSplit is a recipe built on it.
```astro
---
import Badge from "@astronomic-dev/ui/components/Badge.astro";
import Hero from "@astronomic-dev/ui/components/Hero.astro";
import Media from "@astronomic-dev/ui/components/Media.astro";
// Your own image file.
import shelves from "../../photos/studio-shelves.webp";
---
<div class="mx-auto max-w-6xl px-6 py-20">
<Hero
heading="Design that holds up after launch."
text="A small studio for brands that would rather be clear than loud."
actions={[{ label: "See our work", href: "#work" }, { label: "Book a call", href: "#call" }]}
contentClass="items-center @3xl/hero:grid-cols-2"
>
<Badge slot="eyebrow" status="positive">Taking new projects</Badge>
<p class="m-0 text-small text-muted">The default slot sits under the actions.</p>
<Media slot="media" src={shelves} alt="Stacks of plates and bowls on two white shelves." ratio="4/3" loading="eager" />
</Hero>
</div>
```
### Heading emphasis
With emphasis, the one phrase between two asterisks ("Build sites that *last*.") is an <em> in the heading. Off by default, so the heading shows as typed. The <em> has no class: its look is the theme's. Every Hero recipe and every section shell takes the same prop.
```astro
---
import HeroSplit from "@astronomic-dev/ui/components/HeroSplit.astro";
// With emphasis, the phrase between the asterisks is an <em>. Without it, the heading shows as typed.
const actions = [
{ label: "Start a project", href: "#start" },
{ label: "See our work", href: "#work" },
];
---
<div class="mx-auto max-w-6xl px-6 py-20">
<HeroSplit
heading="Build sites that *last*."
emphasis
text="Astronomic is a kit of parts for sites that stay clear and fast long after launch."
actions={actions}
/>
</div>
```
## Props
### Hero
| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `heading` | `string` | None | Required. The main heading, in display type that sizes to the text column. |
| `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, in the lead role. |
| `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. |
| `align` | `"start" \| "center"` | `"start"` | For recipes: the text's alignment. |
| `tone` | `"page" \| "image"` | `"page"` | For recipes: `image` when the text sits on an image under a scrim. The inherited text and the subtitle turn scrim-fg, and the action Buttons take their on-image colors (Button tone="image"); kit parts in the slots (a Badge, a Button) keep their own colors. |
| `contentClass` | `string` | None | Classes for the inner row that holds the text block and the media block. Recipes set its layout here. |
| `textClass` | `string` | None | Classes for the text block, a named container (hero-text) the heading sizes to. |
| `headingClass` | `string` | None | Classes for the heading, after its own, such as a type role (HeroSplit gives text-display-split side by side). |
| `stackClass` | `string` | None | Classes for the stack inside the text block, the box at the reading width (52rem) that holds the eyebrow, heading, subtitle, actions and default slot. |
| `mediaClass` | `string` | None | Classes for the media block, for example its order on a wide hero. |
| `class` | `string` | None | More classes, merged with cn(), so yours win on conflicts. |
| Slot | Description |
| --- | --- |
| `eyebrow` | A short line above the heading, such as a Badge. |
| `default` | More content under the actions, such as a LogoStrip or a note. |
| `media` | An image or other media, in its own block after the text. An empty slot leaves no block. |
Any other attribute goes on the <section>.
## Accessibility
- Renders a <section> named by its heading, so it is a region landmark. The heading id is unique on the page.
- The heading is an h1 by default. Use one h1 per page; set headingTag when the hero sits lower.
- Actions are links that look like buttons. Give each a label that says where it goes.
- The media block comes after the text in the page order, so a screen reader reads the heading first.
- The <em> is read as part of the heading. Use plainHeading() (lib/emphasis.ts) for the page <title>.
Hero
FreeTo build your own hero layout: the heading, a line on what you offer, actions and media, in a fixed order.
- File
- Hero.astro
- Group
- Marketing sections
- Kind
- Static: no JavaScript
- Examples
- 2
Examples
Drag the orange handle to set the width. Frames get real breakpoints.
- Static
- Interactive
- Framed
Slots
The hero is a shell: the eyebrow, the heading, the subtitle, the actions and the default slot always show in that order, with the media block after the text. The shell sets the type and the gaps; contentClass lays out the row. HeroSplit is a recipe built on it.
This preview did not load.
examples/hero/main.astro
---
import Badge from "@astronomic-dev/ui/components/Badge.astro";
import Hero from "@astronomic-dev/ui/components/Hero.astro";
import Media from "@astronomic-dev/ui/components/Media.astro";
// Your own image file.
import shelves from "../../photos/studio-shelves.webp";
---
<div class="mx-auto max-w-6xl px-6 py-20">
<Hero
heading="Design that holds up after launch."
text="A small studio for brands that would rather be clear than loud."
actions={[{ label: "See our work", href: "#work" }, { label: "Book a call", href: "#call" }]}
contentClass="items-center @3xl/hero:grid-cols-2"
>
<Badge slot="eyebrow" status="positive">Taking new projects</Badge>
<p class="m-0 text-small text-muted">The default slot sits under the actions.</p>
<Media slot="media" src={shelves} alt="Stacks of plates and bowls on two white shelves." ratio="4/3" loading="eager" />
</Hero>
</div>Heading emphasis
With emphasis, the one phrase between two asterisks ("Build sites that *last*.") is an <em> in the heading. Off by default, so the heading shows as typed. The <em> has no class: its look is the theme's. Every Hero recipe and every section shell takes the same prop.
This preview did not load.
examples/hero/emphasis.astro
---
import HeroSplit from "@astronomic-dev/ui/components/HeroSplit.astro";
// With emphasis, the phrase between the asterisks is an <em>. Without it, the heading shows as typed.
const actions = [
{ label: "Start a project", href: "#start" },
{ label: "See our work", href: "#work" },
];
---
<div class="mx-auto max-w-6xl px-6 py-20">
<HeroSplit
heading="Build sites that *last*."
emphasis
text="Astronomic is a kit of parts for sites that stay clear and fast long after launch."
actions={actions}
/>
</div>