I don't believe there's a reliable, cross-browser solution for that. You could however do something like this instead:
<label htmlFor="filePicker" style={{ background:"grey", padding:"5px 10px" }}>
My custom choose file label
</label>
<input id="filePicker" style={{visibility:"hidden"}} type={"file"}>
Here the file input
element is "paired" with a corresponding label
element via the id
and for
attributes (note the in react, for
is instead specified by htmlFor
).
This pairing causes user click interaction with the label
element to trigger that default click behavior on the input
element - which in this case, would cause the OS file selector dialog to open.
This technique gives you control over the label of the file picker, and also allows you to specify styling for the pseudo "label-button" as required.
Hope that helps!