🚀 Ship faster with premium components 🚀
Search documentation v1.1.0

Hero

Present key information to your users

Source Report Issue
How to add this block to your project
npm create webcore@latest add Hero

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 ->
AvatarAvatarAvatarAvatarAvatar
★★★★★ 123 students already enrolled
Banner
How to use the Hero component 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'
}}
avatarWithRating={{
avatar: { img: avatarGroup },
rating: { score: 5, color: 'var(--w-color-success)' },
text: '<b>123 students</b> already enrolled'
}}
image={{
src: '/img/banner.png',
alt: 'Banner',
width: 500,
height: 250
}}
/>

Apart from the heading prop, all props are optional to make it possible to create hero sections with a wide range of options. 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

AvatarAvatarAvatar
★★★★★ 123 students already enrolled
Banner
<Hero
heading="Hero section title"
subHeading="Subtitle for hero section"
buttons={[ ... ]}
badge={{ ... }}
image={{ ... }}
avatarWithRating={{ ... }}
reverse={true}
/>

API

type HeroProps = {
badge?: {
text: string
} & BadgeProps | null
heading: string
subHeading?: string
buttons?: ({
text: string
icon?: string
} & ButtonProps)[]
avatarWithRating?: AvatarWithRatingProps
image?: {
src: string
alt: string
width: number
height: number
}
reverse?: boolean
className?: string
}
PropPurpose
badge Sets a badge above the heading. Pass an object using the props of the Badge component.
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.
avatarWithRating Sets avatars with a rating under the CTA buttons.
image Sets a featured image next to your titles and CTA.
reverse Switches the layout of the hero component.
className Pass additional CSS classes for the Hero component.