I tried to put two different components of text in the same line utilizing Container
, but when I did that, the properties I’ve set in GeneralText
and Information
seem to go way. With the exception of the color I’ve set for Information
.
What would be the best way to approach this?
import React, { FC } from 'react';
import styled from 'styled-components/native';
const GeneralText = styled.Text`
font-size: 15px;
margin-left: 12px;
padding-bottom: 20px;
padding-top: 20px;
`;
const Information = styled.Text`
font-size: 15px;
margin-left: 300px;
padding-bottom: 20px;
padding-top: 20px;
color: grey;
`;
const Container = styled.Text`
flex: 65px;
`;
const Menu: FC<Props> = () => (
<Menu>
<Container>
<GeneralText>First Name</GeneralText>
<Information>John Smith</Information>
</Container>
</Menu>
);
export default Menu;
What I currently have
What I am trying to accomplish
3
Answers
Had to change
const Container = styled.Text
toconst Container = styled.View
as well as addingposition: absolute;
underneathInformation
can you try to use, justify-content: space-between in container..
I think you’ll get your answer. If you still face your problem, lemme know, i will help you.
Thanks
on the container you have to create a display: ‘flex’, flex-direction: ‘row’, justify-content: ‘space-between’