We just launched Compose Examples featuring over 150+ components! Check it out →

focusProperties

Common

Modifier in Compose Ui

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.8.0-alpha04")
}

Overloads


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

Code Example

FocusPropertiesSample

@Composable
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()
        )
    }
}
by @alexstyl