Velaguides

Text and fonts

Text size, color, weight, family, alignment, wrapping and truncation on textlabel, textbutton and textbox.

Text classes work on the three Roblox text elements: textlabel, textbutton and textbox.

src/client/Title.tsx
<textlabel
className="text-2xl font-semibold text-slate-100 text-center align-middle"
Text="Match found"
/>
Three labels: size, weight, color and alignment, all from the text-* and font-* families.

The host restriction is editor-only

Put text classes on text elements only. The build won’t stop you: <frame className="text-red-500" /> compiles with no warning, and the class does nothing in game.

The editor extension does warn, with unsupported-host-utility. Install it from Editor setup to catch these.

The same rule covers image-* (for imagelabel and imagebutton) and placeholder-* (for textbox).

The restriction does not apply to components

On a component, Vela can’t know which element it renders, so it never warns:

No warning anywhere, in the editor or the build
<Title className="text-2xl font-semibold" Text="Match found" />

This only works if Title passes the classes on to a text element. See className on components.

How text-* is disambiguated

text-* can mean size, alignment, wrapping or color. Vela checks in this order:

  1. A size key (xs through 9xl) sets TextSize.
  2. left, center, right or justify sets TextXAlignment.
  3. wrap or nowrap sets TextWrapped.
  4. Anything else is a color.

So a typo like text-larg is read as a color, and you get unknown-theme-key. If you see that warning on a text-* class, check for a misspelled size or alignment.

Size

text-{size} sets TextSize:

ClassTextSize
text-xs12
text-sm14
text-base16
text-lg18
text-xl20
text-2xl24
text-3xl30
text-4xl36
text-5xl48
text-6xl60
text-7xl72
text-8xl96
text-9xl128

These sizes are fixed and don’t come from the theme. For another size, use a bracket: text-[13px].

The numbers are the sizes at a 1920×1020 screen. Vela scales them with the player’s viewport. See rem.

Weight, family and style

font-* sets weight or family. Weight, family and italic all combine into one FontFace:

font-mono font-bold italic
FontFace={new Font("rbxasset://fonts/families/RobotoMono.json", Enum.FontWeight.Bold, Enum.FontStyle.Italic)}

Weight

ClassEnum.FontWeight
font-thinThin
font-extralightExtraLight
font-lightLight
font-normalRegular
font-mediumMedium
font-semiboldSemiBold
font-boldBold
font-extraboldExtraBold
font-blackHeavy

italic makes the text italic. not-italic turns it back off.

Family

The theme ships three families:

ClassFamily
font-sansSource Sans Pro (the default)
font-serifMerriweather
font-monoRoboto Mono

Add your own under theme.extend.fontFamily. The value is a Roblox font asset path:

vela.config.ts
export default defineConfig({
theme: {
extend: {
fontFamily: {
display: "rbxassetid://12345678",
body: "rbxasset://fonts/families/Nunito.json",
},
},
},
});
<textlabel className="font-display font-bold" Text="Match found" />

A font-* class that is neither a weight nor a family reports unknown-theme-key.

Setting FontFace yourself

For a one-off font, set the FontFace prop and leave font-* off:

<textlabel
FontFace={new Font("rbxasset://fonts/families/GothamSSm.json", Enum.FontWeight.Bold)}
Text="Custom family"
/>

Don’t mix the two. font-bold and italic write a whole FontFace of their own.

Alignment

text-left, text-center and text-right set the horizontal alignment.

align-top, align-middle and align-bottom set the vertical alignment. Other align-* values report unsupported-text-alignment.

Roblox can’t justify text, so text-justify also reports unsupported-text-alignment.

Line height

leading-{key} sets LineHeight:

ClassLineHeight
leading-none1
leading-tight1.25
leading-snug1.375
leading-normal1.5
leading-relaxed1.625
leading-loose2

For another value, use a bracket: leading-[1.2]. Tailwind’s numbered forms like leading-5 report unsupported-line-height-value.

Wrapping and truncation

text-wrap turns wrapping on, and text-nowrap turns it off. whitespace-normal and whitespace-nowrap do the same. Other whitespace-* values report unsupported-whitespace-value.

truncate cuts overflowing text off with an ellipsis at the end:

src/client/PlayerRow.tsx
<textlabel className="text-sm text-nowrap truncate" Text={playerName} />

Case transforms rewrite the string

uppercase, lowercase, capitalize and normal-case change the Text string itself. With a literal string, Vela rewrites it at build time:

In
<textlabel className="uppercase" Text="match found" />
Out
<textlabel Text="MATCH FOUND" />

If Text is a variable, the change happens in game instead. The element then uses the runtime path.

Decorations use RichText

underline and line-through wrap the text in RichText tags and turn on RichText. no-underline removes them.

If you set RichText on the element yourself, Vela leaves the text alone and warns decoration-on-richtext.

Placeholders

placeholder-* sets the placeholder color on a textbox. placeholder-transparent and /N opacity don’t work, because Roblox has no placeholder transparency. See Colors and surfaces.

Typography families that cannot exist

These Tailwind classes have no Roblox equivalent. They report no-roblox-equivalent:

  • tracking-* (letter spacing).
  • indent-*, break-*, hyphens-* and list-*.
  • decoration-* and overline. RichText only has underline and strikethrough.

See also

  • Colors and surfaces: the color half of text-*, plus transparent and the shade rules.
  • Theming: where text-{color} keys come from.
  • Editor setup: getting the host warnings the build doesn’t give you.
  • Diagnostics: every code and what triggers it.