How to apply Blur (GlassMorphism) to react native View Component? #226
-
I was trying to apply glass morphism to a view Here's the code import React from 'react';
import {StyleSheet, Text, Dimensions} from 'react-native';
import {SafeAreaView} from 'react-native-safe-area-context';
import {
BackdropBlur,
Blur,
BlurMask,
Canvas,
Circle,
Fill,
Group,
Paint,
rect,
Rect,
} from '@shopify/react-native-skia';
const {height, width} = Dimensions.get('window');
let arr = new Array(10).fill(0);
const clipRect = rect(0, 0, width, height);
const SkiaExample = () => {
return (
<SafeAreaView style={styles.container}>
{arr.map((_, i) => (
<Text key={i}>{'Hello World'}</Text>
))}
<Canvas style={StyleSheet.absoluteFillObject}>
<Rect
height={height / 2}
width={width}
x={0}
y={height / 2}
color={'rgba(0,0,0,1)'}
/>
<Group>
<Circle cx={r} cy={r} r={r} color="cyan" />
<Circle cx={_width + r} cy={r} r={r} color="magenta" />
<Circle cx={_width / 2 + r} cy={_height + r} r={r} color="yellow" />
</Group>
<BackdropBlur intensity={20} clip={clipRect} />
</Canvas>
</SafeAreaView>
);
};
export default SkiaExample;
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'space-between',
}
}); All the elements inside canvas get blur, But the Text components which is behind the canvas don't get blur applied at all. If I have to create a blur effect to React Native components like View or Text, how to achieve it? Here's the screenshot of how it looks |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Unfortunately, we don't try to access the bitmap of the native components at the moment, it's something we might be looking into in the future in order to provide advanced effects. |
Beta Was this translation helpful? Give feedback.
-
@wcandillon Is work going on this. react-native-blur-view not has full customisation as one need. |
Beta Was this translation helpful? Give feedback.
Unfortunately, we don't try to access the bitmap of the native components at the moment, it's something we might be looking into in the future in order to provide advanced effects.