androidx.compose.material3
SecureTextFieldSince 1.9
Composable function
One of the text field types. It works like TextField. Only the parameters that differ are described here.
A filled field for passwords. It hides what the user types.

val state = rememberTextFieldState("hunter2")
SecureTextField(state = state, label = { Text("Password") })
Parameters
@Composable
fun SecureTextField(
state: TextFieldState,
modifier: Modifier = Modifier,
enabled: Boolean = true,
textStyle: TextStyle = LocalTextStyle.current,
labelPosition: TextFieldLabelPosition = TextFieldLabelPosition.Inside(),
label: @Composable (TextFieldLabelScope.() -> Unit)? = null,
placeholder: @Composable (() -> Unit)? = null,
leadingIcon: @Composable (() -> Unit)? = null,
trailingIcon: @Composable (() -> Unit)? = null,
prefix: @Composable (() -> Unit)? = null,
suffix: @Composable (() -> Unit)? = null,
supportingText: @Composable (() -> Unit)? = null,
isError: Boolean = false,
inputTransformation: InputTransformation? = null,
textObfuscationMode: TextObfuscationMode = TextObfuscationMode.RevealLastTyped,
textObfuscationCharacter: Char = DefaultObfuscationCharacter,
keyboardOptions: KeyboardOptions = SecureTextFieldKeyboardOptions,
onKeyboardAction: KeyboardActionHandler? = null,
onTextLayout: (Density.(getResult: () -> TextLayoutResult?) -> Unit)? = null,
shape: Shape = TextFieldDefaults.shape,
colors: TextFieldColors = TextFieldDefaults.colors(),
contentPadding: PaddingValues = if (label == null || labelPosition is TextFieldLabelPosition.Above) { TextFieldDefaults.contentPaddingWithoutLabel() } else { TextFieldDefaults.contentPaddingWithLabel() },
interactionSource: MutableInteractionSource? = null,
)
textObfuscationMode: TextObfuscationModeOptional
textObfuscationMode: TextObfuscationModeOptionalDefault: TextObfuscationMode.RevealLastTyped
How a secure field hides the text: hide all, show the last typed character briefly, or show all (for a "show password" toggle).
textObfuscationCharacter: CharOptional
textObfuscationCharacter: CharOptionalDefault: DefaultObfuscationCharacter
The character shown instead of each hidden letter. Default: a dot.
Defaults that differ from TextField:
keyboardOptions=SecureTextFieldKeyboardOptionscontentPadding=if (label == null || labelPosition is TextFieldLabelPosition.Above) { TextFieldDefaults.contentPaddingWithoutLabel() } else { TextFieldDefaults.contentPaddingWithLabel() }
Same as in TextField: state, modifier, enabled, textStyle, labelPosition, label, placeholder, leadingIcon, trailingIcon, prefix, suffix, supportingText, isError, inputTransformation, keyboardOptions, onKeyboardAction, onTextLayout, shape, colors, contentPadding, interactionSource.
Text field types
TextFieldOutlinedTextFieldSecureTextFieldOutlinedSecureTextField
See also
TextFieldDefaults: default values and helper functions forSecureTextField.