Home › Utilities
Responsive
Flux.Responsive exposes the screen, input device, and player accessibility settings as shared reactive nodes, ready to read or bind directly with zero setup:
Flux.new "ScreenGui" {
Parent = playerGui,
Flux.new "Frame" {
Size = UDim2.fromOffset(800, 600),
Flux.new "UIScale" { Scale = Flux.Responsive.scale },
},
}All nodes listen live on the Roblox client and in Studio edit mode (so UI storybooks and Studio plugins react as you resize panes or switch input devices). On the server and in headless Luau, they hold static defaults (1920×1080, "desktop", "Medium" display/text size, "pc", "keyboard", reducedMotion = false, and preferredTransparency = 1).
For safe areas (the Roblox topbar, device notches, and rounded corners), configure Roblox's built-in ScreenGui.ScreenInsets (CoreUISafeInsets or DeviceSafeInsets) and ScreenGui.SafeAreaCompatibility.
Screen & Layout Nodes
Viewport
Flux.Responsive.viewport (Node<Vector2>) tracks workspace.CurrentCamera.ViewportSize live on the client and in Studio edit mode (defaulting to 1920×1080 on the server or headless CLI):
local isPortrait = Flux.computed(function()
local vp = Flux.Responsive.viewport()
return vp.Y > vp.X
end)Scale
Flux.Responsive.scale (Node<number>) computes a UI scale factor from viewport where 1.0 matches config.reference (1920×1080 by default, using "min" fit mode so UI never overflows):
Flux.new "UIScale" { Scale = Flux.Responsive.scale }Breakpoint
Flux.Responsive.breakpoint (Node<"phone" | "tablet" | "desktop">) classifies the viewport width (< 600 phone, < 1024 tablet, >= 1024 desktop by default). Pair it with Flux.switch to swap layouts by screen width:
Flux.switch(Flux.Responsive.breakpoint)({
phone = function(): GuiObject
return CompactLayout()
end,
tablet = function(): GuiObject
return CompactLayout()
end,
desktop = function(): GuiObject
return WideLayout()
end,
})Display Size
Flux.Responsive.displaySize (Node<"Small" | "Medium" | "Large">) mirrors GuiService.ViewportDisplaySize, indicating physical screen size ("Small" for phones and handhelds, "Medium" for monitors and laptops, "Large" for TVs and ten-foot interfaces).
Device & Input Nodes
Platform
Flux.Responsive.platform (Node<"pc" | "mobile" | "console" | "vr">) reflects the active device class on the client and in Studio edit mode, updating live if the player connects a keyboard and mouse or enters VR ("pc" on the server or headless CLI):
Flux.new "TextButton" {
Size = function()
return if Flux.Responsive.platform() == "pc"
then UDim2.fromOffset(160, 36)
else UDim2.fromOffset(200, 48)
end,
}Input
Flux.Responsive.input (Node<"keyboard" | "touch" | "gamepad">) tracks UserInputService.PreferredInput and LastInputTypeChanged live (mapping Gamepad1-Gamepad8 and MicroGamepad to "gamepad"), switching automatically when the player picks up a controller, touches the screen, or reaches for the mouse and keyboard:
local promptText = Flux.computed(function()
return if Flux.Responsive.input() == "gamepad" then "Press [A]" else "Click to Continue"
end)Accessibility Nodes
Text Size
Flux.Responsive.textSize (Node<"Medium" | "Large" | "Larger" | "Largest">) tracks GuiService.PreferredTextSize. Roblox scales text rendering automatically for this setting. Use textSize to give surrounding containers extra breathing room, not to multiply TextSize a second time.
Reduced Motion
Flux.Responsive.reducedMotion (Node<boolean>) tracks GuiService.ReducedMotionEnabled. When true, prefer instant state changes or subtle opacity fades over large movement or scale animations.
Preferred Transparency
Flux.Responsive.preferredTransparency (Node<number>) tracks GuiService.PreferredTransparency from 0 (fully opaque backgrounds) to 1 (default). Multiply translucent background transparencies by this node to respect the player's contrast preference:
Flux.new "Frame" {
BackgroundTransparency = function()
return 0.35 * Flux.Responsive.preferredTransparency()
end,
}Configuration
Flux.Responsive.config is a plain table read when scale and breakpoint first evaluate. Mutate it once at startup before reading Flux.Responsive.scale or Flux.Responsive.breakpoint to customize the default reference resolution, scale mode, clamps, or breakpoint widths:
Flux.Responsive.config.reference = Vector2.new(1280, 720)
Flux.Responsive.config.mode = "height" -- "min" (default) | "width" | "height" | "max"
Flux.Responsive.config.min = 0.5
Flux.Responsive.config.max = 2
Flux.Responsive.config.breakpoints = { phone = 700, tablet = 1100 }Per-Surface Overrides
Use Flux.Responsive.scaleOf(partialConfig?) and Flux.Responsive.breakpointOf(partialConfig?) to create derived nodes with custom thresholds or a custom viewport source (such as a SurfaceGui or Studio DockWidgetPluginGui):
local dockSize = Flux.property(dockWidget, "AbsoluteSize")
local dockScale = Flux.Responsive.scaleOf({
viewport = dockSize,
reference = Vector2.new(400, 600),
})
local dockBreakpoint = Flux.Responsive.breakpointOf({
viewport = dockSize,
breakpoints = { phone = 320, tablet = 480 },
})