Roblox has no CSS box model. Elements are placed by Position and AnchorPoint, sized by Size,
and laid out by child instances like UIListLayout and UIPadding. Vela’s layout classes set those
properties, or add those child instances for you.
<frame className="flex justify-between items-center gap-2"> <textlabel className="text-lg" Text="Inventory" /> <textbutton className="px-3 py-2 rounded-md bg-slate-700" Text="Close" /></frame>import React from "@rbxts/react";
export function Toolbar() { return ( <frame className="flex flex-col gap-3 w-96 h-36 p-4 rounded-lg bg-slate-900 border border-slate-800"> <frame className="flex items-center gap-3 w-full h-10 px-3 rounded-md bg-slate-800"> <textlabel className="w-52 h-5 text-left text-slate-100 text-sm" Text="Inventory" /> <textbutton className="w-16 h-7 rounded-md bg-sky-500 text-white text-sm" Text="Close" /> </frame>
<frame className="flex justify-center items-center gap-3 w-full h-14 p-2 rounded-md bg-slate-800"> <frame className="w-14 h-10 rounded bg-slate-700 border border-slate-600" /> <frame className="w-14 h-10 rounded bg-slate-700 border border-slate-600" /> <frame className="w-14 h-10 rounded bg-slate-700 border border-slate-600" /> </frame> </frame> );}import { __VelaBoundary } from "@rbxts/vela-runtime";import React from "@rbxts/react";export function Toolbar() { return <__VelaBoundary.Consume>{(<frame BackgroundColor3={Color3.fromRGB(15, 23, 43)} Size={UDim2.fromOffset(384, 144)} BorderSizePixel={0}><uilistlayout FillDirection={Enum.FillDirection.Vertical} Padding={new UDim(0, 12)} 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(29, 41, 61)} Transparency={0}/> <frame BackgroundColor3={Color3.fromRGB(29, 41, 61)} Size={new UDim2(1, 0, 0, 40)} BorderSizePixel={0}><uilistlayout FillDirection={Enum.FillDirection.Horizontal} VerticalAlignment={Enum.VerticalAlignment.Center} Padding={new UDim(0, 12)} SortOrder={Enum.SortOrder.LayoutOrder}/><uipadding PaddingLeft={new UDim(0, 12)} PaddingRight={new UDim(0, 12)}/><uicorner CornerRadius={new UDim(0, 6)}/> <textlabel Text="Inventory" TextXAlignment={Enum.TextXAlignment.Left} TextColor3={Color3.fromRGB(241, 245, 249)} TextSize={14} Size={UDim2.fromOffset(208, 20)} BorderSizePixel={0} BackgroundTransparency={1}/> <textbutton Text="Close" BackgroundColor3={Color3.fromRGB(0, 166, 244)} TextColor3={Color3.fromRGB(255, 255, 255)} TextSize={14} Size={UDim2.fromOffset(64, 28)} BorderSizePixel={0}><uicorner CornerRadius={new UDim(0, 6)}/></textbutton> </frame>
<frame BackgroundColor3={Color3.fromRGB(29, 41, 61)} Size={new UDim2(1, 0, 0, 56)} BorderSizePixel={0}><uilistlayout FillDirection={Enum.FillDirection.Horizontal} HorizontalAlignment={Enum.HorizontalAlignment.Center} VerticalAlignment={Enum.VerticalAlignment.Center} Padding={new UDim(0, 12)} SortOrder={Enum.SortOrder.LayoutOrder}/><uipadding PaddingTop={new UDim(0, 8)} PaddingRight={new UDim(0, 8)} PaddingBottom={new UDim(0, 8)} PaddingLeft={new UDim(0, 8)}/><uicorner CornerRadius={new UDim(0, 6)}/> <frame BackgroundColor3={Color3.fromRGB(49, 65, 88)} Size={UDim2.fromOffset(56, 40)} BorderSizePixel={0}><uicorner CornerRadius={new UDim(0, 4)}/><uistroke Thickness={1} Color={Color3.fromRGB(69, 85, 108)} Transparency={0}/></frame> <frame BackgroundColor3={Color3.fromRGB(49, 65, 88)} Size={UDim2.fromOffset(56, 40)} BorderSizePixel={0}><uicorner CornerRadius={new UDim(0, 4)}/><uistroke Thickness={1} Color={Color3.fromRGB(69, 85, 108)} Transparency={0}/></frame> <frame BackgroundColor3={Color3.fromRGB(49, 65, 88)} Size={UDim2.fromOffset(56, 40)} BorderSizePixel={0}><uicorner CornerRadius={new UDim(0, 4)}/><uistroke Thickness={1} Color={Color3.fromRGB(69, 85, 108)} Transparency={0}/></frame> </frame> </frame>)}</__VelaBoundary.Consume>;}Flex and UIListLayout
Flex, alignment, gap and wrap classes all go into one UIListLayout child.
flex and flex-row lay children out horizontally. flex-col lays them out vertically.
flex-row-reverse and flex-col-reverse report unsupported-flex-direction. Reorder the
children instead, or use order-*.
justify-* splits across two properties
Roblox keeps alignment and spacing-out in separate properties, so justify-* writes to one of two:
| Class | Property | Value |
|---|---|---|
justify-start | HorizontalAlignment | Enum.HorizontalAlignment.Left |
justify-center | HorizontalAlignment | Enum.HorizontalAlignment.Center |
justify-end | HorizontalAlignment | Enum.HorizontalAlignment.Right |
justify-between | HorizontalFlex | Enum.UIFlexAlignment.SpaceBetween |
justify-around | HorizontalFlex | Enum.UIFlexAlignment.SpaceAround |
justify-evenly | HorizontalFlex | Enum.UIFlexAlignment.SpaceEvenly |
justify-center justify-between sets both properties. The later class does not win. Roblox’s layout
combines them.
items-* and content-* work the same way on the vertical axis. items-start, items-center and
items-end set VerticalAlignment. items-stretch sets VerticalFlex = Fill.
These classes don’t follow the flex direction. justify-* is always horizontal and items-* is
always vertical, even under flex-col.
Wrapping and gap
flex-wrap and flex-nowrap set Wraps.
gap-{key} sets the list’s Padding. A list has one padding value, so there is no gap-x-* or
gap-y-*. space-y-2 is short for flex flex-col gap-2, and space-x-2 for flex gap-2.
With divide-*, items sit gap + line thickness apart,
as in CSS.
Flex items and UIFlexItem
These classes add a UIFlexItem child to the item itself. Several names map to the same mode:
| Class | UIFlexItem property |
|---|---|
flex-1 | FlexMode = Enum.UIFlexMode.Fill |
flex-auto | FlexMode = Enum.UIFlexMode.Fill |
flex-initial | FlexMode = Enum.UIFlexMode.Shrink |
flex-none | FlexMode = Enum.UIFlexMode.None |
grow | FlexMode = Enum.UIFlexMode.Grow |
grow-0 | FlexMode = Enum.UIFlexMode.None |
shrink | FlexMode = Enum.UIFlexMode.Shrink |
shrink-0 | FlexMode = Enum.UIFlexMode.None |
self-auto, self-start, self-center, self-end, self-stretch | ItemLineAlignment |
Numbered forms like grow-2 or flex-2 don’t exist. basis-{value} is the same as w-{value}.
Child order
order-{n} sets LayoutOrder, which the list sorts by. Negative values (-order-2) work, as do
order-first, order-last and order-none.
Under a divide-* parent, Vela rewrites each child’s LayoutOrder to its position. A component
child must forward LayoutOrder to its root. See divide
if separators land in the wrong place.
Grid and UIGridLayout
grid adds a UIGridLayout child. grid-cols-{n} (1–12) sets the number of columns, and
grid-rows-{n} the number of rows.
The grid sizes its own cells, so a w-* on a cell does nothing. The column count sets the width:
<uigridlayout FillDirectionMaxCells={2} CellSize={new UDim2(0.5, -5, 0, 100)} CellPadding={UDim2.fromOffset(10, 10)} />Rows stay 100px tall until you set auto-rows-* (or auto-cols-* under grid-rows-*). They use
the spacing scale, so auto-rows-24 is a 96px row.
gap-* sets CellPadding, and responsive gaps work: grid grid-cols-3 md:gap-4. Spans like
col-span-* and row-span-* report no-roblox-equivalent. More grid edge cases are in the
utilities reference.
Padding and UIPadding
Padding classes go into one UIPadding child. They work as in Tailwind: p-* sets all four
sides, px-* and py-* set one axis, and pt-*, pr-*, pb-* and pl-* set one side.
Margins are built, not native
Roblox has no margins, so Vela builds one. It wraps the element in a clear frame padded by the margin.
| Class | Effect |
|---|---|
m-*, mx-*, my-*, mt-*, mr-*, mb-*, ml-* | wraps the element in a margin frame |
-mt-*, -ml-* | shifts Position instead of wrapping |
-mr-*, -mb-* | unsupported-negative-margin |
mx-auto, my-auto | centers with AnchorPoint and Position, no wrapper |
A gap-2 column whose children have my-2 shows 16px gaps, not 8. Prefer gap-* for space between
list items.
Any margin moves the element onto the runtime path, even
in a plain string. m-0 and other zero margins are the exception.
Transitions and variants still work: m-4 w-20 transition-all hover:w-40 animates, and
mt-2 hover:mt-4 applies.
The spacing value grammar
Padding, margin, gap, min/max and size offsets all read numbers the same way:
- If the key is in
theme.spacing, Vela uses that value. - Otherwise the key must be a non-negative multiple of
0.5, and Vela multiplies it by 4.
So p-1.5 is 6px and p-40 is 160px. p-0.25 reports unknown-theme-key. A leading sign is
rejected.
The default theme has only one spacing key, so almost every number goes through step 2. To add named keys, see Theming.
Every pixel number on this page is the value at a 1920×1020 screen. Vela scales offsets with the player’s viewport. To keep literal pixels, pin the scale.
Sizing and Size
w-*, h-* and size-* set the element’s Size. Each axis accepts:
px: exactly 1 pixel.full: 100% of the parent.- A fraction, like
w-1/2. Only the fractions in the table below work. - A spacing number, like
w-40(160px).
| Denominator | Accepted numerators |
|---|---|
/2 | 1 |
/3 | 1, 2 |
/4 | 1, 3 |
/5 | 1, 2, 3, 4 |
/6 | 1, 5 |
/12 | 1 through 11 |
Write fractions in lowest terms. w-2/4 reports unknown-theme-key. Use w-1/2.
Automatic sizing
fit and auto set AutomaticSize instead of Size:
| Class | Property |
|---|---|
w-fit, w-auto | AutomaticSize = Enum.AutomaticSize.X |
h-fit, h-auto | AutomaticSize = Enum.AutomaticSize.Y |
size-fit, size-auto | AutomaticSize = Enum.AutomaticSize.XY |
w-fit h-fit | AutomaticSize = Enum.AutomaticSize.XY |
What gets emitted
Width and height merge into one Size, including under variants like md:w-32 md:h-32:
<frame className="w-full h-12" />// Size = UDim2.new(1, 0, 0, 48)
<frame className="w-1/2 h-1/2" />// Size = UDim2.fromScale(0.5, 0.5)
<frame className="w-40 h-8" />// Size = UDim2.fromOffset(160, 32)A custom spacing value with a scale part, like new UDim(0.5, 0), can’t be used for size. It
reports unsupported-size-spacing-value.
Min and max size
min-w-*, max-w-*, min-h-* and max-h-* add a UISizeConstraint child. They take pixel values
only, so max-w-1/2 doesn’t work.
An axis you don’t set has no limit: max-w-80 alone emits MaxSize = new Vector2(320, math.huge).
Position and anchor
Position classes set the element’s Position:
| Class | Effect |
|---|---|
left-* | sets the X component |
top-* | sets the Y component |
right-* | sets the X component, measured from the far edge |
bottom-* | sets the Y component, measured from the far edge |
inset-* | sets both components |
-left-*, -top-*, -inset-* | the same, negated |
They take the same values as sizing: px, full, fractions and spacing numbers.
right-* and bottom-* don’t move the anchor. The element’s top-left corner is still the point
being placed. Add origin-* to place a different corner:
<frame className="right-2 bottom-2 origin-bottom-right w-24 h-8" />Every Roblox element is already positioned relative to its parent, so absolute, relative and
fixed report no-roblox-equivalent. Inside a flex or grid parent, the layout controls position
and left-*/top-* have no effect.
origin-{key} sets AnchorPoint to a corner, an edge or the center. The nine keys are
origin-center, origin-top, origin-bottom, origin-left, origin-right, and the four corners
origin-top-left, origin-top-right, origin-bottom-left and origin-bottom-right. So
origin-center is (0.5, 0.5) and origin-bottom-right is (1, 1). Anything else reports
unsupported-anchor-value.
Translation
translate-x-* and translate-y-* shift the element. A fraction shifts by the element’s own size.
A pixel value adds to Position. The usual CSS centering pattern works:
<frame className="left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 w-96 h-40" />mx-auto and my-auto do the same centering on one axis.
A fractional translate sets AnchorPoint, so don’t combine it with origin-*. The later class wins.
Aspect ratio
aspect-{key} adds a UIAspectRatioConstraint child. aspect-square is 1 and aspect-video is
16:9. For other ratios, use a bracket:
<imagelabel className="w-full aspect-[16/9]" /><frame className="w-40 aspect-[2.35]" />aspect-auto reports unsupported-aspect-value.
Z-index
z-{value} sets ZIndex. The presets are z-0, z-10, z-20, z-30, z-40 and z-50. For
other levels, use a whole number in brackets: z-[15].
| Input | Diagnostic |
|---|---|
z-auto | unsupported-z-index-auto |
-z-10 | unsupported-negative-z-index |
z-[1.5] | unsupported-arbitrary-z-index |
z-5 | unsupported-z-index-value |
Rotation and scale
rotate-N and -rotate-N set Rotation in degrees. The presets are 0, 1, 2, 3, 6, 12,
45, 90 and 180. For any other angle, use a bracket: rotate-[17deg]. Other unbracketed
numbers report unsupported-rotation-value.
scale-N adds a UIScale child with Scale = N / 100. The values are 0, 50, 75, 90, 95,
100, 105, 110, 125 and 150, so scale-105 is 1.05. Other values, brackets included,
report unsupported-scale-value. Scaling is uniform, so there is
no scale-x-* or scale-y-*.
Visibility and clipping
hidden sets Visible = false. visible sets Visible = true.
overflow-hidden and overflow-clip set ClipsDescendants = true. overflow-visible sets it to
false. Other values report unsupported-overflow-value. To scroll, use a scrollingframe
element.
What layout still cannot express
- Grid spans and flow:
col-span-*,row-span-*,grid-flow-*. - CSS positioning:
absolute,relative,fixed,sticky,float,clear. - Per-axis gaps:
gap-x-*andgap-y-*. These reportunknown-theme-key, not an unknown-class warning. - Reversed direction:
flex-row-reverse,flex-col-reverse. Useorder-*.
See also
- Colors and surfaces for
bg-*,border-*, gradients, and shadows. - Responsive and input variants for breakpoint- and input-conditional layout.
- Recipes for these families composed into real interface pieces.
- Utilities reference for the complete class list.
- Diagnostics for every warning code named on this page.