{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

ComposedModifierKt

public final class ComposedModifierKt


Summary

Public methods

static final @NonNull Modifier
composed(
    @NonNull Modifier receiver,
    @ExtensionFunctionType @NonNull Function1<@NonNull InspectorInfoUnit> inspectorInfo,
    @Composable @ExtensionFunctionType @NonNull Function1<@NonNull Modifier, @NonNull Modifier> factory
)

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

static final @NonNull Modifier
@ExperimentalComposeUiApi
composed(
    @NonNull Modifier receiver,
    @NonNull String fullyQualifiedName,
    Object key1,
    @ExtensionFunctionType @NonNull Function1<@NonNull InspectorInfoUnit> inspectorInfo,
    @Composable @ExtensionFunctionType @NonNull Function1<@NonNull Modifier, @NonNull Modifier> factory
)

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

static final @NonNull Modifier
@ExperimentalComposeUiApi
composed(
    @NonNull Modifier receiver,
    @NonNull String fullyQualifiedName,
    Object keys,
    @ExtensionFunctionType @NonNull Function1<@NonNull InspectorInfoUnit> inspectorInfo,
    @Composable @ExtensionFunctionType @NonNull Function1<@NonNull Modifier, @NonNull Modifier> factory
)

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

static final @NonNull Modifier
@ExperimentalComposeUiApi
composed(
    @NonNull Modifier receiver,
    @NonNull String fullyQualifiedName,
    Object key1,
    Object key2,
    @ExtensionFunctionType @NonNull Function1<@NonNull InspectorInfoUnit> inspectorInfo,
    @Composable @ExtensionFunctionType @NonNull Function1<@NonNull Modifier, @NonNull Modifier> factory
)

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

static final @NonNull Modifier
@ExperimentalComposeUiApi
composed(
    @NonNull Modifier receiver,
    @NonNull String fullyQualifiedName,
    Object key1,
    Object key2,
    Object key3,
    @ExtensionFunctionType @NonNull Function1<@NonNull InspectorInfoUnit> inspectorInfo,
    @Composable @ExtensionFunctionType @NonNull Function1<@NonNull Modifier, @NonNull Modifier> factory
)

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

static final @NonNull Modifier

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

Public methods

composed

public static final @NonNull Modifier composed(
    @NonNull Modifier receiver,
    @ExtensionFunctionType @NonNull Function1<@NonNull InspectorInfoUnit> inspectorInfo,
    @Composable @ExtensionFunctionType @NonNull Function1<@NonNull Modifier, @NonNull Modifier> factory
)

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.Modifier
import androidx.compose.ui.composed
import androidx.compose.ui.graphics.Color
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.Modifier
import androidx.compose.ui.composed
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.debugInspectorInfo
import androidx.compose.ui.unit.Dp

// 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
public static final @NonNull Modifier composed(
    @NonNull Modifier receiver,
    @NonNull String fullyQualifiedName,
    Object key1,
    @ExtensionFunctionType @NonNull Function1<@NonNull InspectorInfoUnit> inspectorInfo,
    @Composable @ExtensionFunctionType @NonNull Function1<@NonNull Modifier, @NonNull Modifier> factory
)

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.Modifier
import androidx.compose.ui.composed
import androidx.compose.ui.graphics.Color
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.Modifier
import androidx.compose.ui.composed
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.debugInspectorInfo
import androidx.compose.ui.unit.Dp

// 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
public static final @NonNull Modifier composed(
    @NonNull Modifier receiver,
    @NonNull String fullyQualifiedName,
    Object keys,
    @ExtensionFunctionType @NonNull Function1<@NonNull InspectorInfoUnit> inspectorInfo,
    @Composable @ExtensionFunctionType @NonNull Function1<@NonNull Modifier, @NonNull Modifier> factory
)

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.Modifier
import androidx.compose.ui.composed
import androidx.compose.ui.graphics.Color
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.Modifier
import androidx.compose.ui.composed
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.debugInspectorInfo
import androidx.compose.ui.unit.Dp

// 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
public static final @NonNull Modifier composed(
    @NonNull Modifier receiver,
    @NonNull String fullyQualifiedName,
    Object key1,
    Object key2,
    @ExtensionFunctionType @NonNull Function1<@NonNull InspectorInfoUnit> inspectorInfo,
    @Composable @ExtensionFunctionType @NonNull Function1<@NonNull Modifier, @NonNull Modifier> factory
)

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.Modifier
import androidx.compose.ui.composed
import androidx.compose.ui.graphics.Color
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.Modifier
import androidx.compose.ui.composed
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.debugInspectorInfo
import androidx.compose.ui.unit.Dp

// 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
public static final @NonNull Modifier composed(
    @NonNull Modifier receiver,
    @NonNull String fullyQualifiedName,
    Object key1,
    Object key2,
    Object key3,
    @ExtensionFunctionType @NonNull Function1<@NonNull InspectorInfoUnit> inspectorInfo,
    @Composable @ExtensionFunctionType @NonNull Function1<@NonNull Modifier, @NonNull Modifier> factory
)

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.Modifier
import androidx.compose.ui.composed
import androidx.compose.ui.graphics.Color
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.Modifier
import androidx.compose.ui.composed
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.debugInspectorInfo
import androidx.compose.ui.unit.Dp

// 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>
public static final @NonNull Modifier materialize(@NonNull Composer receiver, @NonNull 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.