[Full Release] Build Cross-Platform UI with the ViewportDisplaySize API

[Update] October 21, 2025

[Update] September 26, 2025

Hi Creators!

We’re excited to introduce a new API today in Studio beta: ViewportDisplaySize! This adaptive property makes it easy to build responsive, cross-platform UI by helping you tailor your UI to the physical viewing size of a player’s screen. The API categorizes the physical size of a player’s screen into Small, Medium, or Large classifications.

Our goal is to make cross-platform development as seamless as possible. ViewportDisplaySize helps you create a great user experience on any device and decouples design from inputs, whether it’s a phone, a tablet, a laptop, or a TV, without having to guess the display size based on resolution.

During this Studio beta period, you can’t publish live experiences with ViewportDisplaySize (it will throw a warning). Once we release the ViewportDisplaySize to client, these will be available to use in-experience.

Keep reading to learn more!


Why is ViewportDisplaySize Important?

Designing UI for small screens vs. large screens provide different challenges – you need to account for factors like different text legibility and UI layouts, to name a few. Relying on screen resolution (or pixel counts) to make design choices is error-prone, since a 4K phone and a 4K TV have the same number of pixels but vastly different physical dimensions.

ViewportDisplaySize solves this by categorizing the physical viewport into Small, Medium, or Large classifications. This allows you to adapt your UI based on the actual space available, ensuring your creations look and feel great everywhere.

Note: This API should not be used to make decisions about rendering quality. We are continuously working on ensuring your UI renders at a high quality on all devices regardless of the screen’s pixel density.

How to Enable this Beta

Click here to learn more

To enable this beta in Roblox Studio, follow these simple steps:

  1. Open Roblox Studio and navigate to the “File” menu.
  2. Click on “Beta Features”.
  3. Enable the “New Display Size API” option by checking the corresponding checkbox (see screenshot below) and press Save.
  4. Restart Roblox Studio when prompted.

How to Use ViewportDisplaySize

ViewportDisplaySize is a read-only property that returns a set of opinionated breakpoints – a DisplaySize enum of Small, Medium, or Large – based on the internally-fetched size of the viewport that the Roblox client is running on.

While device classes can have ranges of display sizes, they generally follow this categorization:

Enum Summary
Small Most tablet/mobile/handheld devices
Medium Most laptops and monitors
Large Most TVs or larger

Note that the viewport may not always fill the entire screen – say for example, when the Roblox client is confined to half of a laptop display.

Here’s an example of how you could use ViewportDisplaySize in a LocalScript in your experience to manage different UI states:

local GuiService = game:GetService("GuiService")

local function updateUI()
	if (GuiService.ViewportDisplaySize == Enum.DisplaySize.Small) then
		-- Update UI to small screen
	elseif (GuiService.ViewportDisplaySize == Enum.DisplaySize.Large) then
		-- Update UI to large screen
	else
		-- Update UI to medium/default screen
	end
end

GuiService:GetPropertyChangedSignal("ViewportDisplaySize"):Connect(updateUI)
updateUI()

Check out our sample placefile for one example of how UI can change depending on display size:
ViewportDisplaySize.rbxl (67.5 KB)

For more native customization, you can use the UI Style Editor (currently in Studio Beta) to configure themes for the various DisplaySize enums. Create tokens and themes for text sizes, container sizes, and any other sizing/measurement tokens to suit your needs. These can be dynamically swapped at run-time using the pseudocode structure above.

:blue_heart: Made with love

Special thanks to @LittleEel0621, @ProtoValence, and @MetaVars for their hard work in making this happen! We can’t wait to see the UI you create. Let us know if you have any feedback or questions.

168 Likes

This topic was automatically opened after 10 minutes.

When I saw this announcement I initially got very excited and thought "awesome!! I can now remove all of my janky code that determines if the user is on a tablet or on a phone and changes the UI. Then I saw that this feature does not distinguish between the two :frowning:

65 Likes

Perhaps this may be a stupid question but does this take into account DPI? My phone is 1080x2340 but significantly smaller than a TV of the same resolution would be.

13 Likes

Can’t access the ViewportDisplaySize.rbxl demo, it redirects me to a Google Drive that I don’t have access to.

Edit: It works now! Thanks :smiley:

5 Likes

Yeah, it’s neat but I don’t understand the point in having so little descriptors for size. I know barely anything about UI—I suck at making it and I suck more at making it look good—but even I would like to have a way to know what exact kind of device it is.

2 Likes

Fixed – let me know if it works now!

4 Likes

@media query from CSS vs. “Small”, “Medium” and “Large”. :thinking:

I hope nobody uses this API to identify whether a device is mobile or laptop.

 

It doesn’t say what minimum resolution counts as “Medium” yet. :thinking:

5 Likes

It works perfectly now! Thanks for the quick fix :smiley:

2 Likes

It’s not based on resolution or dpi, but physical size.

7 Likes

So the name of the device?

And then it looks up the dimensions of the actual physical device, e.g. “Phone” ?

Or how is physical size, determined?

1 Like

What if I mirror my phone to a TV or connect an xbox to a small display?

6 Likes

This is a very welcomed addition to the UI toolkit :smiley: :heart:

3 Likes

We’re detecting the physical size through vendor API. E.g. you can get the inches from Android/Apple. Other platforms are more complicated, but you can get a monitor size.

13 Likes

If you mirror, it’s based on the main screen (the phone). If you dock and switch to the TV, it will be based on the size of the TV.
I hope that helps!

10 Likes

How does that API look like? :thinking:

2 Likes

Hi! I’m curious to hear how you’re differentiating between tablet and phone UI – could you share more?

With how devices are evolving today, we’re seeing mobile phones that have a similar screen size as some tablets, and laptops with a similar screen size as other tablets.

2 Likes

I don’t see why a laptop screen size should be classified in the same category as a monitor.

That’s a wide range.

T-shirt sizes don’t really make much sense here either. Would’ve been better to classify this as what it is: laptop, tablet, phone, tv, etc.

Laptop screen size similarity with a tablet is accurate.

Tablet screen size similarity with a phone is inaccurate.

It’s quite the statement to assume that a phone and a tablet, on average, share similar screen size dimensions. I don’t see a need to “future proof” towards that direction.

Most people aren’t walking around with Samsung Folds, etc.

Most people have the standard iPhone / Android.

I agree with the other person. There needs to be separation between a tablet and a phone. If they share the same screen dimensions (or similar), it’s much easier for a developer to take into account both as opposed to being stuck in broad, blurred lines.

2c as someone who faces this issue frequently.

7 Likes

Should we rely on this for detecting if someone is using a specific device type? For example, if I wanted mobile buttons to only appear on phones and tablets then I would check if the enum is Small?

At the moment we have to use TouchEnabled and KeyboardEnabled for detection which is a bit hacky. If you hook up a keyboard to a tablet then KeyboardEnabled would be true and therefore may mess with the scripts trying to detect the device type.

Are we one day gonna get a reliable way of determining the device type?

But yes, this looks cool! Nice work team :happy3:

3 Likes

Is there a plan to add something like a UIViewportQuery Instance - similar to the UIContainerQuery Instance that is currently in development? Basically a way to make doing this more declarative.

5 Likes