@@ -38,7 +38,11 @@ export interface FileInputProps extends ButtonThemeProps, InputAttributes {
38
38
* Boolean if the children should not have some spacing between the icon and
39
39
* itself. The default behavior is to use the `<TextIconSpacing>` component
40
40
* for text styled input buttons, but this can be disabled if you want to use
41
- * a screenreader only accessible label.
41
+ * a screen-reader only accessible label.
42
+ *
43
+ * Note: This will default to `false` if {@link children} are provided.
44
+ *
45
+ * @defaultValue `true`
42
46
*/
43
47
disableIconSpacing ?: boolean ;
44
48
@@ -48,6 +52,14 @@ export interface FileInputProps extends ButtonThemeProps, InputAttributes {
48
52
* selected.
49
53
*/
50
54
disableRepeatableFiles ?: boolean ;
55
+
56
+ /**
57
+ * Children should generally be provided when the {@link buttonType} is
58
+ * set to `"text"`. This defaults to a screen-reader only accessible text.
59
+ *
60
+ * @defaultValue `<SrOnly>Upload</SrOnly>`
61
+ */
62
+ children ?: ReactNode ;
51
63
}
52
64
53
65
const block = bem ( "rmd-file-input" ) ;
@@ -63,12 +75,12 @@ export const FileInput = forwardRef<HTMLInputElement, FileInputProps>(
63
75
className : propClassName ,
64
76
icon : propIcon ,
65
77
iconAfter = false ,
66
- children = < SrOnly > Upload </ SrOnly > ,
78
+ children : propChildren ,
67
79
theme = "primary" ,
68
80
themeType = "contained" ,
69
81
buttonType = "icon" ,
70
82
multiple = false ,
71
- disableIconSpacing = false ,
83
+ disableIconSpacing : propDisableIconSpacing ,
72
84
disableRepeatableFiles = false ,
73
85
onKeyDown,
74
86
onKeyUp,
@@ -86,6 +98,13 @@ export const FileInput = forwardRef<HTMLInputElement, FileInputProps>(
86
98
) {
87
99
const { id, disabled } = props ;
88
100
const icon = useIcon ( "download" , propIcon ) ;
101
+ const disableIconSpacing =
102
+ propDisableIconSpacing ?? typeof propChildren === "undefined" ;
103
+
104
+ let children = propChildren ;
105
+ if ( typeof propChildren === "undefined" ) {
106
+ children = < SrOnly > Upload</ SrOnly > ;
107
+ }
89
108
90
109
const { ripples, className, handlers } = useInteractionStates ( {
91
110
handlers : {
0 commit comments