@@ -6,10 +6,10 @@ import TextInputWrapper from './_TextInputWrapper'
66
77type NonPassthroughProps = {
88 className ?: string
9- /** @deprecated Use `leadingIcon ` or `trailingIcon ` prop instead */
9+ /** @deprecated Use `leadingVisual ` or `trailingVisual ` prop instead */
1010 icon ?: React . ComponentType < { className ?: string } >
11- leadingIcon ?: React . ComponentType < { className ?: string } >
12- trailingIcon ?: React . ComponentType < { className ?: string } >
11+ leadingVisual ?: string | React . ComponentType < { className ?: string } >
12+ trailingVisual ?: string | React . ComponentType < { className ?: string } >
1313} & Pick <
1414 ComponentProps < typeof TextInputWrapper > ,
1515 'block' | 'contrast' | 'disabled' | 'sx' | 'width' | 'maxWidth' | 'minWidth' | 'variant' | 'size'
@@ -23,8 +23,8 @@ const TextInput = React.forwardRef<HTMLInputElement, TextInputInternalProps>(
2323 (
2424 {
2525 icon : IconComponent ,
26- leadingIcon : LeadingIconComponent ,
27- trailingIcon : TrailingIconComponent ,
26+ leadingVisual : LeadingVisual ,
27+ trailingVisual : TrailingVisual ,
2828 block,
2929 className,
3030 contrast,
@@ -52,18 +52,25 @@ const TextInput = React.forwardRef<HTMLInputElement, TextInputInternalProps>(
5252 validationStatus = { validationStatus }
5353 contrast = { contrast }
5454 disabled = { disabled }
55- hasIcon = { ! ! IconComponent || ! ! ( LeadingIconComponent || TrailingIconComponent ) }
5655 sx = { sxProp }
5756 size = { sizeProp }
5857 width = { widthProp }
5958 minWidth = { minWidthProp }
6059 maxWidth = { maxWidthProp }
6160 variant = { variantProp }
6261 >
63- { IconComponent && < IconComponent className = "TextInput-leading-icon" /> }
64- { LeadingIconComponent && < LeadingIconComponent className = "TextInput-leading-icon" /> }
62+ { IconComponent && < IconComponent className = "TextInput-icon" /> }
63+ { LeadingVisual && (
64+ < span data-component = "leadingVisual" >
65+ { typeof LeadingVisual === 'function' ? < LeadingVisual /> : LeadingVisual }
66+ </ span >
67+ ) }
6568 < UnstyledTextInput ref = { ref } disabled = { disabled } { ...inputProps } data-component = "input" />
66- { TrailingIconComponent && < TrailingIconComponent className = "TextInput-trailing-icon" /> }
69+ { TrailingVisual && (
70+ < span data-component = "leadingVisual" >
71+ { typeof TrailingVisual === 'function' ? < TrailingVisual /> : TrailingVisual }
72+ </ span >
73+ ) }
6774 </ TextInputWrapper >
6875 )
6976 }
0 commit comments