Search documentation v0.8.1

Hero Sections

Present key information to your users

Source ↗️ Report Issue ↗️

Use the Hero component to build visually appealing hero sections that help capture your users attention. They create a strong first impression with bold visuals, typography, and call-to-actions. Use them to highlight key messages, product features, or promotions.

Preview
New releases
Hero section title
Subtitle for hero section
Get Started ->
Banner
How to use Hero sections in Astro
<Hero
heading="Hero section title"
subHeading="Subtitle for hero section"
buttons={[
{ text: 'Get Started ->', theme: 'success' },
{ text: 'Contact', theme: 'secondary', icon: 'info' }
]}
badge={{
rounded: true,
theme: 'outline',
text: 'New releases'
}}
image={{
src: '/img/banner.png',
alt: 'Banner',
width: 500,
height: 250
}}
/>

The above Hero component was created with the following props:

Alternative Layout

The layout of hero sections can be modified using the reverse prop to create an alternative layout:

Hero with reverse layout
New releases
Hero section title
Subtitle for hero section
Banner
<Hero
heading="Hero section title"
subHeading="Subtitle for hero section"
buttons={[ ... ]}
badge={{ ... }}
image={{ ... }}
reverse={true}
/>

API

type HeroProps = {
heading: string
subHeading?: string
buttons?: ({
text: string
icon?: IconProps['type'] | string
} & ButtonProps)[]
badge?: {
text: string
} & BadgeProps | null
image?: {
src: string
alt: string
width: number
height: number
} | null
reverse?: boolean
}
PropPurpose
heading Sets the h1 title for the hero section.
subHeading Sets the h2 title for the hero section.
buttons Sets CTAs under the titles. Pass an array of buttons using the props of the Button component.
badge Sets a badge above the titles. Pass an object using the props of the Badge component.
image Sets a featured image next to your titles and CTA.
reverse Switches the layout of the hero component.

Request improvement for this page