Overview
TheHero component is a header section used to display prominent titles and taglines at the top of pages. It supports customizable text alignment, optional taglines, and slot content for additional elements. The component includes view transitions for smooth page navigations.
Props
The main heading text displayed prominently in the hero section.
Optional descriptive text displayed below the title. Use this to provide additional context or a subtitle.
Controls the text alignment of the hero section. On larger screens (50em+),
'start' aligns content to the left, while 'center' keeps it centered.Optional identifier used for Astro view transitions. Links the hero title animation between pages.
Usage
Basic Hero
Hero with Left Alignment
Hero with Slot Content
Hero with View Transitions
Real-World Examples
This component is used throughout Juan Roccia’s portfolio: Homepage (src/pages/index.astro):
src/pages/work/[...slug].astro):
Styling Features
- Responsive font sizing that scales from mobile to desktop
- Maximum width constraint for optimal readability (37ch)
- Automatic centering on mobile devices
- Smooth view transitions between pages using
transition:name - CSS custom properties for consistent theming
Accessibility
- Uses semantic
<header>element - Proper heading hierarchy with
<h1>for titles - Respects user motion preferences through Astro’s built-in transitions