Can't get basic layout to work #1067
-
Trying to have a row of squares with text centered within them. Can't seem to get it to work. I tried view.add(
<Layout layout gap={20} padding={20}>
<Rect width={100} height={100} fill="gray" radius={15}><Txt>0</Txt></Rect>
<Rect width={100} height={100} fill="gray" radius={15}><Txt>1</Txt></Rect>
<Rect width={100} height={100} fill="gray" radius={15}><Txt>2</Txt></Rect>
<Rect width={100} height={100} fill="gray" radius={15}><Txt>3</Txt></Rect>
</Layout>
); tried messing around with Any help appreciated, thanks! |
Beta Was this translation helpful? Give feedback.
Answered by
aarthificial
Jul 20, 2024
Replies: 1 comment 4 replies
-
You might want to try this:
|
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Apologies, I forgot that
Txt
nodes force-enable layout because they use it to lay out the text inside them.Setting
layout={false}
would work if you had a different node inside, say aCircle
.Well then,
justifyContent
would be the way to go in this case.Alternatively, you could wrap the
Txt
in it's ownLayout
and disable it this way:But that's probably more verbose than
justifyContent
+alignItems