On this page you build a panel with a title and a caption, put it on screen, and see what each class compiled to.
import React from "@rbxts/react";
export function Panel() { return ( <frame className="flex flex-col gap-4 p-4 rounded-lg bg-slate-800 border border-slate-700 w-80 h-24"> <textlabel className="w-full h-6 text-left text-slate-100 text-lg font-semibold" Text="Loadout" /> <textlabel className="w-full h-5 text-left text-slate-400 text-sm" Text="Two slots remaining" /> </frame> );}import { __VelaBoundary } from "@rbxts/vela-runtime";import React from "@rbxts/react";export function Panel() { return <__VelaBoundary.Consume>{(<frame BackgroundColor3={Color3.fromRGB(29, 41, 61)} Size={UDim2.fromOffset(320, 96)} BorderSizePixel={0}><uilistlayout FillDirection={Enum.FillDirection.Vertical} Padding={new UDim(0, 16)} SortOrder={Enum.SortOrder.LayoutOrder}/><uipadding PaddingTop={new UDim(0, 16)} PaddingRight={new UDim(0, 16)} PaddingBottom={new UDim(0, 16)} PaddingLeft={new UDim(0, 16)}/><uicorner CornerRadius={new UDim(0, 8)}/><uistroke Thickness={1} Color={Color3.fromRGB(49, 65, 88)} Transparency={0}/> <textlabel Text="Loadout" TextXAlignment={Enum.TextXAlignment.Left} TextColor3={Color3.fromRGB(241, 245, 249)} TextSize={18} Size={new UDim2(1, 0, 0, 24)} FontFace={new Font("rbxasset://fonts/families/SourceSansPro.json", Enum.FontWeight.SemiBold)} BorderSizePixel={0} BackgroundTransparency={1}/> <textlabel Text="Two slots remaining" TextXAlignment={Enum.TextXAlignment.Left} TextColor3={Color3.fromRGB(144, 161, 185)} TextSize={14} Size={new UDim2(1, 0, 0, 20)} BorderSizePixel={0} BackgroundTransparency={1}/> </frame>)}</__VelaBoundary.Consume>;}The preview is live, not a screenshot. The Classes tab is the code below. The Lowered tab is what the compiler produced.
The component
import React from "@rbxts/react";
export function Panel() { return ( <frame className="flex flex-col gap-4 p-4 rounded-lg bg-slate-800 border border-slate-700 w-80 h-24"> <textlabel className="w-full h-6 text-left text-slate-100 text-lg font-semibold" Text="Loadout" /> <textlabel className="w-full h-5 text-left text-slate-400 text-sm" Text="Two slots remaining" /> </frame> );}Roblox elements start at zero size. Leave out h-24 and the panel compiles cleanly but is invisible. Use w-fit or h-fit to size to content instead.
Put it on screen
Mount it like any @rbxts/react-roblox component:
import React from "@rbxts/react";import { createPortal, createRoot } from "@rbxts/react-roblox";import { Players } from "@rbxts/services";import { Panel } from "./Panel";
const playerGui = Players.LocalPlayer.WaitForChild("PlayerGui");const root = createRoot(new Instance("Folder"));
root.render( createPortal( <screengui ResetOnSpawn={false} ZIndexBehavior={Enum.ZIndexBehavior.Sibling}> <Panel /> </screengui>, playerGui, ),);Vela doesn’t lower screengui, so put classes on a frame inside it. Keep the .tsx extension:
Vela only transforms .tsx files.
Build, sync with Rojo, and press play. The panel appears in your place.
What each class lowers to
Some classes set properties on the Frame. The rest become helper instances, because Roblox handles layout, padding, corners and strokes as separate objects.
| Class | Result | Value |
|---|---|---|
flex | UIListLayout child, FillDirection | Enum.FillDirection.Horizontal |
flex-col | UIListLayout.FillDirection | Enum.FillDirection.Vertical |
gap-4 | UIListLayout.Padding | new UDim(0, 16) |
p-4 | UIPadding child, all four sides | new UDim(0, 16) |
rounded-lg | UICorner.CornerRadius | new UDim(0, 8) |
bg-slate-800 | BackgroundColor3 | Color3.fromRGB(29, 41, 61) |
border | UIStroke.Thickness | 1 |
border-slate-700 | UIStroke.Color and Transparency | Color3.fromRGB(49, 65, 88), 0 |
w-80 h-24 | Size | UDim2.fromOffset(320, 96) |
The pixel values are what you get on a 1920×1020 screen. Vela scales them with the player’s viewport. See rem.
A few things to notice:
flexandflex-colshare oneUIListLayout.flex-colalone is enough for a column.- Spacing numbers are multiplied by 4 pixels, so
w-80is 320 pixels. w-80andh-24merge into a singleSize.bordersets the thickness.border-slate-700sets the color.- On the labels,
text-lgsetsTextSize,text-leftsetsTextXAlignment, andtext-slate-100setsTextColor3. Vela tells them apart by value, so a misspelled size is reported as an unknown color.
What comes out
Vela removes className, writes the resolved properties, and adds helper instances before your own
children. Here is the emitted code, with line breaks added:
import { createVelaRemScaler, __VelaOpacity } from "@rbxts/vela-runtime";const __VelaRem = createVelaRemScaler({ base: 16, min: 8, max: 64, baseResolution: { x: 1920, y: 1020 },});
<frame BackgroundColor3={Color3.fromRGB(29, 41, 61)} Size={__VelaRem.scale(UDim2.fromOffset(320, 96), 11)} BorderSizePixel={0}> <uilistlayout FillDirection={Enum.FillDirection.Vertical} Padding={__VelaRem.scale(new UDim(0, 16), 4)} SortOrder={Enum.SortOrder.LayoutOrder} /> <uipadding PaddingTop={__VelaRem.scale(new UDim(0, 16), 5)} PaddingRight={__VelaRem.scale(new UDim(0, 16), 6)} PaddingBottom={__VelaRem.scale(new UDim(0, 16), 7)} PaddingLeft={__VelaRem.scale(new UDim(0, 16), 8)} /> <uicorner CornerRadius={__VelaRem.scale(new UDim(0, 8), 9)} /> <uistroke Thickness={__VelaRem.scale(1, 10)} Color={Color3.fromRGB(49, 65, 88)} Transparency={0} /> <textlabel Text="Loadout" TextXAlignment={Enum.TextXAlignment.Left} TextColor3={Color3.fromRGB(241, 245, 249)} TextSize={__VelaRem.scaleText(18, 0)} Size={__VelaRem.scale(new UDim2(1, 0, 0, 24), 1)} FontFace={new Font("rbxasset://fonts/families/SourceSansPro.json", Enum.FontWeight.SemiBold)} BorderSizePixel={0} BackgroundTransparency={1} /> <textlabel Text="Two slots remaining" TextXAlignment={Enum.TextXAlignment.Left} TextColor3={Color3.fromRGB(144, 161, 185)} TextSize={__VelaRem.scaleText(14, 2)} Size={__VelaRem.scale(new UDim2(1, 0, 0, 20), 3)} BorderSizePixel={0} BackgroundTransparency={1} /></frame>Some of this isn’t in your class list:
BorderSizePixelandBackgroundTransparencycome from preflight. It stops Roblox drawing its default grey box. The panel keeps its background becausebg-slate-800paints it.SortOrder = LayoutOrderis added to every layout soorder-*works.__VelaRem.scaleis the viewport scaling. Pintheme.remto get plain numbers instead. The previews in these docs are pinned, which is why their Lowered tab shows plain numbers.- A component’s root is also wrapped in
<__VelaOpacity.Fade>, which isn’t shown above. It lets anopacity-*on a parent reach this subtree, and creates no instance.
Helper instances come before your own children. That doesn’t affect layout, but it matters if you index children by position.
Everything here was resolved and checked at build time. How it works explains when that stops being true.
Something that does not work
Vela isn’t a full port of Tailwind. Roblox has no letter spacing, so tracking-* can’t work:
<frame className="tracking-wide p-4 bg-slate-800" />The build still succeeds, with a warning:
[@vela-rbxts/compiler] no-roblox-equivalent: Tailwind "tracking" utilities have no Roblox equivalent, so "tracking-wide" is ignored.p-4 and bg-slate-800 still apply. Only tracking-wide is dropped. A class Vela has never heard
of, like a typo, warns unsupported-utility-family instead.
The diagnostics reference lists every warning and how to fix it.
Next step
Read How it works to see how Vela fits into the build, and when it switches to the runtime path.