feat(components): let an inline text field mask its value

KeyboardType.Password only tells the IME to drop suggestions; without a
visual transformation a borderless password field renders the secret in
the clear.
This commit is contained in:
makiolaj committed 2026-09-07 18:39:39 +02:00
1 parent ad440e8cac
commit 3dc3448265
1 file changed
+10
@@ -16,6 +16,7 @@ import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardCapitalization
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.text.input.VisualTransformation
import androidx.compose.ui.unit.dp
/**
@@ -42,6 +43,14 @@ fun InlineTextField(
imeAction: ImeAction = ImeAction.Default,
/** Invoked when the IME action key (e.g. Done) is pressed. */
onImeAction: (() -> Unit)? = null,
/**
* How the value is rendered, as opposed to stored.
*
* Exists so a password can be masked. [KeyboardType.Password] alone does
* not mask anything — it only tells the IME to drop suggestions — so a
* borderless field without this renders the secret in the clear.
*/
visualTransformation: VisualTransformation = VisualTransformation.None,
) {
val resolvedStyle = textStyle.copy(
color = when {
@@ -66,6 +75,7 @@ fun InlineTextField(
keyboardActions = onImeAction?.let { action ->
KeyboardActions(onAny = { action() })
} ?: KeyboardActions.Default,
visualTransformation = visualTransformation,
cursorBrush = SolidColor(MaterialTheme.colorScheme.primary),
decorationBox = { innerTextField ->
Box {