AnimatedContent
Animated wrapper for the TextField trailing slot. Renders one of the TextFieldScope elements (Icon / Text) per targetState with a smooth transition.
The content lambda is invoked with TextFieldScope as its receiver, so callers naturally use the scope's elements (Icon(...), Text(...)). Children may be omitted entirely (e.g. an if without an else branch); empty states are valid and will simply render nothing for that target.
Parameters
The state value driving the transition. When it changes, content is recomposed for the new state and the transition runs from the previous state.
The Modifier to be applied to the wrapper. The required layoutId for the trailing slot is appended internally.
Describes the enter / exit animation between adjacent target states. Defaults to a simple cross-fade.
Alignment of the content within the wrapper while incoming and outgoing children overlap during the transition. Defaults to Alignment.Center.
Diagnostic label forwarded to the underlying androidx.compose.animation.AnimatedContent; appears in animation tooling.
Optional key derivation function used to decide whether a transition should run. When targetState changes, the new and previous keys are compared; a transition runs only if they differ. Defaults to { it }, mirroring androidx.compose.animation.AnimatedContent and keying on targetState itself. Override when targetState is a complex type and only a subset of its fields should drive transitions (e.g. contentKey = { it.id }).
Composable lambda invoked with the current targetState. Only TextFieldScope.Icon / TextFieldScope.Text are accepted; any other content fails validation at runtime.