Adding border only to the one side of the component in React Native (iOS)

后端 未结 3 464
终归单人心
终归单人心 2021-01-07 17:15

I am facing something weird issue with React-Native\'s component in iOS.

I wanted to apply borderBottomWidth

相关标签:
3条回答
  • 2021-01-07 17:56
    <Text style={{
      borderBottomWidth: 1,
      borderBottomColor: 'red',
      borderBottomStyle: 'solid'
    }}> 
      React Native 
    </Text>
    

    or

    borderBottom: '1px solid rgba(219, 219, 219, 1)'
    
    0 讨论(0)
  • 2021-01-07 18:03

    This isn't currently possible. See the following RN issue: https://github.com/facebook/react-native/issues/29 and this ticket on Product Pains: https://productpains.com/post/react-native/add-borderwidth-left-right-top-bottom-to-textinput-/

    0 讨论(0)
  • 2021-01-07 18:09

    Even though borderBottom doesn't work on the Text component, it did work for me on the TextInput component, just set editable to false and set the value to your desired text as so...

    <TextInput
        style={styles.textInput}
        editable={false}
        value={'My Text'}/>
    
    const styles = StyleSheet.create({
        textInput: {
            borderBottomColor: 'black',
            borderBottomWidth: 1,
        }
    });
    
    0 讨论(0)
提交回复
热议问题