Fade in view
UI-scroll-linked reveal measured from a separate static wrapper.
npx @swipeui/cli add fade-in-viewWhen to use it
- Content that gently fades and rises into place as people scroll to it, like features on a landing screen.
- Long editorial screens where each section should arrive softly.
- Lists where a subtle entrance helps people notice new sections.
When not to use it
- Content people need instantly, such as form fields or prices.
- Very long lists; animating every row is distracting.
- Elements that appear without scrolling. Use a simple entering animation.
Installation
Run this from your app's root. If SwipeUI isn't set up yet, run npx @swipeui/cli init first; it sets up Uniwind, the theme tokens and the cn helper.
npx @swipeui/cli add fade-in-view- Adds
components/swipeui/ui/use-fade-in-view-scroll.ts,components/swipeui/ui/fade-in-view.tsxand 1 shared helper. - Installs react-native-reanimated, react-native-worklets. In Expo apps it uses
npx expo installso versions match your SDK.
Usage
import { FadeInView } from '@/components/swipeui/ui/fade-in-view';
import { useFadeInViewScroll } from '@/components/swipeui/ui/use-fade-in-view-scroll';
const { scrollY, onScroll, viewportRef } = useFadeInViewScroll();
<Animated.ScrollView ref={viewportRef} onScroll={onScroll} scrollEventThrottle={16}>
<FadeInView scrollY={scrollY} viewportRef={viewportRef}>
<Text>Discover more</Text>
</FadeInView>
</Animated.ScrollView>;Examples
once, repeat. The app and website share content, named boards and compact outside controls. The boards use distance={32} and threshold={0.5} for a more visible entrance across a longer scroll ramp. Full-window defaults stay unchanged.
Settings
| Setting | Default | Behavior |
|---|---|---|
scrollY | required | Shared scroll offset from useFadeInViewScroll. |
viewportRef | absent | Ref returned by the scroll helper; attach it to a nested Animated.ScrollView and pass it here to measure its visible area. Omit for a full-window scroll. |
children | required | Content stays in layout and the accessibility tree. |
threshold | 0.15 | Viewport fraction used as the reveal ramp; in (0, 1]. |
once | true | Keep revealed after the first entrance. |
from | 'bottom' | Original rise, logical 'start' or 'end', or 'none' for opacity only. Logical sides mirror in RTL. |
distance | 16 | Nonnegative finite travel in points. |
delay | 0 | Nonnegative finite milliseconds after entry begins. Ignored when once=false, which remains scroll linked. |
motion | app feel | Reduce Motion shows content immediately without travel. |
className | absent | Root classes. |
style | absent | Native layout escape hatch. |
testID | absent | Root and content IDs. |
Accessibility
Content remains in layout and the accessibility tree. Reduce Motion shows it immediately without travel. Native screen-reader, Dynamic Type and performance checks remain pending at 7.9.
Behavior and gestures
- Default remains the shipped bottom/16pt scroll ramp. Once freezes after full reveal; a nonzero delay gates its entrance with shared timing. Repeat stays scroll linked.
- The application owns its content; demo controls sit outside the item.
- Pass viewportRef from useFadeInViewScroll for a nested scroll area; window measurement remains the default.
Accessibility
- Content stays in the layout and the accessibility tree the whole time, so screen readers can reach it before it's revealed.
- Reduce Motion shows content immediately with no fade or travel.
Motion
- Uses the
listmotion role, so it follows your app's feel. Passmotionto tune this one instance. - Preserves the original scroll ramp and 16pt rise. A nonzero once-only delay gates the reveal with shared list timing.
- Reduce Motion shows content immediately without travel; repeat remains directly scroll linked.
Performance
- Measures from a separate static wrapper to avoid feedback loops.
- No React re-renders while scrolling.
Notes for AI
- Use useFadeInViewScroll() on the scroll view and pass scrollY to each FadeInView.
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.