Header collapsing hero
Media stretches on pull and collapses into a compact header.
npx @swipeui/cli add header-collapsing-heroWhen to use it
- Profile, recipe, album or place screens that open with a big photo and a title over it.
- Detail screens where the image should stretch when people pull down, and shrink away as they scroll.
- Editorial screens where the image sets the mood before the content.
- Any screen where Collapsing header needs a picture behind it.
When not to use it
- Screens without a strong image. Collapsing header is cleaner.
- Lists where people need the content immediately at the top.
- Native stack large titles. Use Header large title preset.
- Search-led screens. Use Search header.
Installation
Installs with a Pro licence
Everything on this page is public except the source. Founder pre-sale opens around 5 January 2027.
Usage
import { HeaderCollapsingHero } from '@/components/swipeui/header/header-collapsing-hero';
import { useHeaderScroll } from '@/components/swipeui/header/header-collapsing';
const header = useHeaderScroll();
<HeaderCollapsingHero title="A quieter route" source={routePhoto} scrollY={header.scrollY} />
<Animated.ScrollView onScroll={header.onScroll} scrollEventThrottle={16}>{content}</Animated.ScrollView>API reference
| Prop | Type | Default | Description |
|---|---|---|---|
title | | — | The title, shown and spoken in full. |
subtitle? | | — | A line under the title. By default it fades away as the header collapses. |
subtitleCollapse? | | | What the subtitle does as the header collapses: |
scrollY | | — | The |
collapseDistance? | | | How far the content scrolls, in points, before the title is fully compact. |
largeTitle? | | | Starts with the large title. Turn it off for a header that is always compact. |
divider? | | | Fades in a hairline under the header once it has collapsed. |
insetTop? | | | Space above the header, in points, usually the top safe-area inset. |
leading? | | — | Content before the title, such as a back button. |
trailing? | | — | Content after the title, such as actions. |
motion? | | | Local motion feel or spring override. |
className? | | — | Classes merged over the header. |
style? | | — | Style escape hatch for the header. |
testID? | | — | The header gets |
source | | — | The image behind the expanded header. |
heroHeight? | | | The image's height before any scrolling, in points. |
stretch? | | | Lets the image grow when the content is pulled down past the top. |
parallax? | | | Moves the image at half the scroll speed as it collapses, so it appears to sit behind the content. |
titleCollapse? | | | When the title folds into the compact bar: |
overlay? | | | The strength, from 0 to 1, of a wash in the background colour over the image, so content placed on it stays readable in light and dark. |
children? | | — | Content drawn over the image, at its bottom edge. Header actions belong in |
mediaStyle? | | — | Style escape hatch for the image container. |
Composition and behavior
- source fills the media area behind the title, heroHeight tall.
- children overlays the media, for example a badge or scrim.
- Below it, a Collapsing header with title, leading and trailing.
- mediaStyle adjusts the media container.
- stretch lets the image grow on pull; parallax moves it at half the scroll speed.
- titleCollapse set to after-hero holds the large title until the image has gone.
- subtitleCollapse set to keep leaves the subtitle under the compact title.
- The content must be long enough to scroll past the image, or the header cannot collapse.
- overlay adds a wash in the background colour, from 0 to 1, so content on the image stays readable.
Behavior and gestures
- Pull down at the top and the image grows taller, like a stretchy header.
- Scroll up and the image shrinks away while the title folds into a compact header.
- Content you put on the image (children) moves with it; keep header buttons in leading and trailing.
Accessibility
- The title is a header and stays fully readable at both sizes.
- The image is decorative; put important information in the title or children with proper labels.
- Under Reduce Motion the image doesn't stretch; it stays at full height until fully scrolled, then disappears in one step.
- Make sure text over the image has enough contrast, for example with a scrim in children.
Motion
- Uses the
morphmotion role, so it follows your app's feel. Passmotionto tune this one instance. - Image height follows scroll position directly on the UI thread.
- Reduce Motion replaces the gradual change with a single switch.
Performance
- Scroll drives styles through Reanimated, never React state.
- Use a properly sized image; it's shown at heroHeight (240 points by default).
Notes for AI
- Use useHeaderScroll() like Collapsing header and pass the same scrollY.
- Set heroHeight to suit the artwork.
Compatibility
| Runs on | Supported |
|---|---|
| Expo SDK 57 | Yes |
| Expo SDK 58 | Yes |
| React Native CLI (with Expo modules) | Yes |
| Expo Go | Yes |
| iOS | Yes |
| Android | Yes |
This table describes API support and static bundle checks. Native runtime, device accessibility and bare Uniwind compatibility remain pending.