New Compose Multiplatform components arrived on Composables UICheck it out →

Modifier in Compose Ui

focusProperties

Common

This modifier allows you to specify properties that are accessible to [focusTarget]s further down the modifier chain or on child layout nodes.

Last updated:

Installation

dependencies {
   implementation("androidx.compose.ui:ui:1.7.0-beta04")
}

Overloads


fun Modifier.focusProperties(
    scope: FocusProperties.() -> Unit
)

Code Example

FocusPropertiesSample

@Composable
@Sampled
fun FocusPropertiesSample() {
    Column {
        // Always focusable.
        Box(modifier = Modifier
            .focusProperties { canFocus = true }
            .focusTarget()
        )
        // Only focusable in non-touch mode.
        val inputModeManager = LocalInputModeManager.current
        Box(modifier = Modifier
            .focusProperties { canFocus = inputModeManager.inputMode != Touch }
            .focusTarget()
        )
    }
}