Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot center <Col> horizontally. #83

Open
maotora opened this issue Dec 18, 2018 · 3 comments
Open

Cannot center <Col> horizontally. #83

maotora opened this issue Dec 18, 2018 · 3 comments

Comments

@maotora
Copy link

maotora commented Dec 18, 2018

Hi,

I'm trying to center content inside Col horizontally and it doesn't work.
I've read this alignment issue and this stackoverflow post and none of them works for me 😭😭

I want to horizontally center those two <Row>s inside the first <Col>.

Here is my code.

<Container>
    <Content contentContainerStyle={{flex: 1}}>
        <Grid style={{justifyContent: 'center'}}>
            <Col>
                <Row size={2}>
                    <Col>
                        <Text> Sign up options </Text>
                    </Col>
                </Row>
                <Row size={2}>
                    <Col>
                        <Button iconLeft danger>
                            <Icon name="logo-google" />
                            <Text> With Google </Text>
                        </Button>
                    </Col>
                </Row>
                <Row size={2}>
                    <Col>
                        <Button iconLeft bordered dark>
                            <Icon name="sms" type="MaterialIcons" />
                            <Text> With SMS </Text>
                        </Button>
                    </Col>
                </Row>
            </Col>
        </Grid>
    </Content>
</Container>

Please note that alignItems works as expected (centering Col vertically) but none works horizontally for me.

Please help,

Thanks.

@HakanAkca
Copy link

you have found a solution ? because i have this problem

@maotora
Copy link
Author

maotora commented Jan 16, 2019

Because col has flexDirection: 'column' I concluded that if I want to center something horizontally I only use as parent and child.

Using (as parent) changes the flex direction and somehow, spoils everything's alignment.

@dsouksavatd
Copy link

try this <Col><View style={{ alignItems: 'center' }}><Text>CENTER</Text></Col>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants