Skip to content

HeroX

Learn how to use the HeroX component to create compelling hero sections with background images, flexible positioning, and responsive behavior.

The HeroX component is a custom hero component designed specifically for the Six theme, providing enhanced styling and functionality for creating compelling landing page heroes. It offers full control over image dimensions, background images, content positioning, and responsive behavior with automatic title and tagline integration from frontmatter.


Prop NameProp TypeDescriptionDefault
titlestringCustom title (overrides frontmatter)Frontmatter title
taglinestringCustom tagline (overrides frontmatter)Frontmatter description
titleColorstringColor for title textvar(--foreground-light)
taglineColorstringColor for tagline textvar(--muted-foreground)
gapnumber | stringVertical spacing between title and tagline"0.25rem"
heightnumber | stringHeight of hero containerauto (standard), "60vh" (background)
pxnumber | stringHorizontal padding"2rem"
pynumber | stringVertical padding"2rem"
mtstringMargin-top (px, rem, em, vh, etc.)-
mbstringMargin-bottom (px, rem, em, vh, etc.)-
radiusstringBorder radius (px, rem, em, etc.)-
imageobjectImage configuration object-
actionsarrayArray of action button objects-

The HeroX component automatically pulls title and description from your page’s frontmatter when used with template: splash.

---
title: My Page Title
description: A compelling description of your project
template: splash
---
import { HeroX } from '@six-tech/starlight-theme-six/components'
<HeroX />
Welcome
Build amazing documentation sites with Starlight
<HeroX
title="Custom Hero Title"
tagline="This overrides the frontmatter description"
/>
Custom Hero Title
This overrides the frontmatter description

The HeroX component supports custom margin control to create proper spacing between components.

<HeroX
title="Hero with Custom Margins"
tagline="Proper spacing from surrounding elements"
mt="2rem"
mb="3rem"
/>
<HeroX
title="Background Hero with Margins"
tagline="Spaced from other page elements"
height="400px"
mt="4rem"
mb="2rem"
image={{
background: heroImage,
backgroundSize: "cover",
contentPosition: "middle-center"
}}
/>
Background Hero with Margins
Spaced from other page elements

The HeroX component supports custom border radius for rounded corners on the content container.

<HeroX
title="Hero with Rounded Corners"
tagline="Content with custom border radius"
radius="1rem"
/>
<HeroX
title="Background Hero with Radius"
tagline="Rounded corners on background hero"
height="400px"
radius="2rem"
image={{
background: heroImage,
backgroundSize: "cover",
contentPosition: "middle-center"
}}
/>
Background Hero with Radius
Rounded corners on background hero

For regular image display (non-background):

<HeroX
image={{
file: heroImage,
alt: "Hero image description",
width: "1920px",
height: "640px"
}}
/>

For background images with overlay content:

<HeroX
height="100vh"
px="4rem"
py="3rem"
image={{
background: heroImage,
alt: "Hero background image",
backgroundSize: "cover",
backgroundPosition: "center",
backgroundRepeat: "no-repeat",
contentPosition: "middle-left"
}}
/>

For comprehensive theme and device support:

import backgroundDesktopLight from '../../assets/hero-desktop-light.jpg'
import backgroundDesktopDark from '../../assets/hero-desktop-dark.jpg'
import backgroundMobileLight from '../../assets/hero-mobile-light.jpg'
import backgroundMobileDark from '../../assets/hero-mobile-dark.jpg'
<HeroX
height="80vh"
px="2rem"
py="2rem"
image={{
background: backgroundDesktopLight,
backgroundLight: backgroundDesktopLight,
backgroundDark: backgroundDesktopDark,
backgroundMobileLight: backgroundMobileLight,
backgroundMobileDark: backgroundMobileDark,
alt: "Responsive hero background",
backgroundSize: "cover",
contentPosition: "bottom-right"
}}
/>

When using background images, you can position content using these presets:

LeftCenterRight
top-lefttop-centertop-right
middle-leftmiddle-centermiddle-right
bottom-leftbottom-centerbottom-right
  • top-left - Top-left corner with left-aligned text
  • top-center - Top center with center-aligned text
  • top-right - Top-right corner with right-aligned text
  • middle-left - Vertical center, left aligned
  • middle-center - Perfect center (default)
  • middle-right - Vertical center, right aligned
  • bottom-left - Bottom-left corner with left-aligned text
  • bottom-center - Bottom center with center-aligned text
  • bottom-right - Bottom-right corner with right-aligned text
<HeroX
title="Background Hero"
tagline="Content positioned in the center"
titleColor="#ffffff"
taglineColor="#e2e8f0"
height="400px"
image={{
background: heroImage,
backgroundSize: "cover",
contentPosition: "middle-center"
}}
/>
Background Hero
Content positioned in the center
<HeroX
title="Bottom Right Hero"
tagline="Content positioned in bottom-right corner"
titleColor="#fbbf24"
taglineColor="#f3f4f6"
height="400px"
px="3rem"
py="2rem"
image={{
background: heroImage,
backgroundSize: "cover",
contentPosition: "bottom-right"
}}
/>
Bottom Right Hero
Content positioned in bottom-right corner

Add action buttons to guide users to key pages or features.

<HeroX
title="Hero with Actions"
tagline="Get started with your documentation"
actions={[
{
text: "Get Started",
link: "/getting-started/"
},
{
text: "View Examples",
link: "/examples/",
variant: "minimal"
}
]}
/>
<HeroX
title="Hero with Actions"
tagline="Demonstrating action buttons with background positioning"
titleColor="#10b981"
taglineColor="#d1fae5"
height="350px"
px="4rem"
py="3rem"
image={{
background: heroImage,
backgroundSize: "cover",
contentPosition: "middle-left"
}}
actions={[
{
text: "Primary Action",
link: "#"
},
{
text: "Secondary",
link: "#",
variant: "minimal"
}
]}
/>
Hero with Actions
Demonstrating action buttons with background positioning

Customize title and tagline colors for better contrast:

<HeroX
title="Colorful Hero"
tagline="Custom colors for better visibility"
titleColor="#3b82f6"
taglineColor="#64748b"
/>
Colorful Hero
Custom colors for better visibility
---
title: My Documentation
description: Comprehensive guide to building with our platform
template: splash
editUrl: false
---
<HeroX
height="80vh"
px="3rem"
py="2rem"
mt="2rem"
mb="4rem"
radius="1.5rem"
titleColor="#ffffff"
taglineColor="#e2e8f0"
image={{
background: heroImage,
alt: "Hero background image",
backgroundSize: "cover",
backgroundPosition: "center",
contentPosition: "bottom-left"
}}
actions={[
{
text: "Get Started",
link: "/getting-started/"
},
{
text: "View Examples",
link: "/examples/",
variant: "minimal"
}
]}
/>

The component uses intelligent fallback for responsive images:

  1. Mobile Light: backgroundMobileLightbackgroundMobilebackgroundLightbackground
  2. Mobile Dark: backgroundMobileDarkbackgroundMobilebackgroundDarkbackground
  3. Desktop Light: backgroundLightbackground
  4. Desktop Dark: backgroundDarkbackground
  5. Fallback: background (required)

---
title: Your Page Title
description: Your page description
template: splash
editUrl: false
---
import { HeroX } from '@six-tech/starlight-theme-six/components'
import heroImage from '../../assets/your-image.png'
<HeroX
height="80vh"
px="3rem"
py="2rem"
mt="1rem"
mb="2rem"
radius="1rem"
image={{
background: heroImage,
contentPosition: "bottom-left",
backgroundSize: "cover"
}}
actions={[
{
text: "Get Started",
link: "/getting-started/"
}
]}
/>
PropertyTypeDescription
textstringButton label text
linkstringURL or internal path
variant'primary' | 'minimal'Button style variant
attrsRecord<string, any>Additional HTML attributes
icon{ html?: string }Icon HTML content

  • Use template: splash in frontmatter to prevent title duplication
  • Choose appropriate content positioning based on your background image
  • Test color contrast for accessibility with custom colors
  • Use semantic action button text that clearly describes the destination
  • Consider mobile responsiveness when setting heights and padding
  • Provide meaningful alt text for background images
  • Test different screen sizes to ensure content remains readable
  • Use margin props (mt, mb) to create proper spacing between components
  • Consider the relationship between padding (px, py) and margins (mt, mb) for optimal spacing
  • Use radius prop for subtle rounded corners that enhance visual appeal
  • Test radius values on different screen sizes to ensure consistent appearance

  • Don’t use extremely tall hero sections - Consider user experience and content below the fold
  • Don’t use low-contrast color combinations - Ensure text is readable against backgrounds
  • Don’t forget alt text for images - Important for accessibility and SEO
  • Don’t use too many action buttons - Keep it focused with 1-3 primary actions
  • Don’t ignore mobile experience - Test on smaller screens and adjust accordingly
  • Don’t use background images without proper fallbacks - Provide appropriate fallback colors or images
  • Don’t position content where it might be cut off - Consider safe areas for text placement
  • Don’t confuse padding with margins - Padding controls internal spacing, margins control external spacing
  • Don’t use extremely large radius values - Very large radius can create awkward visual shapes