TextFieldDefaults


Contains the default values used by TextField. For defaults used in OutlinedTextField, see OutlinedTextFieldDefaults.

Summary

Public functions

Unit
@ExperimentalMaterial3Api
@Composable
ContainerBox(
    enabled: Boolean,
    isError: Boolean,
    interactionSource: InteractionSource,
    colors: TextFieldColors,
    shape: Shape
)

Composable that draws a default container for the content of TextField, with an indicator line at the bottom.

Cmn
Unit
@Composable
@ExperimentalMaterial3Api
DecorationBox(
    value: String,
    innerTextField: @Composable () -> Unit,
    enabled: Boolean,
    singleLine: Boolean,
    visualTransformation: VisualTransformation,
    interactionSource: InteractionSource,
    isError: Boolean,
    label: (@Composable () -> Unit)?,
    placeholder: (@Composable () -> Unit)?,
    leadingIcon: (@Composable () -> Unit)?,
    trailingIcon: (@Composable () -> Unit)?,
    prefix: (@Composable () -> Unit)?,
    suffix: (@Composable () -> Unit)?,
    supportingText: (@Composable () -> Unit)?,
    shape: Shape,
    colors: TextFieldColors,
    contentPadding: PaddingValues,
    container: @Composable () -> Unit
)

A decoration box which helps creating custom text fields based on Material Design filled text field.

Cmn
Unit
@ExperimentalMaterial3Api
@Composable
FilledContainerBox(
    enabled: Boolean,
    isError: Boolean,
    interactionSource: InteractionSource,
    colors: TextFieldColors,
    shape: Shape
)

This function is deprecated. Renamed to `TextFieldDefaults.ContainerBox`

Cmn
Unit
@ExperimentalMaterial3Api
@Composable
OutlinedBorderContainerBox(
    enabled: Boolean,
    isError: Boolean,
    interactionSource: InteractionSource,
    colors: TextFieldColors,
    shape: Shape,
    focusedBorderThickness: Dp,
    unfocusedBorderThickness: Dp
)

This function is deprecated. Renamed to `OutlinedTextFieldDefaults.ContainerBox`

Cmn
Unit
@Composable
@ExperimentalMaterial3Api
OutlinedTextFieldDecorationBox(
    value: String,
    innerTextField: @Composable () -> Unit,
    enabled: Boolean,
    singleLine: Boolean,
    visualTransformation: VisualTransformation,
    interactionSource: InteractionSource,
    isError: Boolean,
    label: (@Composable () -> Unit)?,
    placeholder: (@Composable () -> Unit)?,
    leadingIcon: (@Composable () -> Unit)?,
    trailingIcon: (@Composable () -> Unit)?,
    prefix: (@Composable () -> Unit)?,
    suffix: (@Composable () -> Unit)?,
    supportingText: (@Composable () -> Unit)?,
    colors: TextFieldColors,
    contentPadding: PaddingValues,
    container: @Composable () -> Unit
)

This function is deprecated. Renamed to `OutlinedTextFieldDefaults.DecorationBox`

Cmn
Unit
@Composable
@ExperimentalMaterial3Api
TextFieldDecorationBox(
    value: String,
    innerTextField: @Composable () -> Unit,
    enabled: Boolean,
    singleLine: Boolean,
    visualTransformation: VisualTransformation,
    interactionSource: InteractionSource,
    isError: Boolean,
    label: (@Composable () -> Unit)?,
    placeholder: (@Composable () -> Unit)?,
    leadingIcon: (@Composable () -> Unit)?,
    trailingIcon: (@Composable () -> Unit)?,
    prefix: (@Composable () -> Unit)?,
    suffix: (@Composable () -> Unit)?,
    supportingText: (@Composable () -> Unit)?,
    shape: Shape,
    colors: TextFieldColors,
    contentPadding: PaddingValues,
    container: @Composable () -> Unit
)

This function is deprecated. Renamed to `TextFieldDefaults.DecorationBox`

Cmn
TextFieldColors

Creates a TextFieldColors that represents the default input text, container, and content colors (including label, placeholder, icons, etc.) used in a TextField.

Cmn
TextFieldColors
@Composable
colors(
    focusedTextColor: Color,
    unfocusedTextColor: Color,
    disabledTextColor: Color,
    errorTextColor: Color,
    focusedContainerColor: Color,
    unfocusedContainerColor: Color,
    disabledContainerColor: Color,
    errorContainerColor: Color,
    cursorColor: Color,
    errorCursorColor: Color,
    selectionColors: TextSelectionColors?,
    focusedIndicatorColor: Color,
    unfocusedIndicatorColor: Color,
    disabledIndicatorColor: Color,
    errorIndicatorColor: Color,
    focusedLeadingIconColor: Color,
    unfocusedLeadingIconColor: Color,
    disabledLeadingIconColor: Color,
    errorLeadingIconColor: Color,
    focusedTrailingIconColor: Color,
    unfocusedTrailingIconColor: Color,
    disabledTrailingIconColor: Color,
    errorTrailingIconColor: Color,
    focusedLabelColor: Color,
    unfocusedLabelColor: Color,
    disabledLabelColor: Color,
    errorLabelColor: Color,
    focusedPlaceholderColor: Color,
    unfocusedPlaceholderColor: Color,
    disabledPlaceholderColor: Color,
    errorPlaceholderColor: Color,
    focusedSupportingTextColor: Color,
    unfocusedSupportingTextColor: Color,
    disabledSupportingTextColor: Color,
    errorSupportingTextColor: Color,
    focusedPrefixColor: Color,
    unfocusedPrefixColor: Color,
    disabledPrefixColor: Color,
    errorPrefixColor: Color,
    focusedSuffixColor: Color,
    unfocusedSuffixColor: Color,
    disabledSuffixColor: Color,
    errorSuffixColor: Color
)

Creates a TextFieldColors that represents the default input text, container, and content colors (including label, placeholder, icons, etc.) used in a TextField.

Cmn
PaddingValues
contentPaddingWithLabel(start: Dp, end: Dp, top: Dp, bottom: Dp)

Default content padding applied to TextField when there is a label.

Cmn
PaddingValues
contentPaddingWithoutLabel(start: Dp, top: Dp, end: Dp, bottom: Dp)

Default content padding applied to TextField when the label is null.

Cmn
Modifier
@ExperimentalMaterial3Api
Modifier.indicatorLine(
    enabled: Boolean,
    isError: Boolean,
    interactionSource: InteractionSource,
    colors: TextFieldColors,
    focusedIndicatorLineThickness: Dp,
    unfocusedIndicatorLineThickness: Dp
)

A modifier to draw a default bottom indicator line in TextField.

Cmn
TextFieldColors
@ExperimentalMaterial3Api
@Composable
outlinedTextFieldColors(
    focusedTextColor: Color,
    unfocusedTextColor: Color,
    disabledTextColor: Color,
    errorTextColor: Color,
    containerColor: Color,
    errorContainerColor: Color,
    cursorColor: Color,
    errorCursorColor: Color,
    selectionColors: TextSelectionColors,
    focusedBorderColor: Color,
    unfocusedBorderColor: Color,
    disabledBorderColor: Color,
    errorBorderColor: Color,
    focusedLeadingIconColor: Color,
    unfocusedLeadingIconColor: Color,
    disabledLeadingIconColor: Color,
    errorLeadingIconColor: Color,
    focusedTrailingIconColor: Color,
    unfocusedTrailingIconColor: Color,
    disabledTrailingIconColor: Color,
    errorTrailingIconColor: Color,
    focusedLabelColor: Color,
    unfocusedLabelColor: Color,
    disabledLabelColor: Color,
    errorLabelColor: Color,
    focusedPlaceholderColor: Color,
    unfocusedPlaceholderColor: Color,
    disabledPlaceholderColor: Color,
    errorPlaceholderColor: Color,
    focusedSupportingTextColor: Color,
    unfocusedSupportingTextColor: Color,
    disabledSupportingTextColor: Color,
    errorSupportingTextColor: Color,
    focusedPrefixColor: Color,
    unfocusedPrefixColor: Color,
    disabledPrefixColor: Color,
    errorPrefixColor: Color,
    focusedSuffixColor: Color,
    unfocusedSuffixColor: Color,
    disabledSuffixColor: Color,
    errorSuffixColor: Color
)

This function is deprecated. Renamed to `OutlinedTextFieldDefaults.colors` with additional parameters tocontrol container color based on state.

Cmn
PaddingValues
outlinedTextFieldPadding(start: Dp, top: Dp, end: Dp, bottom: Dp)

This function is deprecated. Renamed to `OutlinedTextFieldDefaults.contentPadding`

Cmn
TextFieldColors
@ExperimentalMaterial3Api
@Composable
textFieldColors(
    focusedTextColor: Color,
    unfocusedTextColor: Color,
    disabledTextColor: Color,
    errorTextColor: Color,
    containerColor: Color,
    errorContainerColor: Color,
    cursorColor: Color,
    errorCursorColor: Color,
    selectionColors: TextSelectionColors,
    focusedIndicatorColor: Color,
    unfocusedIndicatorColor: Color,
    disabledIndicatorColor: Color,
    errorIndicatorColor: Color,
    focusedLeadingIconColor: Color,
    unfocusedLeadingIconColor: Color,
    disabledLeadingIconColor: Color,
    errorLeadingIconColor: Color,
    focusedTrailingIconColor: Color,
    unfocusedTrailingIconColor: Color,
    disabledTrailingIconColor: Color,
    errorTrailingIconColor: Color,
    focusedLabelColor: Color,
    unfocusedLabelColor: Color,
    disabledLabelColor: Color,
    errorLabelColor: Color,
    focusedPlaceholderColor: Color,
    unfocusedPlaceholderColor: Color,
    disabledPlaceholderColor: Color,
    errorPlaceholderColor: Color,
    focusedSupportingTextColor: Color,
    unfocusedSupportingTextColor: Color,
    disabledSupportingTextColor: Color,
    errorSupportingTextColor: Color,
    focusedPrefixColor: Color,
    unfocusedPrefixColor: Color,
    disabledPrefixColor: Color,
    errorPrefixColor: Color,
    focusedSuffixColor: Color,
    unfocusedSuffixColor: Color,
    disabledSuffixColor: Color,
    errorSuffixColor: Color
)

This function is deprecated. Renamed to `TextFieldDefaults.colors` with additional parameters to controlcontainer color based on state.

Cmn
PaddingValues
textFieldWithLabelPadding(start: Dp, end: Dp, top: Dp, bottom: Dp)

This function is deprecated. Renamed to `TextFieldDefaults.contentPaddingWithLabel`

Cmn
PaddingValues
textFieldWithoutLabelPadding(start: Dp, top: Dp, end: Dp, bottom: Dp)

This function is deprecated. Renamed to `TextFieldDefaults.contentPaddingWithoutLabel`

Cmn

Public properties

Dp

This property is deprecated. Split into `TextFieldDefaults.FocusedIndicatorThickness` and `OutlinedTextFieldDefaults.FocusedBorderThickness`.

Cmn
Dp

The default thickness of the indicator line in TextField in focused state.

Cmn
Dp

The default min height applied to a TextField.

Cmn
Dp

The default min width applied to a TextField.

Cmn
Dp

This property is deprecated. Split into `TextFieldDefaults.UnfocusedIndicatorThickness` and `OutlinedTextFieldDefaults.UnfocusedBorderThickness`.

Cmn
Dp

The default thickness of the indicator line in TextField in unfocused state.

Cmn
Shape

This property is deprecated. Renamed to `TextFieldDefaults.shape`

Cmn
Shape

This property is deprecated. Renamed to `OutlinedTextFieldDefaults.shape`

Cmn
Shape

Default shape for a TextField.

Cmn

Public functions

ContainerBox

@ExperimentalMaterial3Api
@Composable
fun ContainerBox(
    enabled: Boolean,
    isError: Boolean,
    interactionSource: InteractionSource,
    colors: TextFieldColors,
    shape: Shape = TextFieldDefaults.shape
): Unit

Composable that draws a default container for the content of TextField, with an indicator line at the bottom. You can use it to draw a container for your custom text field based on TextFieldDefaults.DecorationBox. TextField applies it automatically.

Parameters
enabled: Boolean

whether the text field is enabled

isError: Boolean

whether the text field's current value is in error

interactionSource: InteractionSource

the InteractionSource of this text field. Helps to determine if the text field is in focus or not

colors: TextFieldColors

TextFieldColors used to resolve colors of the text field

shape: Shape = TextFieldDefaults.shape

shape of the container

DecorationBox

@Composable
@ExperimentalMaterial3Api
fun DecorationBox(
    value: String,
    innerTextField: @Composable () -> Unit,
    enabled: Boolean,
    singleLine: Boolean,
    visualTransformation: VisualTransformation,
    interactionSource: InteractionSource,
    isError: Boolean = false,
    label: (@Composable () -> 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,
    shape: Shape = TextFieldDefaults.shape,
    colors: TextFieldColors = colors(),
    contentPadding: PaddingValues = if (label == null) { contentPaddingWithoutLabel() } else { contentPaddingWithLabel() },
    container: @Composable () -> Unit = { ContainerBox(enabled, isError, interactionSource, colors, shape) }
): Unit

A decoration box which helps creating custom text fields based on Material Design filled text field.

If your text field requires customising elements that aren't exposed by TextField, consider using this decoration box to achieve the desired design.

For example, if you need to create a dense text field, use contentPadding parameter to decrease the paddings around the input field. If you need to customise the bottom indicator, apply indicatorLine modifier to achieve that.

See example of using DecorationBox to build your own custom text field

import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.material3.Text
import androidx.compose.runtime.remember
import androidx.compose.ui.text.input.PasswordVisualTransformation

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun CustomTextField(
    value: String,
    onValueChange: (String) -> Unit,
    modifier: Modifier = Modifier
) {
    val interactionSource = remember { MutableInteractionSource() }
    // parameters below will be passed to BasicTextField for correct behavior of the text field,
    // and to the decoration box for proper styling and sizing
    val enabled = true
    val singleLine = true
    val passwordTransformation = PasswordVisualTransformation()

    BasicTextField(
        value = value,
        onValueChange = onValueChange,
        modifier = modifier,
        visualTransformation = passwordTransformation,
        // internal implementation of the BasicTextField will dispatch focus events
        interactionSource = interactionSource,
        enabled = enabled,
        singleLine = singleLine
    ) {
        TextFieldDefaults.DecorationBox(
            value = value,
            visualTransformation = passwordTransformation,
            innerTextField = it,
            singleLine = singleLine,
            enabled = enabled,
            // same interaction source as the one passed to BasicTextField to read focus state
            // for text field styling
            interactionSource = interactionSource,
            supportingText = { Text("Supporting text") },
            // keep horizontal paddings but change the vertical
            contentPadding = TextFieldDefaults.contentPaddingWithoutLabel(
                top = 8.dp, bottom = 8.dp
            ),
        )
    }
}
Parameters
value: String

the input String shown by the text field

innerTextField: @Composable () -> Unit

input text field that this decoration box wraps. You will pass here a framework-controlled composable parameter "innerTextField" from the decorationBox lambda of the BasicTextField

enabled: Boolean

controls the enabled state of the text field. When false, this component will not respond to user input, and it will appear visually disabled and disabled to accessibility services. You must also pass the same value to the BasicTextField for it to adjust the behavior accordingly.

singleLine: Boolean

indicates if this is a single line or multi line text field. You must pass the same value as to BasicTextField.

visualTransformation: VisualTransformation

transforms the visual representation of the input value. You must pass the same value as to BasicTextField.

interactionSource: InteractionSource

the read-only InteractionSource representing the stream of Interactions for this text field. You must first create and pass in your own remembered MutableInteractionSource instance to the BasicTextField for it to dispatch events. And then pass the same instance to this decoration box to observe Interactions and customize the appearance / behavior of this text field in different states.

isError: Boolean = false

indicates if the text field's current value is in error state. If set to true, the label, bottom indicator and trailing icon by default will be displayed in error color.

label: (@Composable () -> Unit)? = null

the optional label to be displayed inside the text field container. The default text style for internal Text is Typography.bodySmall when the text field is in focus and Typography.bodyLarge when the text field is not in focus.

placeholder: (@Composable () -> Unit)? = null

the optional placeholder to be displayed when the text field is in focus and the input text is empty. The default text style for internal Text is Typography.bodyLarge.

leadingIcon: (@Composable () -> Unit)? = null

the optional leading icon to be displayed at the beginning of the text field container

trailingIcon: (@Composable () -> Unit)? = null

the optional trailing icon to be displayed at the end of the text field container

prefix: (@Composable () -> Unit)? = null

the optional prefix to be displayed before the input text in the text field

suffix: (@Composable () -> Unit)? = null

the optional suffix to be displayed after the input text in the text field

supportingText: (@Composable () -> Unit)? = null

the optional supporting text to be displayed below the text field

shape: Shape = TextFieldDefaults.shape

defines the shape of this text field's container

colors: TextFieldColors = colors()

TextFieldColors that will be used to resolve the colors used for this text field in different states. See TextFieldDefaults.colors.

contentPadding: PaddingValues = if (label == null) { contentPaddingWithoutLabel() } else { contentPaddingWithLabel() }

the spacing values to apply internally between the internals of text field and the decoration box container. You can use it to implement dense text fields or simply to control horizontal padding. See TextFieldDefaults.contentPaddingWithLabel and TextFieldDefaults.contentPaddingWithoutLabel. Note that if there's a label in the text field, the top padding represents the distance from the top edge of the container to the top of the label. Otherwise if label is null, it represents the distance from the top edge of the container to the top of the input field. All other paddings represent the distance from the corresponding edge of the container to the corresponding edge of the closest element.

container: @Composable () -> Unit = { ContainerBox(enabled, isError, interactionSource, colors, shape) }

the container to be drawn behind the text field. By default, this includes the bottom indicator line. Default colors for the container come from the colors.

FilledContainerBox

@ExperimentalMaterial3Api
@Composable
fun FilledContainerBox(
    enabled: Boolean,
    isError: Boolean,
    interactionSource: InteractionSource,
    colors: TextFieldColors,
    shape: Shape = TextFieldDefaults.shape
): Unit

OutlinedBorderContainerBox

@ExperimentalMaterial3Api
@Composable
fun OutlinedBorderContainerBox(
    enabled: Boolean,
    isError: Boolean,
    interactionSource: InteractionSource,
    colors: TextFieldColors,
    shape: Shape = OutlinedTextFieldTokens.ContainerShape.value,
    focusedBorderThickness: Dp = OutlinedTextFieldDefaults.FocusedBorderThickness,
    unfocusedBorderThickness: Dp = OutlinedTextFieldDefaults.UnfocusedBorderThickness
): Unit

OutlinedTextFieldDecorationBox

@Composable
@ExperimentalMaterial3Api
fun OutlinedTextFieldDecorationBox(
    value: String,
    innerTextField: @Composable () -> Unit,
    enabled: Boolean,
    singleLine: Boolean,
    visualTransformation: VisualTransformation,
    interactionSource: InteractionSource,
    isError: Boolean = false,
    label: (@Composable () -> 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,
    colors: TextFieldColors = OutlinedTextFieldDefaults.colors(),
    contentPadding: PaddingValues = OutlinedTextFieldDefaults.contentPadding(),
    container: @Composable () -> Unit = { OutlinedTextFieldDefaults.ContainerBox(enabled, isError, interactionSource, colors) }
): Unit

TextFieldDecorationBox

@Composable
@ExperimentalMaterial3Api
fun TextFieldDecorationBox(
    value: String,
    innerTextField: @Composable () -> Unit,
    enabled: Boolean,
    singleLine: Boolean,
    visualTransformation: VisualTransformation,
    interactionSource: InteractionSource,
    isError: Boolean = false,
    label: (@Composable () -> 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,
    shape: Shape = TextFieldDefaults.shape,
    colors: TextFieldColors = colors(),
    contentPadding: PaddingValues = if (label == null) { contentPaddingWithoutLabel() } else { contentPaddingWithLabel() },
    container: @Composable () -> Unit = { ContainerBox(enabled, isError, interactionSource, colors, shape) }
): Unit

colors

@Composable
fun colors(): TextFieldColors

Creates a TextFieldColors that represents the default input text, container, and content colors (including label, placeholder, icons, etc.) used in a TextField.

colors

@Composable
fun colors(
    focusedTextColor: Color = Color.Unspecified,
    unfocusedTextColor: Color = Color.Unspecified,
    disabledTextColor: Color = Color.Unspecified,
    errorTextColor: Color = Color.Unspecified,
    focusedContainerColor: Color = Color.Unspecified,
    unfocusedContainerColor: Color = Color.Unspecified,
    disabledContainerColor: Color = Color.Unspecified,
    errorContainerColor: Color = Color.Unspecified,
    cursorColor: Color = Color.Unspecified,
    errorCursorColor: Color = Color.Unspecified,
    selectionColors: TextSelectionColors? = null,
    focusedIndicatorColor: Color = Color.Unspecified,
    unfocusedIndicatorColor: Color = Color.Unspecified,
    disabledIndicatorColor: Color = Color.Unspecified,
    errorIndicatorColor: Color = Color.Unspecified,
    focusedLeadingIconColor: Color = Color.Unspecified,
    unfocusedLeadingIconColor: Color = Color.Unspecified,
    disabledLeadingIconColor: Color = Color.Unspecified,
    errorLeadingIconColor: Color = Color.Unspecified,
    focusedTrailingIconColor: Color = Color.Unspecified,
    unfocusedTrailingIconColor: Color = Color.Unspecified,
    disabledTrailingIconColor: Color = Color.Unspecified,
    errorTrailingIconColor: Color = Color.Unspecified,
    focusedLabelColor: Color = Color.Unspecified,
    unfocusedLabelColor: Color = Color.Unspecified,
    disabledLabelColor: Color = Color.Unspecified,
    errorLabelColor: Color = Color.Unspecified,
    focusedPlaceholderColor: Color = Color.Unspecified,
    unfocusedPlaceholderColor: Color = Color.Unspecified,
    disabledPlaceholderColor: Color = Color.Unspecified,
    errorPlaceholderColor: Color = Color.Unspecified,
    focusedSupportingTextColor: Color = Color.Unspecified,
    unfocusedSupportingTextColor: Color = Color.Unspecified,
    disabledSupportingTextColor: Color = Color.Unspecified,
    errorSupportingTextColor: Color = Color.Unspecified,
    focusedPrefixColor: Color = Color.Unspecified,
    unfocusedPrefixColor: Color = Color.Unspecified,
    disabledPrefixColor: Color = Color.Unspecified,
    errorPrefixColor: Color = Color.Unspecified,
    focusedSuffixColor: Color = Color.Unspecified,
    unfocusedSuffixColor: Color = Color.Unspecified,
    disabledSuffixColor: Color = Color.Unspecified,
    errorSuffixColor: Color = Color.Unspecified
): TextFieldColors

Creates a TextFieldColors that represents the default input text, container, and content colors (including label, placeholder, icons, etc.) used in a TextField.

Parameters
focusedTextColor: Color = Color.Unspecified

the color used for the input text of this text field when focused

unfocusedTextColor: Color = Color.Unspecified

the color used for the input text of this text field when not focused

disabledTextColor: Color = Color.Unspecified

the color used for the input text of this text field when disabled

errorTextColor: Color = Color.Unspecified

the color used for the input text of this text field when in error state

focusedContainerColor: Color = Color.Unspecified

the container color for this text field when focused

unfocusedContainerColor: Color = Color.Unspecified

the container color for this text field when not focused

disabledContainerColor: Color = Color.Unspecified

the container color for this text field when disabled

errorContainerColor: Color = Color.Unspecified

the container color for this text field when in error state

cursorColor: Color = Color.Unspecified

the cursor color for this text field

errorCursorColor: Color = Color.Unspecified

the cursor color for this text field when in error state

selectionColors: TextSelectionColors? = null

the colors used when the input text of this text field is selected

focusedIndicatorColor: Color = Color.Unspecified

the indicator color for this text field when focused

unfocusedIndicatorColor: Color = Color.Unspecified

the indicator color for this text field when not focused

disabledIndicatorColor: Color = Color.Unspecified

the indicator color for this text field when disabled

errorIndicatorColor: Color = Color.Unspecified

the indicator color for this text field when in error state

focusedLeadingIconColor: Color = Color.Unspecified

the leading icon color for this text field when focused

unfocusedLeadingIconColor: Color = Color.Unspecified

the leading icon color for this text field when not focused

disabledLeadingIconColor: Color = Color.Unspecified

the leading icon color for this text field when disabled

errorLeadingIconColor: Color = Color.Unspecified

the leading icon color for this text field when in error state

focusedTrailingIconColor: Color = Color.Unspecified

the trailing icon color for this text field when focused

unfocusedTrailingIconColor: Color = Color.Unspecified

the trailing icon color for this text field when not focused

disabledTrailingIconColor: Color = Color.Unspecified

the trailing icon color for this text field when disabled

errorTrailingIconColor: Color = Color.Unspecified

the trailing icon color for this text field when in error state

focusedLabelColor: Color = Color.Unspecified

the label color for this text field when focused

unfocusedLabelColor: Color = Color.Unspecified

the label color for this text field when not focused

disabledLabelColor: Color = Color.Unspecified

the label color for this text field when disabled

errorLabelColor: Color = Color.Unspecified

the label color for this text field when in error state

focusedPlaceholderColor: Color = Color.Unspecified

the placeholder color for this text field when focused

unfocusedPlaceholderColor: Color = Color.Unspecified

the placeholder color for this text field when not focused

disabledPlaceholderColor: Color = Color.Unspecified

the placeholder color for this text field when disabled

errorPlaceholderColor: Color = Color.Unspecified

the placeholder color for this text field when in error state

focusedSupportingTextColor: Color = Color.Unspecified

the supporting text color for this text field when focused

unfocusedSupportingTextColor: Color = Color.Unspecified

the supporting text color for this text field when not focused

disabledSupportingTextColor: Color = Color.Unspecified

the supporting text color for this text field when disabled

errorSupportingTextColor: Color = Color.Unspecified

the supporting text color for this text field when in error state

focusedPrefixColor: Color = Color.Unspecified

the prefix color for this text field when focused

unfocusedPrefixColor: Color = Color.Unspecified

the prefix color for this text field when not focused

disabledPrefixColor: Color = Color.Unspecified

the prefix color for this text field when disabled

errorPrefixColor: Color = Color.Unspecified

the prefix color for this text field when in error state

focusedSuffixColor: Color = Color.Unspecified

the suffix color for this text field when focused

unfocusedSuffixColor: Color = Color.Unspecified

the suffix color for this text field when not focused

disabledSuffixColor: Color = Color.Unspecified

the suffix color for this text field when disabled

errorSuffixColor: Color = Color.Unspecified

the suffix color for this text field when in error state

contentPaddingWithLabel

fun contentPaddingWithLabel(
    start: Dp = TextFieldPadding,
    end: Dp = TextFieldPadding,
    top: Dp = TextFieldWithLabelVerticalPadding,
    bottom: Dp = TextFieldWithLabelVerticalPadding
): PaddingValues

Default content padding applied to TextField when there is a label.

Note that when the label is present, the "top" padding is a distance between the top edge of the TextField and the top of the label, not to the top of the input field. The input field is placed directly beneath the label.

See PaddingValues for more details.

contentPaddingWithoutLabel

fun contentPaddingWithoutLabel(
    start: Dp = TextFieldPadding,
    top: Dp = TextFieldPadding,
    end: Dp = TextFieldPadding,
    bottom: Dp = TextFieldPadding
): PaddingValues

Default content padding applied to TextField when the label is null. See PaddingValues for more details.

@ExperimentalMaterial3Api
fun Modifier.indicatorLine(
    enabled: Boolean,
    isError: Boolean,
    interactionSource: InteractionSource,
    colors: TextFieldColors,
    focusedIndicatorLineThickness: Dp = FocusedIndicatorThickness,
    unfocusedIndicatorLineThickness: Dp = UnfocusedIndicatorThickness
): Modifier

A modifier to draw a default bottom indicator line in TextField. You can use this modifier if you build your custom text field using TextFieldDefaults.DecorationBox whilst the TextField applies it automatically.

Parameters
enabled: Boolean

whether the text field is enabled

isError: Boolean

whether the text field's current value is in error

interactionSource: InteractionSource

the InteractionSource of this text field. Helps to determine if the text field is in focus or not

colors: TextFieldColors

TextFieldColors used to resolve colors of the text field

focusedIndicatorLineThickness: Dp = FocusedIndicatorThickness

thickness of the indicator line when text field is focused

unfocusedIndicatorLineThickness: Dp = UnfocusedIndicatorThickness

thickness of the indicator line when text field is not focused

outlinedTextFieldColors

@ExperimentalMaterial3Api
@Composable
fun outlinedTextFieldColors(
    focusedTextColor: Color = OutlinedTextFieldTokens.FocusInputColor.value,
    unfocusedTextColor: Color = OutlinedTextFieldTokens.InputColor.value,
    disabledTextColor: Color = OutlinedTextFieldTokens.DisabledInputColor.value .copy(alpha = OutlinedTextFieldTokens.DisabledInputOpacity),
    errorTextColor: Color = OutlinedTextFieldTokens.ErrorInputColor.value,
    containerColor: Color = Color.Transparent,
    errorContainerColor: Color = Color.Transparent,
    cursorColor: Color = OutlinedTextFieldTokens.CaretColor.value,
    errorCursorColor: Color = OutlinedTextFieldTokens.ErrorFocusCaretColor.value,
    selectionColors: TextSelectionColors = LocalTextSelectionColors.current,
    focusedBorderColor: Color = OutlinedTextFieldTokens.FocusOutlineColor.value,
    unfocusedBorderColor: Color = OutlinedTextFieldTokens.OutlineColor.value,
    disabledBorderColor: Color = OutlinedTextFieldTokens.DisabledOutlineColor.value .copy(alpha = OutlinedTextFieldTokens.DisabledOutlineOpacity),
    errorBorderColor: Color = OutlinedTextFieldTokens.ErrorOutlineColor.value,
    focusedLeadingIconColor: Color = OutlinedTextFieldTokens.FocusLeadingIconColor.value,
    unfocusedLeadingIconColor: Color = OutlinedTextFieldTokens.LeadingIconColor.value,
    disabledLeadingIconColor: Color = OutlinedTextFieldTokens.DisabledLeadingIconColor.value .copy(alpha = OutlinedTextFieldTokens.DisabledLeadingIconOpacity),
    errorLeadingIconColor: Color = OutlinedTextFieldTokens.ErrorLeadingIconColor.value,
    focusedTrailingIconColor: Color = OutlinedTextFieldTokens.FocusTrailingIconColor.value,
    unfocusedTrailingIconColor: Color = OutlinedTextFieldTokens.TrailingIconColor.value,
    disabledTrailingIconColor: Color = OutlinedTextFieldTokens.DisabledTrailingIconColor .value.copy(alpha = OutlinedTextFieldTokens.DisabledTrailingIconOpacity),
    errorTrailingIconColor: Color = OutlinedTextFieldTokens.ErrorTrailingIconColor.value,
    focusedLabelColor: Color = OutlinedTextFieldTokens.FocusLabelColor.value,
    unfocusedLabelColor: Color = OutlinedTextFieldTokens.LabelColor.value,
    disabledLabelColor: Color = OutlinedTextFieldTokens.DisabledLabelColor.value .copy(alpha = OutlinedTextFieldTokens.DisabledLabelOpacity),
    errorLabelColor: Color = OutlinedTextFieldTokens.ErrorLabelColor.value,
    focusedPlaceholderColor: Color = OutlinedTextFieldTokens.InputPlaceholderColor.value,
    unfocusedPlaceholderColor: Color = OutlinedTextFieldTokens.InputPlaceholderColor.value,
    disabledPlaceholderColor: Color = OutlinedTextFieldTokens.DisabledInputColor.value .copy(alpha = OutlinedTextFieldTokens.DisabledInputOpacity),
    errorPlaceholderColor: Color = OutlinedTextFieldTokens.InputPlaceholderColor.value,
    focusedSupportingTextColor: Color = OutlinedTextFieldTokens.FocusSupportingColor.value,
    unfocusedSupportingTextColor: Color = OutlinedTextFieldTokens.SupportingColor.value,
    disabledSupportingTextColor: Color = OutlinedTextFieldTokens.DisabledSupportingColor .value.copy(alpha = OutlinedTextFieldTokens.DisabledSupportingOpacity),
    errorSupportingTextColor: Color = OutlinedTextFieldTokens.ErrorSupportingColor.value,
    focusedPrefixColor: Color = OutlinedTextFieldTokens.InputPrefixColor.value,
    unfocusedPrefixColor: Color = OutlinedTextFieldTokens.InputPrefixColor.value,
    disabledPrefixColor: Color = OutlinedTextFieldTokens.InputPrefixColor.value .copy(alpha = OutlinedTextFieldTokens.DisabledInputOpacity),
    errorPrefixColor: Color = OutlinedTextFieldTokens.InputPrefixColor.value,
    focusedSuffixColor: Color = OutlinedTextFieldTokens.InputSuffixColor.value,
    unfocusedSuffixColor: Color = OutlinedTextFieldTokens.InputSuffixColor.value,
    disabledSuffixColor: Color = OutlinedTextFieldTokens.InputSuffixColor.value .copy(alpha = OutlinedTextFieldTokens.DisabledInputOpacity),
    errorSuffixColor: Color = OutlinedTextFieldTokens.InputSuffixColor.value
): TextFieldColors

outlinedTextFieldPadding

fun outlinedTextFieldPadding(
    start: Dp = TextFieldPadding,
    top: Dp = TextFieldPadding,
    end: Dp = TextFieldPadding,
    bottom: Dp = TextFieldPadding
): PaddingValues

textFieldColors

@ExperimentalMaterial3Api
@Composable
fun textFieldColors(
    focusedTextColor: Color = FilledTextFieldTokens.FocusInputColor.value,
    unfocusedTextColor: Color = FilledTextFieldTokens.InputColor.value,
    disabledTextColor: Color = FilledTextFieldTokens.DisabledInputColor.value .copy(alpha = FilledTextFieldTokens.DisabledInputOpacity),
    errorTextColor: Color = FilledTextFieldTokens.ErrorInputColor.value,
    containerColor: Color = FilledTextFieldTokens.ContainerColor.value,
    errorContainerColor: Color = FilledTextFieldTokens.ContainerColor.value,
    cursorColor: Color = FilledTextFieldTokens.CaretColor.value,
    errorCursorColor: Color = FilledTextFieldTokens.ErrorFocusCaretColor.value,
    selectionColors: TextSelectionColors = LocalTextSelectionColors.current,
    focusedIndicatorColor: Color = FilledTextFieldTokens.FocusActiveIndicatorColor.value,
    unfocusedIndicatorColor: Color = FilledTextFieldTokens.ActiveIndicatorColor.value,
    disabledIndicatorColor: Color = FilledTextFieldTokens.DisabledActiveIndicatorColor.value .copy(alpha = FilledTextFieldTokens.DisabledActiveIndicatorOpacity),
    errorIndicatorColor: Color = FilledTextFieldTokens.ErrorActiveIndicatorColor.value,
    focusedLeadingIconColor: Color = FilledTextFieldTokens.FocusLeadingIconColor.value,
    unfocusedLeadingIconColor: Color = FilledTextFieldTokens.LeadingIconColor.value,
    disabledLeadingIconColor: Color = FilledTextFieldTokens.DisabledLeadingIconColor.value .copy(alpha = FilledTextFieldTokens.DisabledLeadingIconOpacity),
    errorLeadingIconColor: Color = FilledTextFieldTokens.ErrorLeadingIconColor.value,
    focusedTrailingIconColor: Color = FilledTextFieldTokens.FocusTrailingIconColor.value,
    unfocusedTrailingIconColor: Color = FilledTextFieldTokens.TrailingIconColor.value,
    disabledTrailingIconColor: Color = FilledTextFieldTokens.DisabledTrailingIconColor.value .copy(alpha = FilledTextFieldTokens.DisabledTrailingIconOpacity),
    errorTrailingIconColor: Color = FilledTextFieldTokens.ErrorTrailingIconColor.value,
    focusedLabelColor: Color = FilledTextFieldTokens.FocusLabelColor.value,
    unfocusedLabelColor: Color = FilledTextFieldTokens.LabelColor.value,
    disabledLabelColor: Color = FilledTextFieldTokens.DisabledLabelColor.value .copy(alpha = FilledTextFieldTokens.DisabledLabelOpacity),
    errorLabelColor: Color = FilledTextFieldTokens.ErrorLabelColor.value,
    focusedPlaceholderColor: Color = FilledTextFieldTokens.InputPlaceholderColor.value,
    unfocusedPlaceholderColor: Color = FilledTextFieldTokens.InputPlaceholderColor.value,
    disabledPlaceholderColor: Color = FilledTextFieldTokens.DisabledInputColor.value .copy(alpha = FilledTextFieldTokens.DisabledInputOpacity),
    errorPlaceholderColor: Color = FilledTextFieldTokens.InputPlaceholderColor.value,
    focusedSupportingTextColor: Color = FilledTextFieldTokens.FocusSupportingColor.value,
    unfocusedSupportingTextColor: Color = FilledTextFieldTokens.SupportingColor.value,
    disabledSupportingTextColor: Color = FilledTextFieldTokens.DisabledSupportingColor.value .copy(alpha = FilledTextFieldTokens.DisabledSupportingOpacity),
    errorSupportingTextColor: Color = FilledTextFieldTokens.ErrorSupportingColor.value,
    focusedPrefixColor: Color = FilledTextFieldTokens.InputPrefixColor.value,
    unfocusedPrefixColor: Color = FilledTextFieldTokens.InputPrefixColor.value,
    disabledPrefixColor: Color = FilledTextFieldTokens.InputPrefixColor.value .copy(alpha = FilledTextFieldTokens.DisabledInputOpacity),
    errorPrefixColor: Color = FilledTextFieldTokens.InputPrefixColor.value,
    focusedSuffixColor: Color = FilledTextFieldTokens.InputSuffixColor.value,
    unfocusedSuffixColor: Color = FilledTextFieldTokens.InputSuffixColor.value,
    disabledSuffixColor: Color = FilledTextFieldTokens.InputSuffixColor.value .copy(alpha = FilledTextFieldTokens.DisabledInputOpacity),
    errorSuffixColor: Color = FilledTextFieldTokens.InputSuffixColor.value
): TextFieldColors

textFieldWithLabelPadding

fun textFieldWithLabelPadding(
    start: Dp = TextFieldPadding,
    end: Dp = TextFieldPadding,
    top: Dp = TextFieldWithLabelVerticalPadding,
    bottom: Dp = TextFieldWithLabelVerticalPadding
): PaddingValues

textFieldWithoutLabelPadding

fun textFieldWithoutLabelPadding(
    start: Dp = TextFieldPadding,
    top: Dp = TextFieldPadding,
    end: Dp = TextFieldPadding,
    bottom: Dp = TextFieldPadding
): PaddingValues

Public properties

FocusedBorderThickness

val FocusedBorderThicknessDp

FocusedIndicatorThickness

val FocusedIndicatorThicknessDp

The default thickness of the indicator line in TextField in focused state.

MinHeight

val MinHeightDp

The default min height applied to a TextField. Note that you can override it by applying Modifier.heightIn directly on a text field.

MinWidth

val MinWidthDp

The default min width applied to a TextField. Note that you can override it by applying Modifier.widthIn directly on a text field.

UnfocusedBorderThickness

val UnfocusedBorderThicknessDp

UnfocusedIndicatorThickness

val UnfocusedIndicatorThicknessDp

The default thickness of the indicator line in TextField in unfocused state.

filledShape

val filledShapeShape

outlinedShape

val outlinedShapeShape

shape

val shapeShape

Default shape for a TextField.