rn-fade-wrapper is a simple, highly-performant React Native component that adds smooth, customizable fade gradients to the edges of any content. Perfect for enhancing the user experience in scrollable containers, lists, carousels, modals, or any view with overflowing content.
- β‘ Native rendering for iOS and Android
- π Supports vertical and horizontal gradient directions
- π¨ Fully customizable fade size and color (per side or uniform)
βοΈ Optionalinwardmode to fade towards content instead of outward- π§© Simple API: drop-in wrapper with intuitive props
- πͺ Great performance β gradients are rendered natively, ideal for scroll views and animations
- π§ Works in bare React Native and Expo (EAS Build / Development Build)
yarn add rn-fade-wrapper
# or
npm install rn-fade-wrapperAutolinking handles everything. No extra steps needed.
This library uses native code and requires a Development Build or EAS Build. It does not work in Expo Go.
- Add the plugin to your
app.json:
{
"expo": {
"plugins": ["rn-fade-wrapper"]
}
}- Rebuild your native project:
npx expo prebuild
# or use EAS Build
eas build| Platform | Old Architecture | New Architecture (Fabric) |
|---|---|---|
| iOS | β | β |
| Android | β | β |
import { FadeWrapper } from 'rn-fade-wrapper';
const MyComponent = () => {
return (
<FadeWrapper color="#ffffff" size={24} orientation="vertical">
<ScrollView>
<Text>Fading edges example</Text>
</ScrollView>
</FadeWrapper>
);
};| Prop | Type | Default | Description |
|---|---|---|---|
color |
string |
white | Fade color β any valid color string ("#fff", "rgba(0,0,0,0.5)", etc.) |
size |
number |
20 |
Uniform fade size in points, applied according to orientation |
orientation |
'horizontal' | 'vertical' |
'vertical' |
Applies size to top/bottom (vertical) or left/right (horizontal) |
sizes |
{ top?: number, right?: number, bottom?: number, left?: number } |
β | Per-edge fade sizes. Takes precedence over size and orientation |
inward |
boolean |
false |
Flips the gradient direction β fades inward (towards the center of the content) |
style |
ViewStyle |
β | Additional style for the wrapper view |
children |
React.ReactNode |
β | Content to wrap |
<FadeWrapper color="#ffffff" size={32}>
<ScrollView>
{/* content */}
</ScrollView>
</FadeWrapper><FadeWrapper color="#ffffff" size={16} orientation="horizontal">
<ScrollView horizontal>
{/* content */}
</ScrollView>
</FadeWrapper><FadeWrapper color="#000000" sizes={{ top: 0, bottom: 40, left: 16, right: 16 }}>
<FlatList ... />
</FadeWrapper><FadeWrapper color="black" inward sizes={{ top: 20, bottom: 30 }}>
<FlatList ... />
</FadeWrapper>- iOS:
CAGradientLayersublayers added directly to the target view for zero-overhead compositing - Android:
LinearGradientshaders drawn on aViewGroupcanvas β shaders are cached and only rebuilt on size or color change
Use rn-fade-wrapper to subtly indicate content overflow β especially in carousels, scroll views, and horizontal sliders. Gradients help hint to the user that there's more to scroll, improving engagement.
MIT β free to use, improve and contribute π
