Media Queries

CSS media queries are supported in ReactUnity. How to use media queries in CSS can be learned at MDN Docs. Programmatical usage also works.

These are different kind of media queries supported in ReactUnity.

Boolean typed media properties

Boolean properties are either true or false. There is no comparison required, only the existence of the property.

PropertyDescription
reactunityAlways true
allAlways true
screenAlways true, added for compatibility with browsers.
editorTrue for editor UIs
runtimeTrue for non-editor UIs
windowTrue for editor windows
inspectorTrue for editor inspector drawers
propertyTrue for editor property drawers
uguiTrue for UIs built with UGUI
uitoolkitTrue for UIs built with UIToolkit
full-screenTrue if game is in full-screen
consoleTrue if running in a console platform
mobileTrue if running in a mobile platform
batchTrue if running in batch mode
focusedTrue if game is currently in focus
editingTrue if currently in editor
playingTrue if inside built Player, or play state in editor

Example

@media (full-screen and ugui) {
...
}

String typed media properties

String typed media properties has a current value to compare with.

PropertyValid valuesDescription
frameworkugui or uitoolkitUI renderer backend
orientationlandscape or portraitThe value will be landscape if the game width is greater than height, portrait otherwise
cursorvisible or hiddenIs the mouse cursor visible or hidden (via Cursor.visible)
cursor-locklocked, confined or noneThe lock state of mouse cursor (via Cursor.lockState)
enginejint, clearscript or quickjsCurrent JavaScript engine
platformOne of the values in RuntimePlatformCurrent platform (via Application.platform).
systemwindows, linux, macosx or otherCurrent operating system (via SystemInfo.operatingSystemFamily).
device-typedesktop, console, handheld or unknownCurrent device type (via SystemInfo.deviceType).
genuineyes, no or unknownWas the application files modified after build (via Application.genuine)
languageOne of the values in SystemLanguageCurrent system language (via Application.systemLanguage)
install-modeOne of the values in ApplicationInstallModeCurrent install mode (via Application.installMode)
full-screen-modeexclusive, borderless, maximised or windowedCurrent full screen mode (via Screen.fullScreenMode)
display-modefullscreen, editor, or standaloneWhether the app is in fullscreen, editor or neither of them. Added for browser compatibility.
skinlight or dark(Editor Only) Currently used editor theme
pointerfine, coarse or noneThe pointing accuracy of current pointer device. coarse for touch, and fine for mouse devices.
any-pointerfine, coarse or noneThe list of pointing accuracy of available pointer devices
hoverhover or noneIs the current pointer device capable of hovering (e.g. mouse)
any-hoverhover or noneDoes the device has any pointer device that is capable of hovering (e.g. mouse)
inputgamepad, touch, mouse, pen, keyboard, joystick, pointer, otherHas the value of last updated input device (Input System only)
any-inputSame as inputList of all available input devices

Example

@media (system: windows) or (platform: iphoneplayer) {
...
}

Numeric media properties

Numeric media properties has a current value that can be compared with numerically. They support min- and max- prefixes, as well as =, <, <=, > and >= operators.

PropertyDescription
widthWidth of the root element
heightHeight of the root element
aspect-ratioWidth/height of the root element
window-widthWidth of the game window
window-heightHeight of the game window
window-aspect-ratioWidth/height of the game window
screen-widthWidth of the current screen
screen-heightHeight of the current screen
screen-aspect-ratioWidth/height of the current screen
screen-refresh-rateRefresh rate of the current screen
screen-dpiDPI of the current screen
screen-brightnessBrightness of the current screen
target-fpsTarget frame rate (via Application.targetFrameRate)

Example

@media (aspect-ratio: 1.6) and (1024 >= window-width >= 2160) {
...
}