Directory
- Welcome
Hero Section
The Hero section component creates visually striking page headers with support for background images, breadcrumb navigation, and flexible content layouts. Perfect for landing pages, article headers, and key content sections.
Overview
Hero sections are designed to be:
- Impactful: Full-width design with optional background images
- Flexible: Supports various content types and layouts
- Responsive: Adapts seamlessly across all device sizes
- Accessible: Built with semantic HTML and proper image handling
Basic Usage
<Hero> Welcome to Our Site <Fragment slot="subtitle"> Discover amazing content and features </Fragment></Hero>
Features
Background Images
Add visual impact with optimized background images:
<Hero image={{ file: import('@/assets/images/hero.jpg'), alt: 'Mountain landscape', quality: 'high', class: 'bg-gradient-to-b from-primary/20', }}> Featured Content</Hero>
Breadcrumb Navigation
Enable contextual navigation with built-in breadcrumbs:
<Hero pathname="/docs/components/hero" breadcrumb={{ show: true, showHome: true, removePaths: ['docs'], }}> Documentation</Hero>
Publication Dates
Display timestamps for content:
<Hero date={new Date('2024-03-01')}> Latest Updates </Hero>
Props API
Prop | Type | Default | Description |
---|---|---|---|
image | { file: ImageMetadata, alt: string, quality?: 'low' | 'max' | 'mid' | 'high', class?: string } | undefined | Background image configuration |
pathname | string | undefined | Current page path for breadcrumbs |
date | Date | undefined | Publication date to display |
breadcrumb | { show: boolean, removePaths?: string[], showHome?: boolean } | { show: true, showHome: true } | Breadcrumb navigation options |
Slots
Slot | Description |
---|---|
default | Main heading content |
subtitle | Secondary text below the heading |
Image Optimization
The Hero component automatically handles image optimization with:
- Responsive image sizes
- Lazy loading
- Multiple width variants
- Quality presets
- Priority loading for above-the-fold content
Best Practices
-
Content Guidelines
- Keep headings concise and impactful
- Use subtitles to provide context
- Ensure text remains readable over background images
- Maintain consistent tone across hero sections
-
Image Usage
- Optimize images for web performance
- Choose images that don’t interfere with text readability
- Consider mobile viewing experience
- Use appropriate quality settings for your needs
-
Layout Considerations
- Maintain adequate spacing around content
- Ensure proper contrast for text
- Consider viewport heights on different devices
- Test breadcrumb visibility with different backgrounds
Common Applications
- Landing page headers
- Article introductions
- Section breaks
- Feature showcases
- Product presentations
- Category headers
- Portfolio items
- Blog post headers
Responsive Behavior
The Hero section automatically adjusts:
- Font sizes across breakpoints
- Padding and margins
- Image scaling and cropping
- Content layout and spacing
Related Components
- Banner - For announcements and notifications
- Header - For site-wide navigation
- Card - For featured content blocks
- Image - For standalone image display
Limited Time Launch Sale
Create stunning page headers with our pre-built Hero component. Get the AstroJS starter template now and make your content stand out.
GET 60% OFF!