Velagetting started

How it works

What happens to a file during the build, which elements Vela touches, and the two ways a className compiles.

Vela has two parts: a host adapter that decides which files to touch, and a native compiler that turns class names into Roblox properties. The transformer and the CLI share everything in between, so both produce the same Luau.

The pipeline

  1. A file reaches the adapter. With the transformer, rbxtsc loads the plugin, so plain tsc can’t run it. With the CLI, vela build walks your source folder itself.
  2. The adapter skips any file that isn’t .tsx, is a .d.ts, sits under node_modules, or has no className and JSX. See the configuration reference for the switches.
  3. The adapter finds the nearest vela.config.ts or vela.config.json above the file, or uses the default theme. See config discovery.
  4. The compiler resolves each class against your theme and returns new source text and diagnostics.
  5. The transformer swaps the new text in memory and reports diagnostics through roblox-ts. The CLI writes the file into .vela/src and prints diagnostics itself. It skips unchanged output, so rbxtsc -w isn’t woken for nothing.

What gets touched

Vela lowers className on eight Roblox host elements:

frame, scrollingframe, canvasgroup, textlabel, textbutton, textbox, imagelabel, imagebutton

It also lowers className on components. A component is any tag that starts with an uppercase letter, like <Panel />, or a member expression, like <Switch.Root />.

Anything else, such as screengui or a namespaced tag like <svg:rect />, keeps its className untouched and warns classname-on-unsupported-host.

className on components

<Panel className="p-4 bg-slate-800" /> works like a host element. The resolved properties become props on the component, className is removed, and helper instances are added as children:

In
<Box className="bg-slate-700 rounded-md" />
Out (shape, not verbatim)
<Box BackgroundColor3={Color3.fromRGB(49, 65, 88)}>
<uicorner CornerRadius={new UDim(0, 6)} />
</Box>

lattice-ui components are built to accept this. See Styling Lattice with Vela for a worked example.

Vela can’t know which host element a component renders. So inside a component’s className, every utility is allowed, and nothing checks whether text-lg makes sense there.

The two lowering paths

Every element takes one of two paths. The path decides whether anything runs in the game.

Static lowering

This is the default. The compiler resolves every class to a value, writes Roblox properties on the element, adds helper instances as children, and removes className. Nothing from Vela runs in the game.

Host elements with a className also start transparent and borderless, so you don’t get Roblox’s default grey box. That’s preflight. Components are never preflighted.

The runtime path

When Vela can’t finish at build time, it swaps the element’s tag for VelaRuntimeHost. That host reads the player’s screen size, input device and hover state in the game, then applies the matching classes.

The host lives in a shared package, @rbxts/vela-runtime. A file on this path only gains an import and a config object:

What a runtime-path module emits
import { createVelaRuntimeHost } from "@rbxts/vela-runtime";
const VelaRuntimeHost = createVelaRuntimeHost({ preflight: true, theme: { … }, plugins: { … } });

A Vide project imports @rbxts/vela-runtime-vide instead.

What triggers the runtime path

Any one of these is enough:

  • A className the compiler can’t read. A template literal with an interpolation, a variable, a function call, or a spread. A ternary like a ? "x" : "y" is different: the compiler still resolves and checks both sides, and only the condition is left for the game.

  • A variant prefix. Variants depend on the live game, so even a plain string goes this way:

    <frame className="w-full sm:w-1/2" />
  • A structural utility. Margins (except mx-auto and my-auto), divide-* and animate-* build extra frames or animation loops at runtime.

transition-* on its own doesn’t trigger the runtime path. With nothing to animate, it warns transition-without-runtime and is dropped.

Dynamic class names covers what you lose on the runtime path.

Five rules that keep you on the static path

Most “my class did nothing” reports come from an element that quietly took the runtime path.

  1. Write className as a plain string literal. A literal inside a .map() callback still counts.
  2. Write branches out. Use [base, on ? "bg-blue-600" : "bg-slate-700"] rather than building a string. Both looks stay checked at build time.
  3. Set changing numbers as props. Use Size={UDim2.fromScale(health, 1)} and let classes carry the rest. Don’t set the same property with both a class and a prop. The prop wins, and the build warns explicit-prop-overrides-class.
  4. Give every element a size. Roblox starts every element at zero size, so a missing h-* makes it invisible.
  5. Prefer gap-* to margins. Margins build a wrapper frame, which forces the runtime path. They also add to the parent’s gap.

Variants like hover: are worth the runtime path. A computed string where a plain one would do is not: the classes still work, but nothing checks them.

Next step

See what Vela deliberately leaves out in Scope and status.