Text alignment: one works, the other doesn't

i have created a small table with 2 columns and three rows each. i have created two different examples.

the first table was only created from text components within a grid.

in the second table, the text components are each in a container.

in the second table, the alignment of the text works without any problems.
but i can’t get the text alignment to work in the first table.

@dan what is the best way to solve this problem? is there a solution without containers, because I don’t need them at this point in the code.

Link to the project

Are you referring to the vertical alignment of the text not working?

I looked at the project and was able to get the first table to work by placing the text within a FLEX component, as it has controls that allow you to center both vertically and horizontally, as you have done in the second example with the container.

NOTE: I also removed the background color you were setting on the text and used the background of the flex for the colors.

The problem is that there is no VERTICAL text alignment, so using a text block on its own will not get you the vertical alignment. From what I can tell, Tailwind does not appear to have vertical alignment for text.

@handshaper

that’s what I want. thank you.

can you show me a screenshot of the setup? I guess you put 2 flexboxes in the grid and then split the text elements accordingly, right?

thx and regards

No, I put each of the text blocks in a flex and left them all in the existing grid as you had originally laid it out.

Unfortunately, I deleted the project so I can’t send a screenshot.

There are a number of ways this can be accomplished using a flex box. You could use them to create “rows”, or “columns”. I just tried to use what you had and leveraged the Flex to control the layout of the text block.

Hey @Pegasus,

Sorry for the delay on this one, somehow missed it… anyway, I added the following Tailwind css classes to the text component:

h-full flex items-center justify-center

How’s that?!

perfect! that is exactly what i need. :slight_smile:
then I will probably work with Tailwind CSS classes more often in the future

Yeah, it’s pretty cool what you can with classes, and that’s The Power of Elements!

I thought you wanted the text centered vertically as well. Looking at the image @dan posted, that does not seem to be the case. What am I missing?

@handshaper that’s what I thought at first. but the css-code works.

this saves me having to create a container or flex for each text element. they are absolutely superfluous for me at this point in the code

@Pegasus

the stretch setting was not helping

I turned off everything, then used the grid controls to centre the items, then applied padding afterwards

or you use margin vertical auto on each individual text and then apply padding

@upssjw that was exactly the starting point for my struggle with the text component

that was my starting set-up. with this setting, the text alignment fits, but the height of the background was no longer correct - hence the stretch setting.

i could then adjust the height of the background with a container or flex. but that was too much unnecessary code for me at this point.

the css classes for the text component are the best solution at the moment. it would of course be nice to be able to make the setting directly in the text component … it’s actually a niche problem but annoying if you don’t know how to solve it. ^^

thanks for your time and support :slight_smile:

Ah ok didn’t know you had a height restriction