Created
July 14, 2017 15:29
-
-
Save minhchu/38f46592d2fbc1117fde91f9f879b094 to your computer and use it in GitHub Desktop.
style input with close button. RN 0.46
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import { Text, View, TextInput, StyleSheet, TouchableHighlight } from 'react-native'; | |
export default class App extends Component { | |
render() { | |
return ( | |
<View> | |
<View style={styles.wrapper}> | |
<TextInput | |
underlineColorAndroid={'transparent'} | |
style={styles.input} | |
/> | |
<TouchableHighlight | |
onPress={() => {}} | |
style={styles.close} | |
> | |
<Text | |
style={styles.text} | |
>X</Text> | |
</TouchableHighlight> | |
</View> | |
<Text>Hello World</Text> | |
</View> | |
); | |
} | |
} | |
const styles = StyleSheet.create({ | |
wrapper: { | |
borderWidth: 1, | |
borderRadius: 20, | |
borderColor: 'gray', | |
flexDirection: 'row', | |
justifyContent: 'center', | |
alignItems: 'center' | |
}, | |
input: { | |
flex: 1, | |
}, | |
close: { | |
borderWidth: 1, | |
borderRadius: 15, | |
borderColor: 'red', | |
backgroundColor: 'red', | |
width: 30, | |
height: 30, | |
justifyContent: 'center', | |
alignItems: 'center', | |
marginRight: 3, | |
}, | |
text: { | |
color: 'white', | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment