About this animation
A React Native expanding carousel can show the surrounding choices without squeezing the selected card into a conventional pager. This component divides its available space into strips, then continuously transfers width or height between them during a drag. Use it for travel photos, editorial features, portfolios, product families, or any small set where context matters alongside a strong active image. Gesture Handler writes to one continuous position, and Reanimated derives strip weight, offset, image parallax, copy reveal, and indicator state on the UI thread. Live hit testing keeps taps accurate during interrupted transitions. Supply any number of photo items, choose a horizontal or vertical axis, tune proportions and spacing, and control selection through a callback or imperative ref.
When to use it
- Present a compact set of destination photos.
- Build a horizontal or vertical expanding gallery.
- Keep neighboring choices visible around one hero card.
- Reveal copy only when a strip has enough room.
Choose a carousel by task
Start with what people need to compare: products, artwork, or neighboring choices. The transition style supports that task.
- Compare products and prices · Flip Product Carousel
- Edge-hinged card turns keep the product, rolling price, and background color connected.
- Browse an immersive image gallery · Blurred Backdrop Carousel
- The selected image supplies a blurred backdrop, emphasizing artwork rather than a purchase flow.
- Choose artwork for a lock screen · Wallpaper Carousel
- Credits move with the image, and holding previews the selected wallpaper at full size.
- Keep neighboring options visible · Expanding Strip Carousel (this piece)
- Narrow image strips trade width with the active card; copy appears only when there is room to read it.
- Open an editorial card into detail · Vertical Title Cards
- A portrait-card carousel expands into a detail header while its vertical title rotates into reading position.
- Introduce an art collection · Tilted Marquee Carousel
- A moving perspective gallery creates an opening scene rather than a compact value picker.
- Select a full-screen artwork scene · Arc Avatar Switcher
- Portrait thumbnails turn along an arc, then reveal the selected artwork from its thumbnail instead of opening a product card.
A photo carousel where narrow strips expand under a drag, with configurable items, direction, spacing, and fonts.
Why this one
Most expanding accordions jump directly between fixed layouts. This version distributes width continuously under the finger, supports either axis, and waits until a card has enough room before sliding and fading its copy into view. Any number of items can be supplied, so the number of visible strips is controlled by the data.
How it works
- The component measures its own container and calculates the active weight required to give the selected strip the requested share of useful space.
- One continuous
positionshared value drives every strip's weight, offset, size, image parallax, copy reveal, and indicator state. - A pan moves that value in proportion to twice the resting narrow-strip size, then velocity and proximity choose the spring target.
- A tap hit-tests the live strip geometry, so selection remains accurate midway through an interrupted transition.
- Copy stays hidden until its strip passes half of its final active size, then enters with opacity and translation.
Install
npx expo install expo-image expo-linear-gradient react-native-gesture-handler react-native-reanimated react-native-workletsUsage
import ExpandingStripCarousel from './ExpandingStripCarousel';
export function Places() {
return (
<ExpandingStripCarousel
items={[
{ image: require('./forest.jpg'), title: 'Fern Trail', subtitle: 'North Ridge' },
{ image: require('./coast.jpg'), title: 'Quiet Coast', subtitle: 'West Bay' },
]}
/>
);
}Customize its axis and proportions, or select a card from outside:
import { useRef } from 'react';
import ExpandingStripCarousel, { type ExpandingStripCarouselRef } from './ExpandingStripCarousel';
export function VerticalPlaces() {
const ref = useRef<ExpandingStripCarouselRef>(null);
return (
<ExpandingStripCarousel
ref={ref}
items={places}
direction="vertical"
activeShare={0.72}
gap={8}
radius={28}
height={0.7}
fontFamily="YourSansFont"
titleFontFamily="YourDisplayFont"
onIndexChange={(index) => trackSelection(index)}
/>
);
}The forwarded ref exposes select(index).
Props
| Prop | Type | Default | Description |
|---|---|---|---|
items | StripItem[] | Required | Photos, titles, optional subtitles, and optional accent colors. |
direction | 'horizontal' | 'vertical' | 'horizontal' | Axis along which strips divide the available space. |
activeShare | number | 0.66 | Resting share for the active strip, clamped from 0.5 to 0.85. |
gap | number | 6 | Space between strips in points. |
radius | number | 22 | Strip corner radius in points. |
height | number | 0.42 | Strip-stage height as a fraction of component height. |
fontFamily | string | System font | Font for subtitles. |
titleFontFamily | string | System font | Font for strip and footer titles. |
onIndexChange | (index: number) => void | — | Called when selection changes. |
style | StyleProp<ViewStyle> | — | Outer-container style. |
testID | string | — | Test identifier for the outer container. |
Compatibility
- Expo SDK 58
- React Native 0.88
- Reanimated 4.7 and Worklets 0.13
- iOS: supported
- Android: supported
- Web: supported
- Works in Expo Go because its native dependencies are included in the SDK
Accessibility
The carousel is exposed as an adjustable control with its active title, place, position, and increment/decrement actions. Tapping a strip provides an alternative to dragging. With reduced motion enabled, taps, accessibility actions, and external selections update immediately without a spring.
Customization notes
Set items[].tone for the ambient backdrop behind each image.
Movement follows gestures, scroll position, or interruptible spring physics. A global duration is not exposed; reduced-motion fades retain their short fixed timing.
FAQ
- Does the expanding carousel work in Expo Go?
- Yes. Expo Image, Gesture Handler, Reanimated, and Worklets are included with Expo SDK 58 and Expo SDK 57. Each published piece is reviewed on physical iPhone and Android devices with Expo Go before release.
- Can it expand vertically instead of horizontally?
- Yes. Set direction to vertical and tune activeShare, gap, radius, and height. The item count comes from your data rather than a fixed layout.
- What accessible interaction does it provide?
- The carousel is adjustable and announces the active title, place, and position. Tapping a strip is an alternative to dragging, and Reduce Motion makes selections immediate.




