Add your theme values to vela.config.ts under theme.extend. Each value is a roblox-ts
expression written as a string:
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)" }, }, },});import React from "@rbxts/react";
export function ThemedCard() { return ( <frame className="flex flex-col justify-center gap-3 w-72 h-28 p-gutter rounded-card bg-surface border border-brand-700"> <textlabel className="w-full h-5 text-left text-slate-100 text-sm font-semibold" Text="Season pass" /> <textbutton className="w-24 h-9 rounded-card bg-brand-500 text-white text-sm" Text="Claim" /> </frame> );}import { __VelaBoundary } from "@rbxts/vela-runtime";import React from "@rbxts/react";export function ThemedCard() { return <__VelaBoundary.Consume>{(<frame BackgroundColor3={Color3.fromRGB(24, 24, 27)} Size={UDim2.fromOffset(288, 112)} BorderSizePixel={0}><uilistlayout FillDirection={Enum.FillDirection.Vertical} HorizontalAlignment={Enum.HorizontalAlignment.Center} Padding={new UDim(0, 12)} SortOrder={Enum.SortOrder.LayoutOrder}/><uipadding PaddingTop={new UDim(0, 20)} PaddingRight={new UDim(0, 20)} PaddingBottom={new UDim(0, 20)} PaddingLeft={new UDim(0, 20)}/><uicorner CornerRadius={new UDim(0, 10)}/><uistroke Thickness={1} Color={Color3.fromRGB(67, 56, 202)} Transparency={0}/> <textlabel Text="Season pass" TextXAlignment={Enum.TextXAlignment.Left} TextColor3={Color3.fromRGB(241, 245, 249)} TextSize={14} Size={new UDim2(1, 0, 0, 20)} FontFace={new Font("rbxasset://fonts/families/SourceSansPro.json", Enum.FontWeight.SemiBold)} BorderSizePixel={0} BackgroundTransparency={1}/> <textbutton Text="Claim" BackgroundColor3={Color3.fromRGB(99, 102, 241)} TextColor3={Color3.fromRGB(255, 255, 255)} TextSize={14} Size={UDim2.fromOffset(96, 36)} BorderSizePixel={0}><uicorner CornerRadius={new UDim(0, 10)}/></textbutton> </frame>)}</__VelaBoundary.Consume>;}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’sUDim.new(0, 6).
Vela pastes that code into the output it emits.
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"becomesfoo.
Write colors as Color3.fromRGB(r, g, b) and UDims as new UDim(a, b), with plain numbers. Classes resolved in-game re-read the theme with parsers that accept only these, and anything else silently breaks there.
Or write the tokens as CSS
A vela.css file takes the values a design tool gives you
and converts them:
@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.colorsadds to the defaults. Your keys win on a collision.theme.colorsreplaces 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.
With a top-level theme.colors, Vela silently ignores theme.extend.colors, so your added colors fail with unknown-theme-key. Every axis works this way, unlike Tailwind, which applies both.
// 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.
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.
A layout tuned at 1920×1080 grows or shrinks on other viewports. To keep literal pixels, pin the clamp.
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:
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:
<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:
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.
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 noDEFAULT.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
- Configuration reference: the full schema, config discovery,
vela.cssand plugins. - Colors and surfaces: the utilities that use
theme.colorsandtheme.radius. - Layout and sizing: the utilities that use
theme.spacing. - Text and fonts: the utilities that use
theme.fontFamily.