I have create the desired effect in a not-so-elegant way using absolute positioning, however this is not very good for re-usability. Is there any way I can instead put these two items in a flex container together but somehow center only the text? Also I am using an MUI icon and it appears to have an invisible square around it that pushes it out of line and am not sure how to fix that as well.
Note I am using React and MUI but this seems to be more of a CSS question so it shouldn't matter too much:
export default function CreateGuest() {
const defaultText = 'Enter a display name'
const [guestDisplayName, setGuestDisplayName] = useState(defaultText)
return (
<Box
display="flex"
justifyContent="center"
margin="auto"
sx={{
width: 366,
height: 386,
backgroundColor: 'primary.contrastText',
boxShadow: '0 2px 3px #00000053',
}}
>
<Stack justifyContent="space-evenly">
<Typography
variant="h3"
component="pre"
textAlign="center"
sx={{ position: 'relative' }}
>
<ChevronLeftIcon
sx={{
fontSize: 48,
color: 'secondary.main',
position: 'absolute',
bottom: '43%',
right: '87%',
'&:hover': {
cursor: 'pointer',
},
}}
/>
{`Create a\nGuest User`}
</Typography>
<TextField
label={guestDisplayName === '' ? defaultText : guestDisplayName}
onChange={(e) => setGuestDisplayName(e.target.value)}
variant="outlined"
color="info"
></TextField>
<Button variant="contained">Create Guest</Button>
</Stack>
</Box>
)
}