Vertical Align
Places the text block inside the space its element has, on the vertical axis — the counterpart of text-align, which does the same on the horizontal one.
This is not the web’s vertical-align, which shifts an inline box against its line. There are no inline boxes here, so the property was given the job that TextMeshPro actually has for it.
:root { flex-direction: row; gap: 12px; padding: 20px; justify-content: center; background-color: #eef1f4; } .box { width: 90px; height: 110px; background-color: white; border-radius: 6px; } text { height: 100%; text-align: center; }
Values
top(default)middlebottombaseline— the first line’s baseline sits at the top of the element.capline— astop, but measured from the cap height rather than the ascender, so the tops of the capitals line up with the element’s edge.geometry— centered on the rendered glyphs rather than on the line metrics, which centers a short string more convincingly thanmiddledoes.
Notes
- It applies to the text inside the element, not to the element itself. To move an element within its parent, use
align-selfor the parent’salign-items. text-aligncan override it. TextMeshPro carries both axes in one alignment value, so atext-alignthat names a vertical position —top-left,bottom-rightand the rest of the combined spellings — sets the vertical alignment as well, andvertical-alignis then ignored. It is respected withtext-alignunset, or set to one of the horizontal-only values:left,center,right,justify,flush,startandend.- The property is inherited.