Velaguides

Theming

Add your own theme values, extend versus replace, rem scaling, and the defaults.

Add your theme values to vela.config.ts under theme.extend. Each value is a roblox-ts expression written as a string:

vela.config.ts
import { defineConfig } from "vela-rbxts";
export default defineConfig({
theme: {
extend: {
colors: {
brand: {
500: "Color3.fromRGB(99, 102, 241)",
700: "Color3.fromRGB(67, 56, 202)",
},
surface: "Color3.fromRGB(24, 24, 27)",
},
radius: { card: "new UDim(0, 10)" },
spacing: { gutter: "new UDim(0, 20)" },
},
},
});
bg-surface, rounded-card, p-gutter and bg-brand-500 — all four keys come from the config above.

The preview compiles against that config with rem pinned, so one pixel is one pixel. The built-in text-slate-100 still works because the config extends the defaults instead of replacing them. Open the Lowered tab to see each value pasted in as written.

A theme has six axes: colors, radius, spacing, fontFamily, screens and rem. plugins and presets sit beside theme, not inside it. Tailwind keys like content, darkMode, prefix, safelist and variants are ignored.

Values are source code, not values

Write each value as roblox-ts code inside a string:

  • Colors: "Color3.fromRGB(59, 130, 246)".
  • Radius and spacing: "new UDim(0, 6)". This is roblox-ts syntax, not Luau’s UDim.new(0, 6).

Vela pastes that code into the output it emits.

vela.config.ts
export default defineConfig({
theme: {
extend: {
// correct — a roblox-ts expression, as a string
colors: { ink: "Color3.fromRGB(17, 24, 39)" },
radius: { pill: "new UDim(0.5, 0)" },
// wrong — accepted by the config, then fails when roblox-ts compiles it
// colors: { ink: "#111827" },
// wrong — not a string, so this throws at config-load time
// radius: { pill: 999 },
},
},
});

A number throws when the config loads. A wrong string is never rejected. Vela uses the first expression that parses and silently drops the rest:

  • "#3b82f6" becomes the string literal "#3b82f6", a type error on the next build.
  • "#a1b2c3" is emitted as a bare #a1b2c3, because # followed by a letter is valid TypeScript.
  • "Color3.fromRGB(1, 2, 3) // blue" loses the comment, and "foo bar" becomes foo.

Or write the tokens as CSS

A vela.css file takes the values a design tool gives you and converts them:

vela.css
@theme {
--color-brand-500: #3b82f6;
--radius-card: 12px;
--spacing-gutter: 20px;
}

#3b82f6 becomes Color3.fromRGB(59, 130, 246), and 12px becomes new UDim(0, 12). A value it can’t read, like hotpink, is a build error instead of a silent mistake.

A stylesheet only extends the theme. If you also have a vela.config.ts, the stylesheet applies on top of it. Keep rem, framework and anything that needs logic in the config file.

Extend merges, top-level replaces

  • theme.extend.colors adds to the defaults. Your keys win on a collision.
  • theme.colors replaces the whole scale. All 28 built-in color families are gone.

Colors merge shade by shade. Extending blue with only a 400 keeps the other ten shades.

vela.config.ts
// Do not do this — `brand` never resolves, and every built-in palette is dropped.
export default defineConfig({
theme: {
colors: { surface: "Color3.fromRGB(24, 24, 27)" },
extend: {
colors: { brand: { 500: "Color3.fromRGB(99, 102, 241)" } },
},
},
});

Use a top-level scale only when you want to start from empty, such as a locked-down design system where bg-slate-700 should be an error.

Rem

Pixel sizes in Vela scale with the screen. p-4, w-40, rounded-lg and text-sm are rem units, not raw pixels. One rem is 16px at 1920×1020 and scales from there. It’s on by default, with nothing to mount.

vela.config.ts — the defaults, written out
export default defineConfig({
theme: {
rem: {
base: 16,
min: 8,
max: 64,
baseResolution: { x: 1920, y: 1020 },
},
},
});

The curve follows Littensy’s rem provider. It compares the viewport diagonal with baseResolution, caps the width at 19:9 so ultrawide screens don’t inflate it, eases off in portrait, then rounds and clamps to [min, max].

theme.rem and theme.extend.rem do the same thing: both merge field by field.

What rem does not touch

Fractions like w-full, h-1/2 and translate-x-1/2 stay fractions of the parent. Colors, alignment, LayoutOrder and ZIndex have no pixels in them. TextSize scales, but stops at 100, the most Roblox honors.

Pinning offsets back to literal pixels

Set min and max to the base value:

vela.config.ts
export default defineConfig({
theme: { rem: { min: 16, max: 16 } },
});

Every viewport now gets the same rem, and Vela emits plain pixel values with no scaling code:

className="p-4 w-40" with the clamp closed
<frame Size={UDim2.fromOffset(160, 0)}>
<uipadding PaddingTop={new UDim(0, 16)} … />
</frame>

Pinning to any other value still scales, so the scaling code stays.

Anything inside a SurfaceGui or BillboardGui is already pinned, because those take their size from a part, not the screen. Change that list with rem.pinnedUnder. A container your JSX doesn’t create needs the closed clamp above.

What the emit looks like

Without the pin, each offset is wrapped in a scaler that updates when the viewport changes:

className="p-4 w-40" with rem active
import { createVelaRemScaler } from "@rbxts/vela-runtime";
const __VelaRem = createVelaRemScaler({ base: 16, min: 8, max: 64, baseResolution: { x: 1920, y: 1020 } });
<frame Size={__VelaRem.scale(UDim2.fromOffset(160, 0), 4)}>
<uipadding PaddingTop={__VelaRem.scale(new UDim(0, 16), 0)} … />
</frame>

The number after each value is a slot: one binding per scaled offset. TextSize goes through scaleText, which applies the 100 cap. An element on the runtime host scales the same props in-game instead.

Semantic colors and shade palettes

A color is either a literal, one expression used as-is, or a palette keyed by shade from 50 to 950. A palette only needs the shades you use.

Add a DEFAULT key so the bare family name works, as in bg-brand. Every built-in palette has one, equal to its 500. Write bg-brand, not bg-brand-DEFAULT, which reports unknown-theme-key.

vela.config.ts
theme: {
extend: {
colors: {
// literal — used as `bg-surface`, with no shade
surface: "Color3.fromRGB(24, 24, 27)",
// palette — used as `bg-brand-500`, or bare `bg-brand` for the DEFAULT
brand: {
DEFAULT: "Color3.fromRGB(99, 102, 241)",
500: "Color3.fromRGB(99, 102, 241)",
700: "Color3.fromRGB(67, 56, 202)",
},
},
},
}

Multi-word names are fine: bg-my-color looks up my-color. The last segment counts as a shade only if it’s one of the eleven shade numbers. So the only names you can’t use end in a hyphen plus a shade number.

Each mistake has its own diagnostic:

  • color-missing-shade: a bare palette name, and the palette has no DEFAULT.
  • color-invalid-shade: a shade on a literal, or a shade the palette doesn’t define.
  • unknown-theme-key: the name isn’t in the theme at all.

What ships by default

26 color palettes with eleven shades and a DEFAULT each, plus black and white. Ten radius keys and a DEFAULT. One spacing key, "4". Three font families, five breakpoints and the rem curve. The configuration reference lists every value.

Spacing is computed, not looked up: any multiple of 0.5 times 4px. p-1.5 is 6px and p-40 is 160px. Add spacing keys only for named steps like gutter. Because "4" is a real entry, redefining it changes p-4 but not p-3 or p-5. Editor completions suggest a short list of common steps, but any multiple of 0.5 works.

screens and fontFamily are the exceptions to expression strings. Breakpoints are plain numbers and fonts are asset paths. Don’t name a font family after a weight: font-bold always means the weight, so a fontFamily.bold never resolves.

See also