DecorationBox
A decoration box used to create 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 wish to customise the bottom indicator line, you can pass a custom Container to this decoration box's container.
This decoration box is meant to be used in conjunction with overloads of BasicTextField that accept a decorationBox parameter. For other overloads of BasicTextField that use a TextFieldDecorator, see decorator.
An example of building a custom text field using DecorationBox:
Parameters
the input String shown by the text field
input text field that this decoration box wraps. Pass the framework-controlled composable parameter innerTextField from the decorationBox lambda of the BasicTextField
the enabled state of the text field. When false, this decoration box will appear visually disabled. This must be the same value that is passed to BasicTextField.
indicates if this is a single line or multi line text field. This must be the same value that is passed to BasicTextField.
transforms the visual representation of the input value. This must be the same value that is passed to BasicTextField.
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.
indicates if the text field's current value is in an error state. When true, this decoration box will display its contents in an error color.
the optional label to be displayed with this text field. The default text style uses Typography.bodySmall when minimized and Typography.bodyLarge when expanded.
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.
the optional leading icon to be displayed at the beginning of the text field container
the optional trailing icon to be displayed at the end of the text field container
the optional prefix to be displayed before the input text in the text field
the optional suffix to be displayed after the input text in the text field
the optional supporting text to be displayed below the text field
defines the shape of this decoration box's container
TextFieldColors that will be used to resolve the colors used for this text field decoration box in different states. See TextFieldDefaults.colors. Note: This parameter only affects the colors of elements in the decoration box. Elements of the BasicTextField (such as text color or cursor color) are unaffected and must be changed using the relevant parameters of BasicTextField.
the padding between the input field and the surrounding elements of the decoration box. Note that the padding values may not be respected if they are incompatible with the text field's size constraints or layout. See TextFieldDefaults.contentPaddingWithLabel and TextFieldDefaults.contentPaddingWithoutLabel.