DecorationBox
A decoration box used to create custom text fields based on Material Design outlined text field.
If your text field requires customising elements that aren't exposed by OutlinedTextField, consider using this decoration box to achieve the desired design.
For example, if you wish to customize the thickness of the border, you can pass a custom Container to this decoration box's container.
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. You will pass here a 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 remember
ed 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 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.
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
TextFieldColors that will be used to resolve the colors used for this text field in different states. See OutlinedTextFieldDefaults.colors.
the padding applied between the internal elements of this decoration box and the edge of its container