
What is React Native Masked View?
React Native Masked View is a component that allows you to mask (or hide) parts of a child view based on another view (the mask). Essentially, it lets developers control the visibility of UI components by defining which parts should be shown or hidden using another shape or pattern.
This is particularly useful for creating sophisticated visual effects such as gradients, shapes, animations, and reveal effects. It is typically used alongside libraries like react-native-reanimated
and react-native-svg
to produce interactive and engaging user interfaces.
The most popular implementation is @react-native-masked-view/masked-view
, which is maintained by the React Native community and supports both iOS and Android.
What are the Major Use Cases of React Native Masked View?
React Native Masked View plays a significant role in enhancing UI/UX. Here are some top use cases:
1. Onboarding Reveal Effects
- Reveal only a part of the screen to introduce users to key features.
- Common in app walkthroughs and tutorials.
2. Profile Image Reveal
- Apply stylish reveals to profile images using circular or gradient masks.
3. Custom Buttons and Gradients
- Create gradient buttons with specific shapes or text clipping.
4. Text Clipping with Background Animations
- Animate a gradient or video behind a clipped text to make it visually appealing.
5. Light Spot or Spotlight Effects
- Mask everything except the spotlighted area, directing user attention.
6. Loading Screens with Animated Masking
- Display animated skeleton loaders or shimmer effects using masks.
How React Native Masked View Works (with Architecture)

React Native Masked View works by rendering a mask element over a child element, and only the parts that intersect are made visible. The underlying system uses native APIs for optimal performance.
Simplified Architecture:
[MaskedView Component]
├── [maskElement] – Defines visible area
└── [children] – Content to be shown within the mask
- maskElement: A shape, view, or animated element that defines what is visible.
- children: The actual content (like text, images, gradients) that is masked.
React Native bridges this structure to native layers using CALayer.mask
on iOS and PorterDuffXfermode
on Android to achieve the masking effect efficiently.
Example:
<MaskedView
maskElement={
<Text style={{ fontSize: 60, fontWeight: 'bold' }}>HELLO</Text>
}>
<LinearGradient
colors={['#ff0080', '#7928ca']}
style={{ flex: 1 }}
/>
</MaskedView>
In this case, the gradient will only be visible where the word “HELLO” is rendered.
Basic Workflow of React Native Masked View
- Install the Masked View package using npm/yarn.
- Import the component and wrap your content inside the
<MaskedView>
element. - Define the maskElement — typically a
Text
,Image
, orView
styled for the mask. - Place your actual content (like gradients or images) as children.
- Run and test to ensure the mask renders correctly on different platforms.
- Add animations or interactions for more dynamic visuals.
Step-by-Step Getting Started Guide for React Native Masked View
Step 1: Install the Library
npm install @react-native-masked-view/masked-view
Or using yarn:
yarn add @react-native-masked-view/masked-view
Step 2: Link the Library (if needed)
If you’re using older versions of React Native (<0.60), link manually:
react-native link @react-native-masked-view/masked-view
Step 3: Install Supporting Libraries (Optional but Common)
npm install react-native-linear-gradient react-native-svg
Step 4: Implement Your First Mask
Example:
import MaskedView from '@react-native-masked-view/masked-view';
import { LinearGradient } from 'expo-linear-gradient';
<MaskedView
style={{ flex: 1 }}
maskElement={
<Text style={{ fontSize: 50, fontWeight: 'bold' }}>MASKED</Text>
}>
<LinearGradient
colors={['#ff8c00', '#ff0080']}
style={{ flex: 1 }}
/>
</MaskedView>
Step 5: Test Across Devices
Test your view on both Android and iOS simulators and real devices for performance and compatibility.
Step 6: Add Interactivity (Optional)
Use react-native-reanimated
to animate masks based on gestures or scroll positions.