SwipeUI

Header collapsing hero

Media stretches on pull and collapses into a compact header.

npx @swipeui/cli add header-collapsing-hero
Variant
Preset
Material
Scheme
Feel
Interactive web demo. Native materials, gestures and system presentation differ on device.

When 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

app/route.tsx
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

PropTypeDefaultDescription
titlestring—

The title, shown and spoken in full.

subtitle?string—

A line under the title. By default it fades away as the header collapses.

subtitleCollapse?"fade" | "keep"'fade'

What the subtitle does as the header collapses: fade away, or keep it under the compact title.

scrollYSharedValue<number>—

The scrollY returned by useHeaderScroll.

collapseDistance?number96

How far the content scrolls, in points, before the title is fully compact.

largeTitle?booleantrue

Starts with the large title. Turn it off for a header that is always compact.

divider?booleanfalse

Fades in a hairline under the header once it has collapsed.

insetTop?number0

Space above the header, in points, usually the top safe-area inset.

leading?ReactNode—

Content before the title, such as a back button.

trailing?ReactNode—

Content after the title, such as actions.

motion?MotionOverridethe app feel

Local motion feel or spring override.

className?string—

Classes merged over the header.

style?StyleProp<ViewStyle>—

Style escape hatch for the header.

testID?string—

The header gets testID, the divider ${testID}-divider.

sourceImageSource—

The image behind the expanded header.

heroHeight?number240

The image's height before any scrolling, in points.

stretch?booleantrue

Lets the image grow when the content is pulled down past the top.

parallax?booleanfalse

Moves the image at half the scroll speed as it collapses, so it appears to sit behind the content.

titleCollapse?"after-hero" | "with-hero"'with-hero'

When the title folds into the compact bar: with-hero while the image is still shrinking, or after-hero once the image has gone.

overlay?number0

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?ReactNode—

Content drawn over the image, at its bottom edge. Header actions belong in leading and trailing.

mediaStyle?StyleProp<ViewStyle>—

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 morph motion role, so it follows your app's feel. Pass motion to 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 onSupported
Expo SDK 57Yes
Expo SDK 58Yes
React Native CLI (with Expo modules)Yes
Expo GoYes
iOSYes
AndroidYes

This table describes API support and static bundle checks. Native runtime, device accessibility and bare Uniwind compatibility remain pending.

Related items