Marketing sectionsHeroCentered
Searchastronomic.dev# HeroCentered
At the top of a page, for the main heading, one line on what you offer and one or two actions, centered, with an optional wide image under them.
Static: no JavaScript.
## Usage
```astro
import HeroCentered from "@astronomic-dev/ui/components/HeroCentered.astro";
```
## Examples
### Studio home page
With no image, the text alone, centered.
```astro
---
import Badge from "@astronomic-dev/ui/components/Badge.astro";
import HeroCentered from "@astronomic-dev/ui/components/HeroCentered.astro";
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">
<HeroCentered
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}
>
<Badge slot="eyebrow" status="positive">Taking new projects</Badge>
</HeroCentered>
</div>
```
### With an image
The image under the text, at the full hero width: 4/3 on a narrow hero, 16/9 from 28rem.
```astro
---
import HeroCentered from "@astronomic-dev/ui/components/HeroCentered.astro";
// Your own image file.
import desk from "../../photos/studio-desk.webp";
const actions = [
{ label: "See our work", href: "#work" },
{ label: "Book a call", href: "#call" },
];
---
<div class="mx-auto max-w-6xl px-6 py-20">
<HeroCentered
heading="Design that holds up after launch."
text="A small studio for brands that would rather be clear than loud."
actions={actions}
image={{ src: desk, alt: "A laptop, a framed print and a cactus on a light wood desk." }}
/>
</div>
```
## Props
### HeroCentered
| 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, in a centered row. 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 | An image under the text, at the full hero width, at every width. MediaImage is { src, alt, width?, height?, ratio?, loading?, focalPoint? }; with no ratio it is 4/3 on a hero narrower than 28rem and 16/9 from there (a ratio you set wins at every width), and loading defaults to eager. |
| `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. It is centered. |
| `media` | Your own image element in place of image, for example an Astro <Image>. It wins over image. |
| `default` | More content under the actions. It is centered (it inherits text-center) and capped at the 52rem reading width, so a LogoStrip there is narrower than the image under it. Center its own layout yourself. |
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.
- Actions are links that look like buttons. Give each a label that says where it goes.
- Centered text is harder to read in long lines, so the text stays at a reading width; keep the subtitle to one or two sentences.
- The image comes after the text in the page order, so a screen reader reads the heading first. It needs alt like any Media; set alt="" when it adds nothing to the heading.
- The <em> is read as part of the heading. Use plainHeading() (lib/emphasis.ts) for the page <title>.
HeroCentered
FreeAt the top of a page, for the main heading, one line on what you offer and one or two actions, centered, with an optional wide image under them.
- File
- HeroCentered.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
Studio home page
With no image, the text alone, centered.
This preview did not load.
main.astro
examples/herocentered/main.astro
---
import Badge from "@astronomic-dev/ui/components/Badge.astro";
import HeroCentered from "@astronomic-dev/ui/components/HeroCentered.astro";
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">
<HeroCentered
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}
>
<Badge slot="eyebrow" status="positive">Taking new projects</Badge>
</HeroCentered>
</div>With an image
The image under the text, at the full hero width: 4/3 on a narrow hero, 16/9 from 28rem.
This preview did not load.
image.astro
examples/herocentered/image.astro
---
import HeroCentered from "@astronomic-dev/ui/components/HeroCentered.astro";
// Your own image file.
import desk from "../../photos/studio-desk.webp";
const actions = [
{ label: "See our work", href: "#work" },
{ label: "Book a call", href: "#call" },
];
---
<div class="mx-auto max-w-6xl px-6 py-20">
<HeroCentered
heading="Design that holds up after launch."
text="A small studio for brands that would rather be clear than loud."
actions={actions}
image={{ src: desk, alt: "A laptop, a framed print and a cactus on a light wood desk." }}
/>
</div>Minimal · Light