React Native - Buttons with shadow - react-native

I'm trying to create this button into my React Native project.
The problem is with that blue shadow. I've already tried packages like react-native-neomorph-shadows. I also tried with:
shadowColor: COLORS.primary,
shadowOffset: {
width: 0,
height: 2,
},
shadowOpacity: 0.25,
shadowRadius: 3.84,
elevation: 5,
About this, the problem is that the shadow isn't powerful enough.
Do you have any ideas how can I do this? Thank you!
EDIT: Maybe this helps... In the design file that effect is made by blurring a blue button and positioning it behind the real button. I've tried this also by using react-native-blur package but the result is also bad.

On IOS you won't need any packages you can just use react-native's shadow props described here: https://reactnative.dev/docs/shadow-props
There is also the elevation property for android, but you won't be able to change the color:
https://reactnative.dev/docs/view-style-props#elevation
Here's an IOS example view with a similar shadow effect:
<View style={{
backgroundColor: '#22A7F0',
height: 48,
width: 240,
borderRadius: 10,
shadowOpacity: 1,
shadowRadius: 10,
shadowOffset: { width: 0, height: 0 },
shadowColor: '#22A7F0',
}}/>
It is noteworthy that the sample you provided combines both a shadow effect and a LinearGradient, so you may want to look into that as well.

Related

How to use css filter: blur() property in React native on a text element?

I need to add a blur effect on a text.
If I were using React, I would use the filter css property.
But I can't find the equivalent syntax to use it in a React native stylesheet.
How do i need to write it ?
you can install react-native-blur / expo-blur
If it's not working for you, this is a workaround/hack that clones the look of blurry text. You can adjust the values to your liking.
<View
style={{
height: 3,
width: 70,
shadowOpacity: 1,
shadowColor: '#000',
shadowOffset: { width: 10, height: 10 },
shadowRadius: 5,
elevation: 5,
borderWidth: 0.5,
borderColor: "white",
backgroundColor: "rgba(255, 255, 255, 1)"
}}
/>

react native bottum tab icon absolute issue

I am want to float my home icon above the tab bar but it gets cut can someone suggest how to do that.. aim also attaching the screenshot and navigation stack structure
stack navigation
-1. drawer nav
-a. Tab nav
position: 'absolute',
bottom: 20,
height: 58,
width: 58,
borderRadius: 58,
backgroundColor: colors.primaryColor,
justifyContent: 'center',
alignItems: 'center',
shadowColor: '#000',
shadowOffset: {
width: 0,
height: 3,
},
shadowOpacity: 0.29,
shadowRadius: 4.65,
elevation: 7,
flex: 1,
Did you try to play with the zIndex property of each of the component ?
or maybe the overflow property ?
... hard to say without having a look at the code structure.
Another solution would be to build a component for the button you want to overlap.

How to show shadow over scroll view items in react native

I'm using native-base's Content to scroll and i want a fixed button on bottom when scrolling. How can i show the shadow of fixed button over scroll view Items like this.
But what i achieve is this
My Code
<Container>
<Content>
...
</Content>
<View style={styles.footer}>
<Button style={styles.footerBtn}>
<Text>{strings('consultant_profile.book_an_appointment')}</Text>
</Button>
</View>
</Container>
//Css
footer: {
padding: 20,
shadowColor: '#000',
shadowOffset: {
width: 0,
height: 2,
},
shadowOpacity: 0.23,
shadowRadius: 2.62,
elevation: 4,
},
It is hard to implement such gradient effect in react-native because of the limitation of it on shadow. For Android API 27 or below, you cannot even change the color of elevation in Android by using shadowColor.
For your situation, I would recommend you to use react-native-linear-gradient.
After installed the package simply place the below component at the top of your button, it might do the trick.
<LinearGradient colors={['rgba(255, 255, 255, 0)', 'rgba(255, 255, 255, 1)']} {...otherGradientProps} />
Try to add to following style to the button styles:
shadowColor: "#000",
shadowOffset: {
width: 0,
height: 2,
},
shadowOpacity: 0.23,
shadowRadius: 2.62,
elevation: 4
If it's not working then please share more of the your component code so it will be easier to try help you out.
You can animate items opacity to get something similar look.

Using shadow with borderRadius on a react native component

I'm trying to set a shadow on a custom card component in React Native with a borderRadius property of 10.
Here is the code:
borderBottomLeftRadius: 10,
borderBottomRightRadius: 10,
shadowOffset: {
width: 0,
height: 3,
},
elevation: 3,
How can I apply rounded corners to the shadow?
You can use the shadowRadius property to shape the rounded corners. But this will only work for iOS since Android only takes the elevation property to create shadows. You can read more about this in the official documentation here. https://reactnative.dev/docs/shadow-props
You can have styles like this example below applied to the container view of your custom card.
const shadowsStyling = {
width: 100,
height: 100,
shadowColor: "#000000",
shadowOpacity: 0.8,
shadowRadius: 2,
shadowOffset: {
height: 1,
width: 0
}
}

Make text blurry in react-native [duplicate]

The question is simple. I have a View with a Text component in it. I just want this text to be blurred initially.
The only solution I saw to blur something in React Native is for an Image via this "react-native-blur".
How can we blur a Text component in React Native?
Info: I just want to make an app where the user does not see the answer directly (via blurring).
If you don't want to install react-native-blur / expo-blur or it's not working for you, this is a workaround/hack that mimics the look of blurred text in a View. The values can be adjusted as necessary.
<View
style={{
height: 3,
width: 70,
shadowOpacity: 1,
shadowColor: '#000',
shadowOffset: { width: 10, height: 10 },
shadowRadius: 5,
elevation: 5,
borderWidth: 0.5,
borderColor: "white",
backgroundColor: "rgba(255, 255, 255, 1)"
}}
/>
Install react-native-blur:
npm install react-native-blur
import BlurView from 'react-native-blur';
...
<BlurView blurType="light" style={styles.blur}>
...
You can simply use css to do it, feel free you change the amount of opacity, offset, color, radius as your requirement
<Text
style={{
color: "#fff0",
textShadowColor: "rgba(255,255,255,0.8)",
textShadowOffset: {
width: 0,
height: 0,
},
textShadowRadius: 10,
fontSize: 14,
fontWeight: "600",
textTransform: "capitalize",
}}
>
Blurred
</Text>