Heroes
Responsive hero sections and layouts for websites, applications and landing pages.
Heroes
Heroes are introductory sections that establish the visual identity of a page.
Puzzle Pieces provides a flexible Hero component and a collection of specialized presets. All presets share the same underlying implementation, making them easy to customize without maintaining separate layouts.
Installation
Import the Hero components from Puzzle Pieces:
import {
Hero,
SplitHero,
CenteredHero,
FullScreenHero,
ImageHero,
VideoHero,
} from "@puzzle-ui/pieces";Components
| Component | Description |
|---|---|
| Hero | Generic hero component |
| SplitHero | Text and media side by side |
| CenteredHero | Centered introduction |
| FullScreenHero | Full viewport introduction |
| VideoHero | Background video |
| ImageHero | Background image with overlay |
| MinimalHero | Minimal introduction |
| EditorialHero | Editorial layout |
| AgencyHero | Agency and consultancy websites |
| ProductHero | Product introductions |
| SaaSHero | SaaS product websites |
| StoreHero | Online stores and collections |
| RestaurantHero | Restaurants and hospitality |
| AccommodationHero | Hotels and holiday accommodation |
| PrintShopHero | Printing businesses |
| DashboardWelcomeHero | Dashboard introductions |
| AppHero | Web application introductions |
| CampaignHero | Campaign landing pages |
| ComingSoonHero | Pre-launch pages |
| SearchHero | Search-oriented websites |
Basic usage
Use Hero for complete control over the layout and content.
Layouts
The Hero component supports four layout configurations.
Split
Text and media are displayed in separate columns.
Centered
Content is centered horizontally.
Full width
The inner container uses the full available width.
Asymmetric
The media and content columns use different proportions.
Media positioning
Control where media is displayed using mediaPosition.
| Value | Description |
|---|---|
| left | Media before content |
| right | Media after content |
| background | Media behind content |
Background media can also be supplied directly.
Height
Control the minimum height of the hero.
| Value | Description |
|---|---|
| auto | Content determines the height |
| large | Large introductory section |
| viewport | Minimum height of the viewport |
Themes
Hero supports four theme configurations.
| Value | Description |
|---|---|
| light | Standard light appearance |
| dark | Dark appearance |
| contrast | Contrasting surface appearance |
| brand | Primary brand appearance |
Hero consumes semantic Puzzle Theme tokens for its background, foreground, typography and spacing.
Overlays
Overlays improve text readability when using background media.
| Value | Description |
|---|---|
| none | No overlay |
| subtle | Subtle overlay |
| strong | Strong overlay |
| gradient | Directional gradient |
Content
Hero supports several content slots.
Eyebrow
A short introductory label above the heading.
Description
Additional introductory text.
Actions
Use existing Puzzle UI components for buttons and other actions.
Search
The search slot can contain any existing Puzzle form components.
Meta
Use meta for supplementary information such as availability, opening hours or product details.
Children
Additional content can be placed between the description and the action slots.
Responsive behavior
Hero automatically adapts its layout to smaller screens.
- Split layouts become single-column layouts.
- Asymmetric layouts become single-column layouts.
- Media can move before content on mobile.
- Typography uses responsive sizing.
- Horizontal and vertical spacing adapt to available screen space.
Use reverseOnMobile to control the order of content and media.
Disable reversal when the content should remain before the media.
Specialized presets
Presets provide sensible defaults for common website types.
All presets inherit the properties of Hero and can be customized.
SplitHero
CenteredHero
FullScreenHero
VideoHero
Background videos are muted, loop automatically and respect the user's reduced-motion preference.
ImageHero
MinimalHero
EditorialHero
AgencyHero
ProductHero
SaaSHero
StoreHero
RestaurantHero
AccommodationHero
PrintShopHero
DashboardWelcomeHero
AppHero
CampaignHero
ComingSoonHero
SearchHero
Customization
All presets inherit the full Hero API.
For example, an AccommodationHero can use a split layout instead of its default background layout.
CSS customization
Hero uses regular CSS and semantic Puzzle Theme tokens.
The root element has the puzzle-hero class.
You can customize its appearance through CSS variables.
.custom-hero {
--puzzle-hero-padding-inline: var(--puzzle-space-8);
--puzzle-hero-padding-block: var(--puzzle-space-16);
--puzzle-hero-gap: var(--puzzle-space-10);
--puzzle-hero-background: var(--puzzle-color-surface);
--puzzle-hero-foreground: var(--puzzle-color-text);
}You can also target individual elements using their class names.
| Class | Element |
|---|---|
| puzzle-hero | Root element |
| puzzle-hero__inner | Layout container |
| puzzle-hero__content | Content container |
| puzzle-hero__title | Main heading |
| puzzle-hero__description | Description |
| puzzle-hero__eyebrow | Eyebrow |
| puzzle-hero__media | Media container |
| puzzle-hero__background | Background container |
| puzzle-hero__overlay | Background overlay |
| puzzle-hero__actions | Action container |
| puzzle-hero__search | Search container |
| puzzle-hero__meta | Supplementary information |
Accessibility
Hero is designed to work with assistive technologies.
- Uses semantic section elements by default.
- Supports custom semantic elements through the as property.
- Supports configurable heading levels through titleAs.
- Supports accessible labels.
- Decorative background images have empty alternative text.
- Background videos are hidden from assistive technology.
- Background videos respect prefers-reduced-motion.
- Interactive content remains accessible through its original Puzzle components.
Always provide meaningful alternative text for informative images.
Use one primary heading per page where appropriate.
API reference
Hero properties
| Property | Type | Default |
|---|---|---|
| as | ElementType | section |
| titleAs | ElementType | h1 |
| id | string | - |
| testId | string | - |
| className | string | - |
| contentClassName | string | - |
| mediaClassName | string | - |
| style | CSSProperties | - |
| layout | HeroLayout | split |
| mediaPosition | HeroMediaPosition | right |
| alignment | HeroAlignment | start |
| height | HeroHeight | auto |
| theme | HeroTheme | light |
| overlay | HeroOverlay | none |
| contentWidth | HeroContentWidth | normal |
| reverseOnMobile | boolean | true |
| eyebrow | ReactNode | - |
| title | ReactNode | - |
| description | ReactNode | - |
| media | ReactNode | - |
| backgroundImage | string | - |
| backgroundVideo | HeroVideoSource | - |
| actions | ReactNode | - |
| search | ReactNode | - |
| meta | ReactNode | - |
| children | ReactNode | - |
| role | AriaRole | - |
| ariaLabel | string | - |
| ariaLabelledBy | string | - |
HeroLayout
type HeroLayout = "centered" | "split" | "full-width" | "asymmetric";HeroMediaPosition
type HeroMediaPosition = "left" | "right" | "background";HeroAlignment
type HeroAlignment = "start" | "center" | "end";HeroHeight
type HeroHeight = "auto" | "large" | "viewport";HeroTheme
type HeroTheme = "light" | "dark" | "contrast" | "brand";HeroOverlay
type HeroOverlay = "none" | "subtle" | "strong" | "gradient";HeroContentWidth
type HeroContentWidth = "narrow" | "normal" | "wide" | "full";HeroVideoSource
type HeroVideoSource = {
src: string;
type?: string;
poster?: string;
};