Composite
Hero
The opening section of a page: copy centered or beside an image or video.
Hero renders its title as an h1 by default, because it opens the page. The examples below pass headline.htmlTag: 'h2' only because this page already has its own h1. Leave it out when Hero is the first block.
Centered
Hero
Build pages from blocks
Copy and actions centered in a full-width section.
---
import Hero from '@alfadormx/blocks/composite/Hero.astro';
import type { ButtonProps } from '@alfadormx/blocks/types/button';
const actions: ButtonProps[] = [
{
label: 'Get started',
intent: 'primary',
icon: { name: 'heroicons:arrow-right' },
iconPosition: 'right',
},
{ label: 'View source', intent: 'secondary', variant: 'outline' },
];
const defaultActionConfig = { size: 'lg', shape: 'pill', variant: 'solid' } as const;
---
<Hero
headline={{
tagline: 'Hero',
title: 'Build pages from blocks',
subtitle: 'Copy and actions centered in a full-width section.',
htmlTag: 'h2',
}}
defaultActionConfig={defaultActionConfig}
actions={actions}
/>Background video
container.background puts an image or video behind centered copy, with a bg-base/60 overlay by default. container.minHeight sets the height. A video gets a pause/play button and stays paused under reduced motion.
Hero
Copy over motion
A full-bleed background video with an overlay for contrast.
---
import Hero from '@alfadormx/blocks/composite/Hero.astro';
import type { ButtonProps } from '@alfadormx/blocks/types/button';
const actions: ButtonProps[] = [
{
label: 'Get started',
intent: 'primary',
icon: { name: 'heroicons:arrow-right' },
iconPosition: 'right',
},
{ label: 'View source', intent: 'secondary', variant: 'outline' },
];
const defaultActionConfig = { size: 'lg', shape: 'pill', variant: 'solid' } as const;
---
<Hero
container={{
minHeight: 'min-h-[80vh]',
background: {
video: [
{ src: '/videos/demos/jewellery/hero.webm', type: 'video/webm' },
{ src: '/videos/demos/jewellery/hero.mp4', type: 'video/mp4' },
],
},
}}
headline={{
tagline: 'Hero',
title: 'Copy over motion',
subtitle: 'A full-bleed background video with an overlay for contrast.',
htmlTag: 'h2',
}}
defaultActionConfig={defaultActionConfig}
actions={actions}
/>Split, media on the right
layout: 'split' puts the copy beside media: set image or video. On small screens the copy stacks above the media.
Hero
Copy beside an image
The image loads eagerly with high fetch priority, since it is usually the largest paint.
---
import Hero from '@alfadormx/blocks/composite/Hero.astro';
import type { ButtonProps } from '@alfadormx/blocks/types/button';
const actions: ButtonProps[] = [
{
label: 'Get started',
intent: 'primary',
icon: { name: 'heroicons:arrow-right' },
iconPosition: 'right',
},
{ label: 'View source', intent: 'secondary', variant: 'outline' },
];
const defaultActionConfig = { size: 'lg', shape: 'pill', variant: 'solid' } as const;
---
<Hero
layout="split"
image={{
src: 'https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=800&h=600&fit=min&auto=format',
alt: 'Mountain peaks above the clouds',
}}
headline={{
tagline: 'Hero',
title: 'Copy beside an image',
subtitle:
'The image loads eagerly with high fetch priority, since it is usually the largest paint.',
htmlTag: 'h2',
}}
defaultActionConfig={defaultActionConfig}
actions={actions}
/>Split, media on the left
mediaPosition: 'left' moves the media to the left column from the md breakpoint up. twoColumnContainer sets the ratio and gap.
Hero
Copy beside a video
Any Video source works: html5, YouTube or Vimeo.
---
import Hero from '@alfadormx/blocks/composite/Hero.astro';
import type { ButtonProps } from '@alfadormx/blocks/types/button';
const actions: ButtonProps[] = [
{
label: 'Get started',
intent: 'primary',
icon: { name: 'heroicons:arrow-right' },
iconPosition: 'right',
},
{ label: 'View source', intent: 'secondary', variant: 'outline' },
];
const defaultActionConfig = { size: 'lg', shape: 'pill', variant: 'solid' } as const;
---
<Hero
layout="split"
mediaPosition="left"
twoColumnContainer={{ ratio: '3:2' }}
video={{
source: {
provider: 'html5',
sources: [
{ src: '/videos/flower.webm', type: 'video/webm' },
{ src: '/videos/flower.mp4', type: 'video/mp4' },
],
},
}}
headline={{
tagline: 'Hero',
title: 'Copy beside a video',
subtitle: 'Any Video source works: html5, YouTube or Vimeo.',
htmlTag: 'h2',
}}
defaultActionConfig={defaultActionConfig}
actions={actions}
/>API Reference
| Prop | Type | Default | Description |
|---|---|---|---|
| layout | 'centered' | 'split' | 'centered' | How copy and media are arranged: copy alone (with an optional `container.background`) or beside media (default: 'centered') |
| mediaPosition | 'left' | 'right' | 'right' | Side the media column sits on in `split`; on small screens the copy always comes first (default: 'right') |
| image | ImageProps | — | Image shown beside the copy; `split` only, and not together with `video` |
| video | VideoProps | — | Video shown beside the copy; `split` only, and not together with `image` |
| container | ContainerProps | — | Configuration for the outer Container; set `background` for a full-bleed image or video and `minHeight` for height (e.g. 'min-h-[80vh]') |
| twoColumnContainer | Omit<TwoColumnContainerProps, 'responsive' | 'reverseOnMobile'> | — | Configuration for the TwoColumnContainer holding copy and media; `split` only. `responsive` and `reverseOnMobile` are set by Hero |
| headline | HeadlineProps | — | Headline rendered above the actions (default: { htmlTag: 'h1', align: 'center' in centered, 'left' in split }) |
| actions | ButtonProps[] | [] | Button configs rendered as the hero actions |
| defaultActionConfig | LayerConfig<ButtonProps> | — | Button config merged under every entry in `actions` |
| actionsClass | string | — | Custom classes for the wrapper around the action buttons (default: 'flex flex-col md:flex-row gap-4', plus 'justify-center' in centered or 'justify-start' in split) |