PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

TextYAlignment

TextLabel

TextYAlignment

TextYAlignment determines the vertical alignment (Y-axis) of text rendered within a UI element’s space. For Top and Bottom, text is rendered such that the top/bottom text bounds just touch the edge of the UI element rectangle. For Center, text is rendered such that there is an equal space from the top bounds of the text to the top of the element and the bottom bounds of the text to the bottom of the element.

This property is used in conjunction with TextLabel/TextXAlignment to fully determine text alignment on both axes. This property won’t affect the read-only properties TextLabel/TextBounds and TextLabel/TextFits.


Code Samples


Text Alignment

This code sample shows all the different text alignment combinations by iterating over each enum item. It is meant to be placed within a TextLabel, TextButton or TextBox.

-- Paste this in a LocalScript within a TextLabel/TextButton/TextBox
local textLabel = script.Parent

local function setAlignment(xAlign, yAlign)
	textLabel.TextXAlignment = xAlign
	textLabel.TextYAlignment = yAlign
	textLabel.Text = xAlign.Name .. " + " .. yAlign.Name
end

while true do
	-- Iterate over both TextXAlignment and TextYAlignment enum items
	for j, yAlign in pairs(Enum.TextYAlignment:GetEnumItems()) do
		for i, xAlign in pairs(Enum.TextXAlignment:GetEnumItems()) do
			setAlignment(xAlign, yAlign)
			wait(1)
		end
	end
end