FileInput

core package3.2.2

Note: All components shown on this site are supported by the Constellation design system. To learn how to configure Theme Cosmos, visit Pega Community.

The FileInput component lets a user upload files or attachments via drag-and-drop or by opening the user's file explorer when clicked.

Usage

FileInputs can be formatted to accept on single files or multiple files. When the input detects files have been added, an onFilesAdded callback function is triggered. This callback should receive a list of files that were attached, and manage their state within your application.

The FileInput component accepts a list of files that will render FileUploadItems within a Grid underneath the input. The FileInput component allows for standard Form Field structures such as being set required or disabled, as well as including a label, status, or info.

Example

 Drag and drop or Choose files 

Related components

Properties

NameDescriptionDefaultType
classNameAdditional CSS classes.string
disabledDisable the control. The browser defaults to false.boolean
filesAn array of files that have been uploaded.FileUploadItemProps[]
idSets DOM id for the control and associates label element via 'for' attribute. If an id is not pass, a random id will be generated for any render.string
infoIt is recommended to pass a simple string to offer guidance. Text will be styled based on status prop.ReactNode
labelPass a string or a fragment with an Icon and string.ReactNode
labelHiddenVisually hides the label region.boolean
multipleAllow multiple files to be selected from the OS specific file browser. NOTE: This does not restrict multiple files from being added via drag and drop. Restrict multi file drag and drop via onFilesAdded and custom info message.falseboolean
nameSets html name attribute for the underlying control. Useful for mapping to a data field.string
onFilesAdded(files: File[]) => void
refRef for the input element within the component's dom structure.Ref<HTMLInputElement>
requiredIndicate if the field is required. The browser defaults to false.boolean
statusSet visual state based on a validation state.
'error' |'pending' |'success' |'warning'