Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React native adding border to the one side of the view

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.

like image 807
user1374 Avatar asked Jan 25 '18 12:01

user1374


People also ask

How do I add a border to the bottom in React Native?

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 .

How do you give border radius to view in React Native?

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.

How do I add a border in React?

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 .


2 Answers

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> 
like image 87
Patrick R Avatar answered Nov 15 '22 15:11

Patrick R


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.

like image 41
Sagar Chauhan Avatar answered Nov 15 '22 15:11

Sagar Chauhan