🌈 Create new beautiful Compose Gradients with our new wesite ->
Interface

UiMediaScope

A receiver scope that provides access to the properties of the current media environment.

Source set: Common
public interface UiMediaScope

A receiver scope that provides access to the properties of the current media environment. This scope is used by mediaQuery to evaluate conditions based on the device and window state.

Properties

windowPosture

Source set: Common
public val windowPosture: Posture

The current posture of the application window.

This reflects how the window is laid out on the screen, which may be affected by the device's physical state. See Posture for possible values.

windowWidth

Source set: Common
@get:FrequentlyChangingValue public val windowWidth: Dp

The current width of the application window.

windowHeight

Source set: Common
@get:FrequentlyChangingValue public val windowHeight: Dp

The current height of the application window.

pointerPrecision

Source set: Common
public val pointerPrecision: PointerPrecision

The highest-precision pointing device currently available.

This property resolves the pointer type based on all connected input devices, prioritizing higher precision (e.g., PointerPrecision.Fine takes precedence over PointerPrecision.Coarse if both are present). See PointerPrecision for all possible values.

keyboardKind

Source set: Common
public val keyboardKind: KeyboardKind

The type of keyboard currently available or connected.

This property prioritizes a physical keyboard connection (KeyboardKind.Physical) over an on-screen soft keyboard (KeyboardKind.Virtual). If neither is detected, it returns KeyboardKind.None.

hasMicrophone

Source set: Common
@get:Suppress("GetterSetterNames") public val hasMicrophone: Boolean

Whether the microphone is supported on the current device.

hasCamera

Source set: Common
@get:Suppress("GetterSetterNames") public val hasCamera: Boolean

Whether the camera is supported on the current device.

viewingDistance

Source set: Common
public val viewingDistance: ViewingDistance

The typical distance between the user and the device screen.

This property provides an estimate of the viewing distance, which can be useful for adjusting UI scale, content density, or hit target sizes for better ergonomics and readability.

Note that this is a broad categorization and does not represent a precise physical measurement. It is based on the device type and its typical usage context.

Members

Posture

Source set: Common
public class Posture private constructor(private val value: Int)

Describes the posture of the window, typically on a foldable device.

This represents the arrangement of the window's display area in relation to physical features like hinges or folds.

Note that this describes the window's state, which may differ from the physical device posture. For example, if the device is in a half-folded state but the app is in split-screen mode on a single panel, the window posture will be Posture.Flat.

Members

Companion

Source set: Common
public companion object

Properties

Flat

Source set: Common
public val Flat: Posture

Represents a flat posture, where the window's display area on a foldable device is flat (either fully open or closed). It's the default posture for non-foldable devices, or when the window does not span across a hinge or fold (such as in split-screen mode on a single panel).

Tabletop

Source set: Common
public val Tabletop: Posture

Represents a device in a semi-open state, similar to a laptop. The window spans across a horizontal fold or hinge, splitting the display area into two logical parts.

Book

Source set: Common
public val Book: Posture

Represents a device in a semi-open state, folded similarly to an open book. The window spans across a vertical fold or hinge, splitting the display area into two logical parts.

PointerPrecision

Source set: Common
public class PointerPrecision private constructor(private val value: Int)

Describes the precision of the available pointing devices.

Members

Companion

Source set: Common
public companion object

Properties

Fine

Source set: Common
public val Fine: PointerPrecision

Represents a pointing device with high precision, such as a mouse, trackpad, or stylus.

Coarse

Source set: Common
public val Coarse: PointerPrecision

Represents a pointing device with limited precision, such as a touchscreen.

Blunt

Source set: Common
public val Blunt: PointerPrecision

Represents a pointing device with low precision, such as a joystick.

None

Source set: Common
public val None: PointerPrecision

Indicates that no pointing device is available.

KeyboardKind

Source set: Common
public class KeyboardKind private constructor(private val value: Int)

Describes the kind of keyboard available.

Members

Companion

Source set: Common
public companion object

Properties

Physical

Source set: Common
public val Physical: KeyboardKind

Represents a physical hardware keyboard.

Virtual

Source set: Common
public val Virtual: KeyboardKind

Represents an on-screen virtual keyboard (IME).

None

Source set: Common
public val None: KeyboardKind

Indicates that no keyboard is currently available for input.

This state occurs when no physical keyboard is connected to the device, and the on-screen software keyboard (IME) is currently hidden or closed.

ViewingDistance

Source set: Common
public class ViewingDistance private constructor(private val value: Int)

Describes the typical distance between the user and the screen.

Members

Companion

Source set: Common
public companion object

Properties

Near

Source set: Common
public val Near: ViewingDistance

Represents a device used within close range, such as a handheld phone, tablet, laptop, or desktop monitor. This is the default for most personal devices.

Medium

Source set: Common
public val Medium: ViewingDistance

Represents a device positioned slightly further away, such as an automotive device, or a tablet in a dock mode.

Far

Source set: Common
public val Far: ViewingDistance

Represents a device viewed from a significant distance, such as a television.