12

I can't figure our how to make the Chakra component inline. Read the documentation but couldn't figure out the right property or if this is a css class thing.

<Text> Hello World, </Text>
<Text> place me next to the Text above! </Text>
Joundill
  • 6,828
  • 12
  • 36
  • 50
uber
  • 4,163
  • 5
  • 26
  • 55

3 Answers3

30

ChakraUI documentation on <Text> component explains that it renders a <p> tag by default.

But, you can swap it to work as a <span> tag, by giving <Text> the as prop. Like this:

<Text as="span"> Hello World, </Text>
<Text as="span"> place me next to the Text above! </Text>
Zeaneth
  • 471
  • 4
  • 5
4

You can use Flex for this

<Flex>
<Text> Hello World, </Text>
<Text> place me next to the Text above! </Text>
</Flex>
Asit Prakash
  • 341
  • 3
  • 9
1

I found the <Stack> tag useful. You can stack items horizontally as well as vertically:

<Stack direction='row'>
  <Text>Hello World, </Text>
  <Text>place me next to the Text above!</Text>
</Stack>

Alternatively there is a tag called <HStack> that does the same thing:

<HStack>
  <Text>Hello World, </Text>
  <Text>place me next to the Text above!</Text>
</HStack>

This results in: "Hello World, place me next to the Text above!"