SubComponents
Control
The control subcomponent is required to render the Control of the FileUploadInput component. Because of this, this component extends the native inputcomponent props. Because of this, you can use all of the native props. This is a required children.
Control API
Notice that there is a difference between using hasError, isDisabled, isReadOnly here or in the parent component. It is not recommended to change this props in the Control subcomponent, because this props can be inherited from the Wrapper. If you use it in the Control subcomponent, you will get the state only in the field.
fileName
string
β
defaultFileName
string
β
hasError
boolean
β
isDisabled
boolean
β
isReadOnly
boolean
β
acceptedFiles
string
β
explorerAcceptedFiles
'Audio' | 'Images' | 'All' | 'Video' | string;
β
placeholder
string
β
onFileClear
(e: FileUploadInputOnFileClearProps) => void;
β
onChange
(e: FileUploadInputOnChangeProps) => void;
β
defaultFileName
This controls the FileUploadinput fileName when using a uncontrolled approach when the component is first rendered.
acceptedFiles and explorerAcceptedFiles
Similar to the standard HTML file input element (input[type='file']), our FileUploadInput component allows you to specify a list of file extensions separated by commas. We've built-in automatic validation, which means we'll check the file's extension for you. If the uploaded file has an extension that isn't on your list, we won't allow it to be uploaded. Here's the important part: While the "accept" attribute in HTML input[type='file'] elements provides a visual filter to guide users, it can be bypassed by determined users. They can manually select different file types in the file selection dialog or change the filter. That's the main difference between both, the explorerAcceptedFiles does not do any validation on the client side, just set a filter on the explore, meanwhile the acceptedfiles will explicitly validate it.
Button
You can add your own custom <FileUploadInput.Button />. If no Node is provided, only the Input will be rendered. The <FileUploadInput.Button /> should always be a <FileUploadInput.Control> children. This subcomponent extends the native SDS Button props.
HelpText
The HelpText subcomponent extends the SDS label component. See for reference: HelpText.
Label
The Label subcomponent extends the SDS label component. See for reference: Label
Last updated