SubComponents

Control

The control subcomponent is required to render the Control of the FileUploadInput component. Because of this, this component extends the native inputarrow-up-rightcomponent props. Because of this, you can use all of the native props. This is a required children.

Control API

triangle-exclamation
Props
Type
Required

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;

❌

chevron-rightfileNamehashtag

This controls the FileUploadinput fileName when using a controlled approach.

chevron-rightdefaultFileNamehashtag

This controls the FileUploadinput fileName when using a uncontrolled approach when the component is first rendered.

chevron-rightacceptedFiles and explorerAcceptedFileshashtag

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.

chevron-rightplaceholderhashtag

Value shown if the fileName is undefined.

chevron-rightonFileClearhashtag

Callback called when the 'x' icon is clicked.

chevron-rightonChangehashtag

Executed when the fileName changes.

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