Hi! Thanks for trying out NativeBase!
Due to the overwhelming requests and issues/questions we ask you to add the following details with your issue.
react-native: 0.41.2, react: 15.4.0, native-base: 2.0.11
vertically centered textInput (Form Item)
Form completely disappears when trying to add vertically centering styles to it or its parents
render() {
return (
<Container>
<Content contentContainerStyle={{alignItems: 'center', flex: 1, justifyContent: 'center'}}>
<Form>
<Item>
<Input placeholder="Username" />
</Item>
<Item last>
<Input placeholder="Password" />
</Item>
</Form>
</Content>
</Container>
)
}
It's just a blank screen.
Both
If I add no styles, it appears at the top of the page as expected and in the docs, I can also add padding to it - but cannot vertically center. I was able to vertically center a button using the approach above.
Just using justifyContent: 'center' should do it.
Same here
@Ajay-Jadhao I just tried with the above code and modified it and was getting the form content centered vertically. can you try something like this
render() {
return (
<Container>
<Content contentContainerStyle={{flex:1,justifyContent: 'center'}}>
<Form>
<Item>
<Input placeholder="Username" />
</Item>
<Item last>
<Input placeholder="Password" />
</Item>
</Form>
</Content>
</Container>
)
}
@akhil-geekyants
Below is my code.. What i want is the Card need to be centered.
render() {
return (
<Container>
<Header backgroundColor='#207ee1'>
<Left>
<Image
style={styles.imageStyle}
source={logo}
/>
</Left>
<Right />
</Header>
<Content contentContainerStyle={{ flex:1, justifyContent: 'center' }}>
<Card>
<CardItem>
<Body>
<Item >
<Text style={styles.titleStyle}>
Invoice & Revenue
</Text>
</Item>
<Item>
<Icon name='face' />
<Input placeholder='Username' />
</Item>
<Item>
<Icon name='lock-open' />
<Input placeholder='Password' />
</Item>
</Body>
</CardItem>
</Card>
</Content>
</Container>
);
@akhil-geekyants Still not working No effect on Card.
Here is the screenshot.

@Ajay-Jadhao
you can eject the theme by following this docs and remove flex:1 from cardTheme object in native-base-theme/components/Card.js or you can override the card style by putting flex:0 (not sure whether it is a good practice)
Still I couldn't vertically center card component inside Content
Most helpful comment
@Ajay-Jadhao I just tried with the above code and modified it and was getting the form content centered vertically. can you try something like this