Compose Modifier

focusGroup

Creates a focus group or marks this component as a focus group.

FocusGroupSample

@Sampled
@Composable
fun FocusGroupSample() {
    Row {
        Column(Modifier.focusGroup()) {
            Button({}) { Text("Row1 Col1") }
            Button({}) { Text("Row2 Col1") }
            Button({}) { Text("Row3 Col1") }
        }
        Column(Modifier.focusGroup()) {
            Button({}) { Text("Row1 Col2") }
            Button({}) { Text("Row2 Col2") }
            Button({}) { Text("Row3 Col2") }
        }
    }
}

FocusableFocusGroupSample

@Sampled
@Composable
fun FocusableFocusGroupSample() {
    val interactionSource = remember { MutableInteractionSource() }
    LazyRow(
        Modifier.focusable(interactionSource = interactionSource)
            .border(1.dp, if (interactionSource.collectIsFocusedAsState().value) Red else Black)
    ) {
        repeat(10) { item { Button({}) { Text("Button$it") } } }
    }
}
Jetpack Compose beyond MaterialFree components, screens and templates for apps that don’t look like Google’s. Copy them into your app, or let your coding agent add them.Browse for free

Content updated: