I created a TextInput
in React Native,
But I want the label go outside the box with animation when isFocused
or filled with some value like:
If value is null or empty the label must be inside the input, otherwise the label must move outside the input with animation.
My Code:
export default function InputBox(props) {
return (
<View style={styles.container}>
<Text style={styles.label}>{props.label}</Text>
<TextInput
style={styles.input}
autoCapitalize="none"
defaultValue={props.defaultValue}
onChangeText={props.onChangeText}
keyboardType={props.keyboardType}
editable={props.editable}
/>
</View>
);
}
Style:
const styles = StyleSheet.create({
container: {
marginBottom: 20,
backgroundColor: COLORS.WHITE,
paddingTop: 5,
paddingHorizontal: 10,
borderWidth: 1,
borderColor: COLORS.GREY_BORDER,
borderRadius: 2,
},
icon: {
width: 40,
justifyContent: 'center',
alignItems: 'center',
},
input: {
fontFamily: FONT_FAMILY.primaryMedium,
fontSize: 13,
height: 35,
color: COLORS.BLACK,
},
label: {
fontFamily: FONT_FAMILY.primary,
color: COLORS.GREY,
fontSize: 10,
},
});