Reputation: 69
How Do I create that Button in React Native?
As above, button component include two part , left is text part, right part include another background color and image. But, whole button component includes same border radius and gradient. Does somebody might know how to get to this?
Upvotes: 0
Views: 154
Reputation: 1182
You should wrap two sibling View components with TouchableOpacity
component which will handle onPress
for the whole button. Position them side by side using flex
and set explicit sizes on each. Left element should get borderTopLeftRadius
and borderBottomLeftRadius
and right should get borderTopRightRadius
and borderBottomRightRadius
. Border radius is solved separately but it would seem like it's all in one, and for gradient do you mean this inner shadow or something else?
It's because inset shadow does not exist in RN, but it can be faked quite realistically. Read more here: https://github.com/facebook/react-native/issues/2255.
If you really wan't to use gradient, you must use https://github.com/react-native-community/react-native-linear-gradient and position it absolutely over everything and just set it in the background using zIndex
property.
Upvotes: 2