androidx.compose.ui

Interfaces

Alignment

An interface to calculate the position of a sized box inside an available space.

Cmn
Alignment.Horizontal

An interface to calculate the position of box of a certain width inside an available width.

Cmn
Alignment.Vertical

An interface to calculate the position of a box of a certain height inside an available height.

Cmn
Modifier

An ordered, immutable collection of modifier elements that decorate or add behavior to Compose UI elements.

Cmn
Modifier.Element

A single element contained within a Modifier chain.

Cmn
MotionDurationScale

Provides a duration scale for motion such as animations.

Cmn

Classes

BiasAbsoluteAlignment

An Alignment specified by bias: for example, a bias of -1 represents alignment to the left/top, a bias of 0 will represent centering, and a bias of 1 will represent right/bottom.

Cmn
BiasAbsoluteAlignment.Horizontal

An Alignment.Horizontal specified by bias: for example, a bias of -1 represents alignment to the left, a bias of 0 will represent centering, and a bias of 1 will represent right.

Cmn
BiasAlignment

An Alignment specified by bias: for example, a bias of -1 represents alignment to the start/top, a bias of 0 will represent centering, and a bias of 1 will represent end/bottom.

Cmn
BiasAlignment.Horizontal

An Alignment.Horizontal specified by bias: for example, a bias of -1 represents alignment to the start, a bias of 0 will represent centering, and a bias of 1 will represent end.

Cmn
BiasAlignment.Vertical

An Alignment.Vertical specified by bias: for example, a bias of -1 represents alignment to the top, a bias of 0 will represent centering, and a bias of 1 will represent bottom.

Cmn
CombinedModifier

A node in a Modifier chain.

Cmn
ComposeScene

A virtual container that encapsulates Compose UI content.

android
Modifier.Node

The longer-lived object that is created for each Modifier.Element applied to a androidx.compose.ui.layout.Layout.

Cmn

Objects

AbsoluteAlignment

A collection of common Alignments unaware of the layout direction.

Cmn
Modifier.Companion

The companion object Modifier is the empty, default, or starter Modifier that contains no elements.

Cmn
MotionDurationScale.Key
Cmn

Annotations

ExperimentalComposeUiApi
Cmn
InternalComposeUiApi

Unstable API for use only between compose-ui modules sharing the same exact version, subject to change without notice in major, minor, or patch releases.

Cmn
UiComposable

An annotation that can be used to mark a composable function as being expected to be use in a composable function that is also marked or inferred to be marked as a UiComposable.

Cmn

Top-level functions summary

Unit
@ExperimentalComposeUiApi
configureSwingGlobalsForCompose(
    overrideLookAndFeel: Boolean,
    useScreenMenuBarOnMacOs: Boolean,
    useAutoDpiOnLinux: Boolean
)

Override global configuration for Swing that is needed for stand-alone Compose application.

android

Extension functions summary

Modifier
Modifier.composed(
    inspectorInfo: InspectorInfo.() -> Unit,
    factory: @Composable Modifier.() -> Modifier
)

Declare a just-in-time composition of a Modifier that will be composed for each element it modifies.

Cmn
Modifier
@ExperimentalComposeUiApi
Modifier.composed(
    fullyQualifiedName: String,
    key1: Any?,
    inspectorInfo: InspectorInfo.() -> Unit,
    factory: @Composable Modifier.() -> Modifier
)

Declare a just-in-time composition of a Modifier that will be composed for each element it modifies.

Cmn
Modifier
@ExperimentalComposeUiApi
Modifier.composed(
    fullyQualifiedName: String,
    vararg keys: Any?,
    inspectorInfo: InspectorInfo.() -> Unit,
    factory: @Composable Modifier.() -> Modifier
)

Declare a just-in-time composition of a Modifier that will be composed for each element it modifies.

Cmn
Modifier
@ExperimentalComposeUiApi
Modifier.composed(
    fullyQualifiedName: String,
    key1: Any?,
    key2: Any?,
    inspectorInfo: InspectorInfo.() -> Unit,
    factory: @Composable Modifier.() -> Modifier
)

Declare a just-in-time composition of a Modifier that will be composed for each element it modifies.

Cmn
Modifier
@ExperimentalComposeUiApi
Modifier.composed(
    fullyQualifiedName: String,
    key1: Any?,
    key2: Any?,
    key3: Any?,
    inspectorInfo: InspectorInfo.() -> Unit,
    factory: @Composable Modifier.() -> Modifier
)

Declare a just-in-time composition of a Modifier that will be composed for each element it modifies.

Cmn
Modifier

Materialize any instance-specific composed modifiers for applying to a raw tree node.

Cmn
Modifier

Creates a modifier that controls the drawing order for the children of the same layout parent.

Cmn

Top-level functions

configureSwingGlobalsForCompose

@ExperimentalComposeUiApi
fun configureSwingGlobalsForCompose(
    overrideLookAndFeel: Boolean = System.getProperty("skiko.rendering.laf.global", "true") == "true",
    useScreenMenuBarOnMacOs: Boolean = System.getProperty("skiko.rendering.useScreenMenuBar", "true") == "true",
    useAutoDpiOnLinux: Boolean = System.getProperty("skiko.linux.autodpi", "true") == "true"
): Unit

Override global configuration for Swing that is needed for stand-alone Compose application.

This function is called implicitly if you use awaitApplication / application / launchApplication and Compose for Desktop Gradle plugin tasks "run" or "package"

If you integrate Compose into existing Swing application (like IDEA), don't call this function as it affects the entire application.

This function:

  • sets system property apple.laf.useScreenMenuBar to true

  • sets system property sun.java2d.uiScale/sun.java2d.uiScale.enabled automatically on Linux

  • sets UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName())

Should be called before using any class from java.swing.* (even before SwingUtilities.invokeLater or Dispatchers.Swing)

Extension functions

composed

fun Modifier.composed(
    inspectorInfo: InspectorInfo.() -> Unit = NoInspectorInfo,
    factory: @Composable Modifier.() -> Modifier
): Modifier

Declare a just-in-time composition of a Modifier that will be composed for each element it modifies. composed may be used to implement stateful modifiers that have instance-specific state for each modified element, allowing the same Modifier instance to be safely reused for multiple elements while maintaining element-specific state.

If inspectorInfo is specified this modifier will be visible to tools during development. Specify the name and arguments of the original modifier.

Example usage:

import androidx.compose.ui.composed
import androidx.compose.ui.platform.debugInspectorInfo

// let's create your own custom stateful modifier
fun Modifier.myColorModifier(color: Color) = composed(
    // pass inspector information for debug
    inspectorInfo = debugInspectorInfo {
        // name should match the name of the modifier
        name = "myColorModifier"
        // specify a single argument as the value when the argument name is irrelevant
        value = color
    },
    // pass your modifier implementation that resolved per modified element
    factory = {
        // add your modifier implementation here
        Modifier
    }
)
import androidx.compose.ui.composed
import androidx.compose.ui.platform.debugInspectorInfo

// let's create your own custom stateful modifier with multiple arguments
fun Modifier.myModifier(width: Dp, height: Dp, color: Color) = composed(
    // pass inspector information for debug
    inspectorInfo = debugInspectorInfo {
        // name should match the name of the modifier
        name = "myModifier"
        // add name and value of each argument
        properties["width"] = width
        properties["height"] = height
        properties["color"] = color
    },
    // pass your modifier implementation that resolved per modified element
    factory = {
        // add your modifier implementation here
        Modifier
    }
)

materialize must be called to create instance-specific modifiers if you are directly applying a Modifier to an element tree node.

composed

@ExperimentalComposeUiApi
fun Modifier.composed(
    fullyQualifiedName: String,
    key1: Any?,
    inspectorInfo: InspectorInfo.() -> Unit = NoInspectorInfo,
    factory: @Composable Modifier.() -> Modifier
): Modifier

Declare a just-in-time composition of a Modifier that will be composed for each element it modifies. composed may be used to implement stateful modifiers that have instance-specific state for each modified element, allowing the same Modifier instance to be safely reused for multiple elements while maintaining element-specific state.

When keys are provided, composed produces a Modifier that will compare equals to another modifier constructed with the same keys in order to take advantage of caching and skipping optimizations. fullyQualifiedName should be the fully-qualified import name for your modifier factory function, e.g. com.example.myapp.ui.fancyPadding.

If inspectorInfo is specified this modifier will be visible to tools during development. Specify the name and arguments of the original modifier.

Example usage:

import androidx.compose.ui.composed
import androidx.compose.ui.platform.debugInspectorInfo

// let's create your own custom stateful modifier
fun Modifier.myColorModifier(color: Color) = composed(
    // pass inspector information for debug
    inspectorInfo = debugInspectorInfo {
        // name should match the name of the modifier
        name = "myColorModifier"
        // specify a single argument as the value when the argument name is irrelevant
        value = color
    },
    // pass your modifier implementation that resolved per modified element
    factory = {
        // add your modifier implementation here
        Modifier
    }
)
import androidx.compose.ui.composed
import androidx.compose.ui.platform.debugInspectorInfo

// let's create your own custom stateful modifier with multiple arguments
fun Modifier.myModifier(width: Dp, height: Dp, color: Color) = composed(
    // pass inspector information for debug
    inspectorInfo = debugInspectorInfo {
        // name should match the name of the modifier
        name = "myModifier"
        // add name and value of each argument
        properties["width"] = width
        properties["height"] = height
        properties["color"] = color
    },
    // pass your modifier implementation that resolved per modified element
    factory = {
        // add your modifier implementation here
        Modifier
    }
)

materialize must be called to create instance-specific modifiers if you are directly applying a Modifier to an element tree node.

composed

@ExperimentalComposeUiApi
fun Modifier.composed(
    fullyQualifiedName: String,
    vararg keys: Any?,
    inspectorInfo: InspectorInfo.() -> Unit = NoInspectorInfo,
    factory: @Composable Modifier.() -> Modifier
): Modifier

Declare a just-in-time composition of a Modifier that will be composed for each element it modifies. composed may be used to implement stateful modifiers that have instance-specific state for each modified element, allowing the same Modifier instance to be safely reused for multiple elements while maintaining element-specific state.

When keys are provided, composed produces a Modifier that will compare equals to another modifier constructed with the same keys in order to take advantage of caching and skipping optimizations. fullyQualifiedName should be the fully-qualified import name for your modifier factory function, e.g. com.example.myapp.ui.fancyPadding.

If inspectorInfo is specified this modifier will be visible to tools during development. Specify the name and arguments of the original modifier.

Example usage:

import androidx.compose.ui.composed
import androidx.compose.ui.platform.debugInspectorInfo

// let's create your own custom stateful modifier
fun Modifier.myColorModifier(color: Color) = composed(
    // pass inspector information for debug
    inspectorInfo = debugInspectorInfo {
        // name should match the name of the modifier
        name = "myColorModifier"
        // specify a single argument as the value when the argument name is irrelevant
        value = color
    },
    // pass your modifier implementation that resolved per modified element
    factory = {
        // add your modifier implementation here
        Modifier
    }
)
import androidx.compose.ui.composed
import androidx.compose.ui.platform.debugInspectorInfo

// let's create your own custom stateful modifier with multiple arguments
fun Modifier.myModifier(width: Dp, height: Dp, color: Color) = composed(
    // pass inspector information for debug
    inspectorInfo = debugInspectorInfo {
        // name should match the name of the modifier
        name = "myModifier"
        // add name and value of each argument
        properties["width"] = width
        properties["height"] = height
        properties["color"] = color
    },
    // pass your modifier implementation that resolved per modified element
    factory = {
        // add your modifier implementation here
        Modifier
    }
)

materialize must be called to create instance-specific modifiers if you are directly applying a Modifier to an element tree node.

composed

@ExperimentalComposeUiApi
fun Modifier.composed(
    fullyQualifiedName: String,
    key1: Any?,
    key2: Any?,
    inspectorInfo: InspectorInfo.() -> Unit = NoInspectorInfo,
    factory: @Composable Modifier.() -> Modifier
): Modifier

Declare a just-in-time composition of a Modifier that will be composed for each element it modifies. composed may be used to implement stateful modifiers that have instance-specific state for each modified element, allowing the same Modifier instance to be safely reused for multiple elements while maintaining element-specific state.

When keys are provided, composed produces a Modifier that will compare equals to another modifier constructed with the same keys in order to take advantage of caching and skipping optimizations. fullyQualifiedName should be the fully-qualified import name for your modifier factory function, e.g. com.example.myapp.ui.fancyPadding.

If inspectorInfo is specified this modifier will be visible to tools during development. Specify the name and arguments of the original modifier.

Example usage:

import androidx.compose.ui.composed
import androidx.compose.ui.platform.debugInspectorInfo

// let's create your own custom stateful modifier
fun Modifier.myColorModifier(color: Color) = composed(
    // pass inspector information for debug
    inspectorInfo = debugInspectorInfo {
        // name should match the name of the modifier
        name = "myColorModifier"
        // specify a single argument as the value when the argument name is irrelevant
        value = color
    },
    // pass your modifier implementation that resolved per modified element
    factory = {
        // add your modifier implementation here
        Modifier
    }
)
import androidx.compose.ui.composed
import androidx.compose.ui.platform.debugInspectorInfo

// let's create your own custom stateful modifier with multiple arguments
fun Modifier.myModifier(width: Dp, height: Dp, color: Color) = composed(
    // pass inspector information for debug
    inspectorInfo = debugInspectorInfo {
        // name should match the name of the modifier
        name = "myModifier"
        // add name and value of each argument
        properties["width"] = width
        properties["height"] = height
        properties["color"] = color
    },
    // pass your modifier implementation that resolved per modified element
    factory = {
        // add your modifier implementation here
        Modifier
    }
)

materialize must be called to create instance-specific modifiers if you are directly applying a Modifier to an element tree node.

composed

@ExperimentalComposeUiApi
fun Modifier.composed(
    fullyQualifiedName: String,
    key1: Any?,
    key2: Any?,
    key3: Any?,
    inspectorInfo: InspectorInfo.() -> Unit = NoInspectorInfo,
    factory: @Composable Modifier.() -> Modifier
): Modifier

Declare a just-in-time composition of a Modifier that will be composed for each element it modifies. composed may be used to implement stateful modifiers that have instance-specific state for each modified element, allowing the same Modifier instance to be safely reused for multiple elements while maintaining element-specific state.

When keys are provided, composed produces a Modifier that will compare equals to another modifier constructed with the same keys in order to take advantage of caching and skipping optimizations. fullyQualifiedName should be the fully-qualified import name for your modifier factory function, e.g. com.example.myapp.ui.fancyPadding.

If inspectorInfo is specified this modifier will be visible to tools during development. Specify the name and arguments of the original modifier.

Example usage:

import androidx.compose.ui.composed
import androidx.compose.ui.platform.debugInspectorInfo

// let's create your own custom stateful modifier
fun Modifier.myColorModifier(color: Color) = composed(
    // pass inspector information for debug
    inspectorInfo = debugInspectorInfo {
        // name should match the name of the modifier
        name = "myColorModifier"
        // specify a single argument as the value when the argument name is irrelevant
        value = color
    },
    // pass your modifier implementation that resolved per modified element
    factory = {
        // add your modifier implementation here
        Modifier
    }
)
import androidx.compose.ui.composed
import androidx.compose.ui.platform.debugInspectorInfo

// let's create your own custom stateful modifier with multiple arguments
fun Modifier.myModifier(width: Dp, height: Dp, color: Color) = composed(
    // pass inspector information for debug
    inspectorInfo = debugInspectorInfo {
        // name should match the name of the modifier
        name = "myModifier"
        // add name and value of each argument
        properties["width"] = width
        properties["height"] = height
        properties["color"] = color
    },
    // pass your modifier implementation that resolved per modified element
    factory = {
        // add your modifier implementation here
        Modifier
    }
)

materialize must be called to create instance-specific modifiers if you are directly applying a Modifier to an element tree node.

materialize

@<Error class: unknown class>
fun Composer.materialize(modifier: Modifier): Modifier

Materialize any instance-specific composed modifiers for applying to a raw tree node. Call right before setting the returned modifier on an emitted node. You almost certainly do not need to call this function directly.

zIndex

fun Modifier.zIndex(zIndex: Float): Modifier

Creates a modifier that controls the drawing order for the children of the same layout parent. A child with larger zIndex will be drawn on top of all the children with smaller zIndex. When children have the same zIndex the original order in which the parent placed the children is used.

Note that if there would be multiple zIndex modifiers applied for the same layout the sum of their values will be used as the final zIndex. If no zIndex were applied for the layout then the default zIndex is 0.

import androidx.compose.foundation.layout.Box
import androidx.compose.material.Text
import androidx.compose.ui.zIndex

Box {
    Text("Drawn second", Modifier.zIndex(1f))
    Text("Drawn first")
}