I have a flexbox grouping consisting of two elements. The first is an arrow icon and the other is text. I want the items to be center aligned vertically. However, horizontally, I want the arrow to be left aligned and the text to be perfectly centered in the parent (flex) container. How can I accomplish this?
As you can see in the code, I tried using the alignSelf
property on the Text
element. However, as you can see in the screenshot I shared, that did not work. I am using the Chakra UI library. Here is the codesandbox.
import { Flex, Text } from "@chakra-ui/react";
import { ArrowBackIcon } from "@chakra-ui/icons";
<Flex alignItems="center" background="grey">
<ArrowBackIcon boxSize="32px" />
<Text fontSize="24px" fontWeight={700} alignSelf="center">
Confirm Your Information
</Text>
</Flex>