JengaFormLayout

fun JengaFormLayout(modifier: Modifier = Modifier, bottomBar: @Composable () -> Unit? = null, state: LazyListState = rememberLazyListState(), contentPadding: PaddingValues = JengaFormLayoutDefaults.contentPadding, spacing: Dp = JengaFormLayoutDefaults.spacing, content: LazyListScope.() -> Unit)(source)

A keyboard-aware form: a lazily laid out body of fields with an optional bottomBar (e.g. a submit button) pinned below it. When the keyboard opens, the body shrinks and the bottom bar rides on top of the keyboard, so the focused field and the primary action stay visible.

On Android the activity must draw edge to edge (or use adjustResize) for the keyboard insets to reach this layout.

Parameters

modifier

the Modifier for the layout.

bottomBar

optional content pinned below the form, above the keyboard.

state

the scroll state of the body.

contentPadding

padding around the form fields.

spacing

the gap between form items.

content

the form fields, laid out lazily in a LazyListScope.

Samples

var name by remember {
    mutableStateOf(
        value = "",
    )
}
JengaFormLayout(
    bottomBar = {
        JengaButton(
            text = "Save",
            onClick = {},
            modifier = Modifier.fillMaxWidth().padding(
                all = JengaTheme.spacing.lg,
            ),
        )
    },
    content = {
        item {
            JengaTextField(
                value = name,
                onValueChange = { name = it },
                label = "Customer name",
            )
        }
    },
)