@@ -213,7 +213,23 @@ export type BaseFieldProps = WithEnhancedClassName &
213
213
* @default 'below'
214
214
*/
215
215
characterCountPosition ?: 'below' | 'inline' | 'hidden'
216
- }
216
+ } & (
217
+ | {
218
+ supportsStartAndEndSlots ?: false
219
+ endSlot ?: never
220
+ endSlotPosition ?: never
221
+ }
222
+ | {
223
+ supportsStartAndEndSlots : true
224
+ endSlot ?: React . ReactElement | string | number
225
+ /**
226
+ * This is solely for `bordered` variants of TextField. When set to `bottom` (the default),
227
+ * the endSlot will be placed inline with the input field. When set to `fullHeight`, the endSlot
228
+ * will be placed to the side of both the input field and the label.
229
+ */
230
+ endSlotPosition ?: 'bottom' | 'fullHeight'
231
+ }
232
+ )
217
233
218
234
type FieldComponentProps < T extends HTMLElement > = Omit <
219
235
BaseFieldProps ,
@@ -239,6 +255,8 @@ function BaseField({
239
255
'aria-describedby' : originalAriaDescribedBy ,
240
256
id : originalId ,
241
257
characterCountPosition = 'below' ,
258
+ endSlot,
259
+ endSlotPosition = 'bottom' ,
242
260
} : BaseFieldProps & BaseFieldVariantProps & WithEnhancedClassName ) {
243
261
const id = useId ( originalId )
244
262
const messageId = useId ( )
@@ -302,36 +320,44 @@ function BaseField({
302
320
return (
303
321
< Stack space = "xsmall" hidden = { hidden } >
304
322
< Box
323
+ display = "flex"
324
+ flexDirection = "row"
305
325
className = { [
306
326
className ,
307
327
styles . container ,
308
328
tone === 'error' ? styles . error : null ,
309
329
variant === 'bordered' ? styles . bordered : null ,
310
330
] }
311
331
maxWidth = { maxWidth }
332
+ alignItems = "center"
312
333
>
313
- { label || auxiliaryLabel ? (
314
- < Box
315
- as = "span"
316
- display = "flex"
317
- justifyContent = "spaceBetween"
318
- alignItems = "flexEnd"
319
- >
320
- < Text
321
- size = { variant === 'bordered' ? 'caption' : 'body' }
322
- as = "label"
323
- htmlFor = { id }
334
+ < Box flexGrow = { 1 } >
335
+ { label || auxiliaryLabel ? (
336
+ < Box
337
+ as = "span"
338
+ display = "flex"
339
+ justifyContent = "spaceBetween"
340
+ alignItems = "flexEnd"
324
341
>
325
- { label ? < span className = { styles . primaryLabel } > { label } </ span > : null }
326
- </ Text >
327
- { auxiliaryLabel ? (
328
- < Box className = { styles . auxiliaryLabel } paddingLeft = "small" >
329
- { auxiliaryLabel }
330
- </ Box >
331
- ) : null }
332
- </ Box >
333
- ) : null }
334
- { children ( childrenProps ) }
342
+ < Text
343
+ size = { variant === 'bordered' ? 'caption' : 'body' }
344
+ as = "label"
345
+ htmlFor = { id }
346
+ >
347
+ { label ? (
348
+ < span className = { styles . primaryLabel } > { label } </ span >
349
+ ) : null }
350
+ </ Text >
351
+ { auxiliaryLabel ? (
352
+ < Box className = { styles . auxiliaryLabel } paddingLeft = "small" >
353
+ { auxiliaryLabel }
354
+ </ Box >
355
+ ) : null }
356
+ </ Box >
357
+ ) : null }
358
+ { children ( childrenProps ) }
359
+ </ Box >
360
+ { endSlot && endSlotPosition === 'fullHeight' ? endSlot : null }
335
361
</ Box >
336
362
337
363
{ message || characterCount ? (
0 commit comments