android-text-input-formslisted
Install: claude install-skill lenorebreakneck630/claude-zero-to-hero-android-KMP
# Android Text Input & Forms (Compose)
## Overview
Compose form patterns centre on three concerns: state (what the user has typed, what errors exist), keyboard (type, IME actions, navigation), and focus (moving between fields programmatically). Get these three right and every form — login, registration, checkout, settings — follows the same pattern.
---
## TextField vs OutlinedTextField
Both accept the same parameters. Choose based on your design system:
```kotlin
// Filled style — appropriate for forms inside a Surface
TextField(
value = state.email,
onValueChange = { onAction(FormAction.EmailChanged(it)) },
label = { Text("Email") },
modifier = Modifier.fillMaxWidth()
)
// Outlined style — stands out on a plain background
OutlinedTextField(
value = state.email,
onValueChange = { onAction(FormAction.EmailChanged(it)) },
label = { Text("Email") },
modifier = Modifier.fillMaxWidth()
)
```
Prefer `OutlinedTextField` in forms — the outline makes the input boundary obvious without requiring a filled background. Use `TextField` only if your design system explicitly uses the filled variant.
---
## Form State Model
Model form state as a single data class in the ViewModel's `UiState`. Each field gets a `value` and an `error`. Errors are typed as `UiText?` (null = no error) so they can be string resources or dynamic strings from the server.
```kotlin
// Presentation model — lives in feature:presentation
data class RegisterFormState(
val