by @alexstyl
✉️ Leave your feedback

← Back to Foundation

focusGroup

Modifier
in
Foundation
. Since 1.2.0

Overview

Examples

Community Notes

@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") }
        }
    }
}
@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") }
            }
        }
    }
}
Next ComponentBaseTextField