Velagetting started

Your first component

Build a small panel with Vela classes and see the Roblox properties and helper instances it compiles to.

On this page you build a panel with a title and a caption, put it on screen, and see what each class compiled to.

The panel this page builds, compiled by Vela and rendered in the browser.

The preview is live, not a screenshot. The Classes tab is the code below. The Lowered tab is what the compiler produced.

The component

src/client/Panel.tsx
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>
);
}

Put it on screen

Mount it like any @rbxts/react-roblox component:

src/client/main.client.tsx
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.

ClassResultValue
flexUIListLayout child, FillDirectionEnum.FillDirection.Horizontal
flex-colUIListLayout.FillDirectionEnum.FillDirection.Vertical
gap-4UIListLayout.Paddingnew UDim(0, 16)
p-4UIPadding child, all four sidesnew UDim(0, 16)
rounded-lgUICorner.CornerRadiusnew UDim(0, 8)
bg-slate-800BackgroundColor3Color3.fromRGB(29, 41, 61)
borderUIStroke.Thickness1
border-slate-700UIStroke.Color and TransparencyColor3.fromRGB(49, 65, 88), 0
w-80 h-24SizeUDim2.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:

  • flex and flex-col share one UIListLayout. flex-col alone is enough for a column.
  • Spacing numbers are multiplied by 4 pixels, so w-80 is 320 pixels.
  • w-80 and h-24 merge into a single Size.
  • border sets the thickness. border-slate-700 sets the color.
  • On the labels, text-lg sets TextSize, text-left sets TextXAlignment, and text-slate-100 sets TextColor3. 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:

Transformed output (line breaks added; nothing else changed)
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:

  • BorderSizePixel and BackgroundTransparency come from preflight. It stops Roblox drawing its default grey box. The panel keeps its background because bg-slate-800 paints it.
  • SortOrder = LayoutOrder is added to every layout so order-* works.
  • __VelaRem.scale is the viewport scaling. Pin theme.rem to 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 an opacity-* 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:

This warns
<frame className="tracking-wide p-4 bg-slate-800" />

The build still succeeds, with a warning:

Compiler output
[@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.