How do I make Roblox UI fit phone, tablet and desktop?
Updated
Position elements with Scale and an AnchorPoint so they stick to the same corner or edge on every screen. Size buttons, icons and text in Offset px, so a 44 px button stays 44 px. Size panels in Scale with a UISizeConstraint cap, keep square art square with a UIAspectRatioConstraint, and add one UIScale per ScreenGui for tablets and TVs.
Scale and Offset in one minute
Every UDim2 position and size has two parts. Scale is a percentage of the parent container. Offset is a number of pixels, which Roblox calls logical pixels. The two add up.
Roblox's cross-platform docs recommend Scale for positioning, because screens vary in pixel count and density. They also recommend Scale for sizing containers, with a warning: a panel 75% wide on every screen renders huge on a 4K TV.
Our rule: Scale places, Offset sizes the content
| What | Use | Why |
|---|---|---|
| Position | Scale plus an AnchorPoint into the corner or edge | It lands in the same spot on every screen shape |
| Buttons, icons, text | Offset px | A 44 px button stays 44 px; a 0.1 Scale height is 36 px of a 360 px tall screen and 108 px of a 1080 px one |
| Panels and lists | Scale, with a UISizeConstraint MaxSize and MinSize | It grows on tablets and desktops, then stops |
| Square art and cards | A UIAspectRatioConstraint | It keeps width to height fixed whatever the parent's shape |
Do not scale a 1920x1080 design down by screen height. One build that did, with a phone floor, came out 1.4-1.7 times the size top games use and covered 23-38% of a 667x375 phone.
One UIScale per ScreenGui
A UIScale multiplies the size of its parent and all its children, strokes and corners included. GuiService.ViewportDisplaySize tells you the screen class: Small for most phones and tablets, Medium for laptops and monitors, Large for TVs.
We use 1 on phones and desktops and 1.5 on TVs, the factor Roblox's own UI uses. Tablets have no class of their own, so we detect them by touch input and a safe frame whose short side is over 500 px.
-- LocalScript in a ScreenGui. Root: a Frame at Position (0, 0) that holds all of this gui's UI.
local GuiService = game:GetService("GuiService")
local UserInputService = game:GetService("UserInputService")
local gui = script.Parent
local root = gui:WaitForChild("Root")
local uiScale = Instance.new("UIScale")
uiScale.Parent = root
local function update()
local short = math.min(gui.AbsoluteSize.X, gui.AbsoluteSize.Y)
local touch = UserInputService.PreferredInput == Enum.PreferredInput.Touch
local k = 1
if GuiService.ViewportDisplaySize == Enum.DisplaySize.Large then
k = 1.5 -- TV
elseif touch and short > 500 then
k = 1.7 -- tablet
end
uiScale.Scale = k
root.Size = UDim2.fromScale(1 / k, 1 / k) -- the scaled root still fills the screen
end
GuiService:GetPropertyChangedSignal("ViewportDisplaySize"):Connect(update)
UserInputService:GetPropertyChangedSignal("PreferredInput"):Connect(update)
gui:GetPropertyChangedSignal("AbsoluteSize"):Connect(update)
update()The script listens for changes, because the screen class, the input and the safe frame can all change during a session. Resizing a desktop window is enough to change the frame.
The tablet factor of 1.7 is our judgment from a small sample of top games, matched to the step Roblox's touch controls take on tablets. Compare captures before you keep it.
Text that fits
- Roblox recommends AutomaticSize over TextScaled. With TextWrapped and AutomaticSize Y, a label grows to fit its lines at a constant font size.
- TextScaled text is not scaled by the player's preferred text size setting, and it stops growing at a font size of 100.
- Never let MinTextSize in a UITextSizeConstraint go under 9: Roblox says smaller text is hard to read.
Test on real screen shapes
Judge phone and tablet layouts only in Studio's Device Simulator, in Play. Never draw phone lines over a desktop capture. In our tests the 800x360 phone preset gave a 705x280 px safe frame, and the 874x402 notched phone 750x323.
- Build on the 800x360 phone first.
- Check the 874x402 notched phone, a 1180x820 tablet and a 1920x1080 desktop.
- Read AbsoluteSize of each panel and button on each device instead of eyeballing.
RoDesigner's design_guide tool, topic layout, serves these device sizes, floors and budgets to your agent as data.
Questions
Should I use Scale or Offset for everything?
Neither alone. Use Scale to place things and to size panels, and Offset px for buttons, icons and text.
Is there a plugin that converts Offset to Scale?
You do not need one if content stays in Offset on purpose. Convert only containers and positions, and check the result in the Device Simulator.
Why does my UI look fine in Studio but wrong on a phone?
Studio's default view is a desktop. A phone's safe frame can be 705x280 px, so judge it in the Device Simulator during Play.
Where these numbers come from
Scale is a percentage of the container's size; Offset is pixels; the two are additive.
UDim2 is a relative scale and an absolute offset in logical pixels.
Scale is recommended for positioning and for sizing, but 75% renders huge on 4K TVs; adapt to screen size.
UIScale multiplies the AbsoluteSize of its parent and scales all children, UIStroke and UICorner included.
ViewportDisplaySize: Small for most tablet and mobile devices, Medium for most laptops and monitors, Large for most TVs.
UIAspectRatioConstraint enforces a width-to-height ratio; UISizeConstraint sets the smallest and largest size in pixels.
Avoid TextScaled in favour of AutomaticSize; TextScaled text is not scaled by PreferredTextSize; TextScaled scales up to the maximum font size of 100.
Do not use MinTextSize values lower than 9.
Content in Offset px, containers in Scale with a UISizeConstraint; UIScale 1 on phone and desktop, 1.5 on Large (Roblox's own UI factor), 1.7 on tablets (judgment).
A 0.1 Scale height is 36 px of a 360 px tall screen and 108 px of a 1080 px one; a 44 px Offset button is 44 px on both.
Roblox's touch controls switch to their large size when the safe frame's short side is over 500 px.
Safe frames in Play: 705x280 px on the 800x360 phone preset, 750x323 on the 874x402 notched phone.
A 1080p design scaled by viewport height with a phone floor came out 1.4-1.7 times top-game sizes and covered 23-38% of a 667x375 phone.