Creates a focus group or marks this component as a focus group.
FocusGroupSample
@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
@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") } } }
}
}