I’m using @rneui/base package’s Input component, however, I cannot center the input field the package provides.
I would be glad if you help. Thank you from now.
Here are the code and styles:
function EditClassScreen() {
return (
<View style={styles.container}>
<Header />
<View style={styles.inputItem}>
<Input containerStyle={styles.inputContainer} style={styles.input}>
<Text>
test
</Text>
</Input>
</View>
</View>
);
};
export default EditClassScreen;
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: COLORS.bgColor,
},
inputItem: {
backgroundColor: COLORS.green,
paddingHorizontal: 16,
marginTop: 8,
},
inputContainer: {
backgroundColor: COLORS.blue,
borderColor: COLORS.paleGray,
borderBottomWidth: 1,
},
input: {
backgroundColor: COLORS.red,
borderColor: COLORS.paleGray,
borderWidth: 1,
},
});
I tried probably every possible option for, alignItems, justifyContent, alignSelf, but none worked.
Here is the image:
I want to centralize the red area within the blue area.
I solved the problem and added my solution as an answer. Thank you for all your answers.
3
Answers
I solved the problem by adding
flexDirection: 'row'
to theinputContainer
.Add this to
inputContainer
orinput
style:App.js
Run this code and see output maybe you find a solution