I have requirements in my react native project to show border in view so i apply
<view style={{borderwidth=1,bordercolor:’red’}}/>
So it’showing border to full view but my requirements is to show border only top side So how to apply border to specific side of the view with different color.
To add border bottom in React Native, we can add border bottom on the View . to set borderBottom to '1px solid blue' on the View .
Border Radius in React NativeThe borderRadius property can be set as the style attribute to any element. It takes a value in pixels and assigns that value to the overall border radius of that UI element. By default, the border radius of any element is 0 if you haven't added that style attribute to that element.
Use the border css property to set the border style of an element in React, e.g. <div style={{border: '1px solid rgba(0,255,0,0.3)'}}> . If you only need to style a specific border, use the corresponding property, e.g. borderBottom .
Please add to your style borderBottomWidth
to add a border to the bottom of the view and borderTopWidth
to add border top side of the view, see below code snippet:
<View style={{borderColor:'red',borderBottomWidth:1,borderTopWidth:1}}>
<Text>
One Side border
</Text>
<View>
In react native there are view's style property to set individual side width. You can use borderTopWidth for Top Border. borderBottomWidth for bottom border, borderLeftWidth for left border and borderRightWidth for right border. If you use single property borderWidth then it will apply to all four side of view.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With