androidx.compose.material3

TextFieldDefaults

Object

No hand-written docs yet.

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

object TextFieldDefaults

Properties

shape

@Composable val shape: Shape

Default shape for a TextField.

roundedShapeSince 1.12

@Composable val roundedShape: Shape

A rounded shape for a TextField, as recommended by Expressive style.

MinHeight

val MinHeight: Dp

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 MinWidth: Dp

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

UnfocusedIndicatorThickness

val UnfocusedIndicatorThickness: Dp

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

FocusedIndicatorThickness

val FocusedIndicatorThickness: Dp

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

Functions

decoratorSince 1.9

@Composable
fun decorator(
    state: TextFieldState,
    enabled: Boolean,
    lineLimits: TextFieldLineLimits,
    outputTransformation: OutputTransformation?,
    interactionSource: InteractionSource,
    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,
    colors: TextFieldColors = colors(),
    contentPadding: PaddingValues = defaultContentPadding(label, labelPosition),
    container: @Composable () -> Unit = { Container(enabled = enabled, isError = isError, interactionSource = interactionSource, colors = colors, shape = shape, focusedIndicatorLineThickness = FocusedIndicatorThickness, unfocusedIndicatorLineThickness = UnfocusedIndicatorThickness) },
): TextFieldDecorator

A decorator used to create custom text fields based on Material Design filled text field.

Container

@Composable
fun Container(
    enabled: Boolean,
    isError: Boolean,
    interactionSource: InteractionSource,
    modifier: Modifier = Modifier,
    colors: TextFieldColors = colors(),
    shape: Shape = TextFieldDefaults.shape,
    focusedIndicatorLineThickness: Dp = FocusedIndicatorThickness,
    unfocusedIndicatorLineThickness: Dp = UnfocusedIndicatorThickness,
)

Composable that draws a default container for a TextField with an indicator line at the bottom. You can apply it to a BasicTextField using decorator or DecorationBox to create a custom text field based on the styling of a Material filled text field. The TextField component applies it automatically.

indicatorLine

fun Modifier.indicatorLine(
    enabled: Boolean,
    isError: Boolean,
    interactionSource: InteractionSource,
    colors: TextFieldColors? = null,
    textFieldShape: Shape? = null,
    focusedIndicatorLineThickness: Dp = FocusedIndicatorThickness,
    unfocusedIndicatorLineThickness: Dp = UnfocusedIndicatorThickness,
)

A modifier to draw a default bottom indicator line for TextField. You can apply it to a BasicTextField to create a custom text field based on the styling of a Material filled text field.

DecorationBox

@Composable
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 = { Container(enabled = enabled, isError = isError, interactionSource = interactionSource, modifier = Modifier, colors = colors, shape = shape, focusedIndicatorLineThickness = FocusedIndicatorThickness, unfocusedIndicatorLineThickness = UnfocusedIndicatorThickness) },
)

A decoration box used to create custom text fields based on Material Design filled text field.

contentPaddingWithLabel

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

Default content padding of the input field within the TextField when there is an inside label. Note that the top padding represents the padding above the label in the focused state. The input field is placed directly beneath the label.

contentPaddingWithoutLabel

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

Default content padding of the input field within the TextField when the label is absent or not positioned inside the container.

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.

tonalColorsSince 1.12

@Composable
fun tonalColors(): TextFieldColors

Creates a TextFieldColors that represents the Expressive style input text, container, and content colors (including label, placeholder, icons, etc.) used in a TextField with tonal 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.

Library docs

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