Skip to content

Hero

A section component for page heroes supporting center, split, and overlay layouts. Text slots accept plain strings or snippets; in the overlay layout, media becomes the full-bleed background.

Import

import { Hero } from "@hyzer-labs/ui"

Demo

Hero is headless. The dashed outline below is docs scaffolding, so you can see its bounds.

What's new

Headless components for Svelte 5

Ships behavior, structure, and accessibility, not visual opinions.
<Hero
	eyebrow="What's new"
	title="Headless components for Svelte 5"
	subtitle="Ships behavior, structure, and accessibility, not visual opinions."
	headingLevel={2}
>
	{#snippet actions()}
		<Button>Get started</Button>
		<Button variant="outline">Learn more</Button>
	{/snippet}
</Hero>

Props

NameTypeDefaultNote
layout'center' | 'split' | 'overlay''center'
height'auto' | 'screen' | 'half''auto'
align'start' | 'center' | 'end''center'
reverseOnMobilebooleanfalseSplit layout only: media renders above content while the split is stacked.
headingLevel1 | 2 | 3 | 4 | 5 | 61
ariaLabelstringAccessible name when no title is provided.
classstringMerged after the hz-hero class.
eyebrowstring | SnippetString for plain text; snippet for inner markup.
titlestring | Snippet
subtitlestring | Snippet
actionsSnippet
mediaSnippetBeside/below content in center/split; becomes the background in overlay.

Theme hooks

What this component promises your CSS. The reference theme styles exactly these — from @layer hz-theme, so your unlayered rules win. See Styling Components for the how.

Root class: .hz-hero

Data attributes

HookValuesStyles
data-layout'center' | 'split' | 'overlay'In overlay the media becomes the background. split composes Split underneath, so .hz-split-layout is in reach. Default center.
data-height'auto' | 'screen' | 'half'Uses dvh where supported. Default auto.
data-align'start' | 'center' | 'end'Default center.
data-reverse-on-mobilepresent when reversedSplit layout only: wraps the media above the content on narrow screens.

Part classes

HookValuesStyles
.hz-hero-backgroundchild elementThe full-bleed media, overlay layout only.
.hz-hero-contentchild elementThe text column.
.hz-hero-eyebrowchild elementThe eyebrow line.
.hz-hero-titlechild elementThe heading, at your headingLevel.
.hz-hero-subtitlechild elementThe subtitle, capped at 60ch.
.hz-hero-actionschild elementThe actions row.
.hz-hero-mediachild elementThe media wrapper in center and split layouts.

Accessibility

Hero renders a <section> with aria-labelledby pointing at the title element, or aria-label when there is no title. Use headingLevel to keep your page's heading hierarchy correct. If the page already has an h1, hero titles inside it are usually level 2.