Expanding Hero

Scroll Video Hero for React

A headline with a small video set between its words. As you scroll, the window opens until it fills the screen, pushing the words off its edges.

  • Hero
  • Scroll
  • Video

Uses motion, clsx, tailwind-merge

Open in ChatGPTOpen in Claude
scrollLength2.0
zoom1.15×
stiffness120
damping30
<ExpandingHero />

The demo follows as you drag.

Take this demo to your coding agent.
Add this moment from KeyframeUI to our project and adapt it to our content.

Expanding Hero: A headline with a small video set between its words. As you scroll, the window opens until it fills the screen, pushing the words off its edges.
This demo, Studio Reel: A motion studio's showreel opens out of the headline. Once it fills the box, a button plays the film full screen.

1. Install it:
   npx shadcn@latest add @keyframeui/expanding-hero-demo
   (If the CLI can't find @keyframeui, use https://keyframeui.com/r/expanding-hero-demo.json instead.)
   It adds the demo, components/expanding-hero-demo.tsx, and the component, components/ui/expanding-hero.tsx.

2. Make it ours: our copy, data, images and colors. Keep the structure the motion depends on. If we only need the effect, use <ExpandingHero> on its own.

3. These props set its feel. Change them before you change the file:
   - scrollLength (default 2): How long the section stays pinned, in stage heights. The window opens over the first 78%; the overlay fades in over the rest. Much longer than 2 starts to feel like the page has taken over the scroll.
   - zoom (default 1.15): Scale of the media at the start. It settles to 1 as the window opens.
   - stiffness (default 120): Stiffness of the spring that smooths scrolling. Higher catches up with the scroll faster.
   - damping (default 30): Damping of the spring that smooths scrolling. Lower lets the window overshoot and swing back.

4. Don't change, in components/ui/expanding-hero.tsx:
   - The media never resizes: it always covers the stage, and the window is an `inset()` `clip-path` over it. Only that clip, the media's scale and the pieces' transforms and opacity move.
   - One spring-smoothed scroll progress drives everything through motion values, so scrolling never re-renders; the stage is `sticky` over a runway `scrollLength` stage heights tall.
   - The window starts where its placeholder span sits in the headline, re-measured by a `ResizeObserver`, and the media stays at opacity 0 until that first measure places it.
   - Each half rides the window edge it touches: pushed sideways when `beside()` finds it on the window's line, up or down when it's stacked.
   - Reduced motion renders `StillHero`, which pins nothing. The flag reads false on the server and while hydrating, so the markup always matches.
   Its timing is all in the TIMING block at the top of that file.

Docs: https://keyframeui.com/components/expanding-hero.md

Installation

Add the component on its own with the CLI, or copy the file in by hand.

The CLI writes components/ui/expanding-hero.tsx and installs motion, clsx and tailwind-merge. It needs the @keyframeui registry in components.json; add it once per project.

npx shadcn@latest add @keyframeui/expanding-hero

Examples

Finished sections built with Expanding Hero. Each one installs whole, with the component included.

Product Launch

An app screenshot instead of a video, built in markup so it stays sharp full screen. A "Watch the demo" button appears once it fills the box.

Take this demo to your coding agent.
Add this moment from KeyframeUI to our project and adapt it to our content.

Expanding Hero: A headline with a small video set between its words. As you scroll, the window opens until it fills the screen, pushing the words off its edges.
This demo, Product Launch: An app screenshot instead of a video, built in markup so it stays sharp full screen. A "Watch the demo" button appears once it fills the box.

1. Install it:
   npx shadcn@latest add @keyframeui/expanding-hero-product-demo
   (If the CLI can't find @keyframeui, use https://keyframeui.com/r/expanding-hero-product-demo.json instead.)
   It adds the demo, components/expanding-hero-product-demo.tsx, and the component, components/ui/expanding-hero.tsx.

2. Make it ours: our copy, data, images and colors. Keep the structure the motion depends on. If we only need the effect, use <ExpandingHero> on its own.

3. These props set its feel. Change them before you change the file:
   - scrollLength (default 2): How long the section stays pinned, in stage heights. The window opens over the first 78%; the overlay fades in over the rest. Much longer than 2 starts to feel like the page has taken over the scroll.
   - zoom (default 1.15): Scale of the media at the start. It settles to 1 as the window opens.
   - stiffness (default 120): Stiffness of the spring that smooths scrolling. Higher catches up with the scroll faster.
   - damping (default 30): Damping of the spring that smooths scrolling. Lower lets the window overshoot and swing back.

4. Don't change, in components/ui/expanding-hero.tsx:
   - The media never resizes: it always covers the stage, and the window is an `inset()` `clip-path` over it. Only that clip, the media's scale and the pieces' transforms and opacity move.
   - One spring-smoothed scroll progress drives everything through motion values, so scrolling never re-renders; the stage is `sticky` over a runway `scrollLength` stage heights tall.
   - The window starts where its placeholder span sits in the headline, re-measured by a `ResizeObserver`, and the media stays at opacity 0 until that first measure places it.
   - Each half rides the window edge it touches: pushed sideways when `beside()` finds it on the window's line, up or down when it's stacked.
   - Reduced motion renders `StillHero`, which pins nothing. The flag reads false on the server and while hydrating, so the markup always matches.
   Its timing is all in the TIMING block at the top of that file.

Docs: https://keyframeui.com/components/expanding-hero.md

Event

A conference hero with an aftermovie and a bolder headline. The date and city chips live inside the halves, so they fly off with the words.

Take this demo to your coding agent.
Add this moment from KeyframeUI to our project and adapt it to our content.

Expanding Hero: A headline with a small video set between its words. As you scroll, the window opens until it fills the screen, pushing the words off its edges.
This demo, Event: A conference hero with an aftermovie and a bolder headline. The date and city chips live inside the halves, so they fly off with the words.

1. Install it:
   npx shadcn@latest add @keyframeui/expanding-hero-event-demo
   (If the CLI can't find @keyframeui, use https://keyframeui.com/r/expanding-hero-event-demo.json instead.)
   It adds the demo, components/expanding-hero-event-demo.tsx, and the component, components/ui/expanding-hero.tsx.

2. Make it ours: our copy, data, images and colors. Keep the structure the motion depends on. If we only need the effect, use <ExpandingHero> on its own.

3. These props set its feel. Change them before you change the file:
   - scrollLength (default 2): How long the section stays pinned, in stage heights. The window opens over the first 78%; the overlay fades in over the rest. Much longer than 2 starts to feel like the page has taken over the scroll.
   - zoom (default 1.15): Scale of the media at the start. It settles to 1 as the window opens.
   - stiffness (default 120): Stiffness of the spring that smooths scrolling. Higher catches up with the scroll faster.
   - damping (default 30): Damping of the spring that smooths scrolling. Lower lets the window overshoot and swing back.

4. Don't change, in components/ui/expanding-hero.tsx:
   - The media never resizes: it always covers the stage, and the window is an `inset()` `clip-path` over it. Only that clip, the media's scale and the pieces' transforms and opacity move.
   - One spring-smoothed scroll progress drives everything through motion values, so scrolling never re-renders; the stage is `sticky` over a runway `scrollLength` stage heights tall.
   - The window starts where its placeholder span sits in the headline, re-measured by a `ResizeObserver`, and the media stays at opacity 0 until that first measure places it.
   - Each half rides the window edge it touches: pushed sideways when `beside()` finds it on the window's line, up or down when it's stacked.
   - Reduced motion renders `StillHero`, which pins nothing. The flag reads false on the server and while hydrating, so the markup always matches.
   Its timing is all in the TIMING block at the top of that file.

Docs: https://keyframeui.com/components/expanding-hero.md

Props

before Required

TypeReact.ReactNode

The words before the window. One to three short words read best. Anything attached to them, like a chip, is pushed off with them.

after Required

TypeReact.ReactNode

The words after the window.

media Required

TypeReact.ReactNode

What plays in the window: a video, an image or any element. It always covers the whole stage and never resizes; the window is a mask that opens onto it.

children

TypeReact.ReactNode

Content under the headline, such as a subtitle and a button. It fades out early and rides the window's bottom edge away.

overlay

TypeReact.ReactNode

Shown over the media once it fills the stage, like a play button. Centered; it fades in before the section unpins.

scrollLength

TypenumberDefault2

How long the section stays pinned, in stage heights. The window opens over the first 78%; the overlay fades in over the rest. Much longer than 2 starts to feel like the page has taken over the scroll.

zoom

TypenumberDefault1.15

Scale of the media at the start. It settles to 1 as the window opens.

stiffness

TypenumberDefault120

Stiffness of the spring that smooths scrolling. Higher catches up with the scroll faster.

damping

TypenumberDefault30

Damping of the spring that smooths scrolling. Lower lets the window overshoot and swing back.

radius

Typenumber | stringDefault"0.22em"

The window's corner radius at the start. A number is in pixels; a string is any CSS length, and em follows the headline's size. The corners square off as the window meets the stage's edges.

containerRef

TypeReact.RefObject<HTMLElement | null>

Scroll container to track. Defaults to the window. The container must be positioned (e.g. relative).

stageClassName

TypestringDefault"h-dvh"

Classes for the pinned stage. Set its height here.

headlineClassName

Typestring

Classes for the headline, such as its font, weight and size. The default size scales with the stage's width.

windowClassName

Typestring

Classes for the window's starting size. Defaults to 1.6em by 0.8em between the words, and to a 16:10 card on its own line on stages narrower than 48rem, where the words stack above and below it.

className

Typestring

Extra classes for the outer section. Other props pass through to it. With reduced motion, nothing pins: the headline sits above the media at full width.