Skip to content

Hero

The Hero component provides a full-width banner section typically used at the top of a webpage to showcase key content or imagery. It’s designed to be eye-catching and to establish the visual identity of the page.

None - this is a CSS-only component.

<div class="hero">
<h1>Welcome to Our Website</h1>
<p>Discover amazing products and services</p>
<button class="button">Learn More</button>
</div>
<div class="hero" style="background-image: url('path/to/image.jpg');">
<h1>Welcome to Our Website</h1>
<p>Discover amazing products and services</p>
<button class="button">Learn More</button>
</div>
<div class="hero" style="--hero-background: #2196F3; --hero-color: #ffffff;">
<h1>Welcome to Our Website</h1>
<p>Discover amazing products and services</p>
<button class="button">Learn More</button>
</div>
  • Full-width banner section for highlighting important content
  • Support for background images
  • Responsive padding that adjusts to screen size
  • Customizable through CSS variables
  • Simple implementation with minimal markup
VariableDefault (Light)Dark ModeDescription
--hero-background#ffffff#1e1f22Background color of the hero section
--hero-color#191919#dbdfe7Text color of the hero section
/* Custom styling for a specific hero section */
.custom-hero {
--hero-background: linear-gradient(135deg, #667eea, #764ba2);
--hero-color: #ffffff;
}
  • .hero - The main container class that applies all the hero styling

The Hero component has the following responsive behavior:

Screen SizePadding
Mobile (< 768px)40px 20px
Desktop (≥ 768px)160px 80px

The Hero component supports various background options:

  • Solid color (using the --hero-background variable)
  • Background image (using the background-image property)
  • Gradient (using the --hero-background variable with a CSS gradient)

When using a background image, the component automatically sets:

  • background-position: center
  • background-repeat: no-repeat
  • background-size: cover
  • Website homepage banner
  • Section introductions
  • Call-to-action areas
  • Product showcases
  • Event announcements