Hi all I am new to react native and try to develop below UI.Is they any ways to create a curve triangle.I tried but unable curve edge of triangle.
Here is my code.
notch: {
width: 32,
height: 5,
backgroundColor: 'transparent',
borderStyle: 'solid',
borderLeftWidth: 30 / 2,
borderRightWidth: 30 / 2,
borderBottomWidth: 20,
borderLeftColor: 'transparent',
borderRightColor: 'transparent',
borderBottomColor: '#7B1B67',
position: 'absolute',
right: 15,
top: -15,
borderTopLeftRadius: 15,
borderTopRightRadius: 15,
borderBottomLeftRadius: 95,
borderBottomRightRadius: 95,
overflow:'visible'
},
2
Answers
You can use a simple square element, round the border then rotate it. Here’s an example where
::after
is just for previewNote
linear-gradient
is just to fill half so it doesn’t hide the text, you may use z-index and simply push it below textTo create a curved triangle shape in React Native, you can use a combination of View and Image components. Here’s an example code that you can modify according to your needs:
In this example, we are using an Image component with a transparent background to display the triangle shape, and we are positioning a View component on top of it to create the curved edge. The borderTopLeftRadius and borderTopRightRadius styles of the View component are set to half the height of the component, which creates a semi-circle shape at the top. You can adjust the dimensions and styles of the Image and View components to achieve the desired shape and color.
You can also use SVG or other libraries such as react-native-svg to create more complex shapes and curves.