androidx.compose.material3

OutlinedSecureTextFieldSince 1.9

Composable function

One of the text field types. It works like TextField. Only the parameters that differ are described here.

An outlined field for passwords.

A password field
A password field
OutlinedSecureTextField(
    state = rememberTextFieldState("hunter2"),
    label = { Text("Password") },
)

Parameters

@Composable
fun OutlinedSecureTextField(
    state: TextFieldState,
    modifier: Modifier = Modifier,
    enabled: Boolean = true,
    textStyle: TextStyle = LocalTextStyle.current,
    labelPosition: TextFieldLabelPosition = TextFieldLabelPosition.Cutout(),
    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 = OutlinedTextFieldDefaults.shape,
    colors: TextFieldColors = OutlinedTextFieldDefaults.colors(),
    contentPadding: PaddingValues = OutlinedTextFieldDefaults.defaultContentPadding(label, labelPosition),
    interactionSource: MutableInteractionSource? = null,
)

textObfuscationMode: TextObfuscationModeOptional

Default: 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

Default: DefaultObfuscationCharacter

The character shown instead of each hidden letter. Default: a dot.

Defaults that differ from TextField:

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

See also