Adding example of using native view with Mask
See original GitHub issueFeature Request
Hi @msand
I just see the new release, Thanks for that. I just wanted to try the new feature, but I didn’t succeed so I should misusing it.
It would be great if you add an example to Mask
section in ReadMe.md file.
Why it is needed
It helps users to understand how it should be used, like the other examples.
Code sample
here is what I tried
https://snack.expo.io/@saeedzhiany/using-native-view-with-mask
import React from 'react';
import {View, Image, Text} from 'react-native';
import {
Svg,
G,
Circle,
Defs,
LinearGradient,
Mask,
Rect,
Stop,
} from 'react-native-svg';
export default () => {
return (
<View style={{flex: 1, justifyContent: 'center'}}>
<Svg height="50%">
<Defs>
<LinearGradient
id="Gradient"
gradientUnits="userSpaceOnUse"
x1="0"
y1="0"
x2="800"
y2="0">
<Stop offset="0" stopColor="white" stopOpacity="0" />
<Stop offset="1" stopColor="white" stopOpacity="1" />
</LinearGradient>
<Mask
id="Mask"
maskUnits="userSpaceOnUse"
x='0'
y='0'
width="800"
height="300">
<Rect x="0" y="0" width="800" height="300" fill="url(#Gradient)" />
</Mask>
</Defs>
<G mask="url(#Mask)">
<Circle x={50} y={70} r={65} />
<G transform="translate(200, 100)">
<Text>Some Text</Text>
</G>
</G>
</Svg>
</View>
);
};
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:17 (8 by maintainers)
Top Results From Across the Web
The 5 Minute React Native Masked View - YouTube
In this video, we are building an angular gradient in React Native using a masked view.Hope you enjoy it Wanna learn the fundamentals...
Read more >React Native Masked View Library - GitHub
The following image demonstrates that you can put almost anything behind the mask. The three examples shown are masked <View> , <Text> ,...
Read more >Mask UI Elements in React Native With React ... - Egghead.io
A masked view is view which only displays the pixels that overlap with the view rendered in its mask element. This can be...
Read more >Using input masks in React Native - LogRocket Blog
Implement input masks in React Native to develop user-friendly input constraints such as entering data according to a pre-defined format.
Read more >MaskedView - Expo Documentation
@react-native-masked-view/masked-view provides a masked view which only displays the pixels that overlap with the view rendered in its mask element.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
What about Android’s result? it seems the nested Text within SVG is disappeared (or even not rendered) however, I’ll test it on my project tomorrow, maybe it because of the library’s version on expo as you said.
Also, Thanks for your guidance.
Ah, yeah that’s correct