Skip to main content

Upload

The Upload component allows users to select and upload files via browsing or drag-and-drop. It supports configurable file type and size validation, multiple file uploads, and provides visual feedback for each file's upload status.

Import

// with @dhl-official/react-library:
import { DhlUpload } from "@dhl-official/react-library"
// with @dhl-official/ui-libraries/react-library:
import { DhlUpload } from "@dhl-official/ui-libraries/react-library"

Code

<DhlUpload
acceptedTypes=".pdf,.docx,.odt,.rtf"
maxSize={31457280}
multiple
/>

Interactive Demo

Readme

Properties

PropertyAttributeDescriptionTypeDefault
acceptedTypesaccepted-typesAn optional prop defining a comma-separated list of accepted file types. Supports MIME types and extensions (e.g. ".pdf,.docx" or "application/pdf,image/*").stringDHL_UPLOAD.DEFAULTS.ACCEPTED_TYPES
backgroundbackgroundAn optional prop to set the background of the component container. Defaults to transparent."transparent" | "white"DHL_UPLOAD.BACKGROUND.TRANSPARENT
browseButtonLabelbrowse-button-labelAn optional prop for the browse button label.string"Browse Files"
cancelButtonLabelcancel-button-labelAn optional prop for the cancel button label.string"Cancel"
continueButtonLabelcontinue-button-labelAn optional prop for the continue button label.string"Continue"
dataAriaLabeldata-aria-labelAn optional prop defining the text read by the screen reader.string"File upload"
dataClassNamedata-class-nameAn optional class name prop for the component.stringundefined
dataIddata-idAn optional prop. Gives a valid HTML ID attribute value for the component.string`dhl-upload-${getRandomString()}`
dataTestiddata-testidAn optional prop. The test id attached to the component as a data-testid attribute.stringundefined
descriptiondescriptionAn optional prop for the description text displayed in the drop zone.string"Or drop here to upload"
filesfilesAn optional prop for the list of files rendered in the upload. The component manages this list in response to user interaction, but consumers may provide an initial value or take control by updating it externally. Each entry follows the DhlUploadFile interface.DhlUploadFile[][]
isDisabledis-disabledAn optional flag to define if the component is disabled.booleanfalse
maxSizemax-sizeAn optional prop for the maximum file size in bytes. Defaults to 30 MB.numberDHL_UPLOAD.DEFAULTS.MAX_SIZE
maxSizeLabelmax-size-labelAn optional prop for the max size display text. If not set, the value is auto-generated from the maxSize prop.stringundefined
multiplemultipleAn optional flag to allow multiple file uploads.booleanDHL_UPLOAD.DEFAULTS.MULTIPLE
showBordershow-borderAn optional flag to display the dashed border around the drop zone.booleanDHL_UPLOAD.DEFAULTS.SHOW_BORDER
showCtashow-ctaAn optional flag to display the Cancel/Continue action buttons.booleanDHL_UPLOAD.DEFAULTS.SHOW_CTA
showDescriptionshow-descriptionAn optional flag to display the description text.booleanDHL_UPLOAD.DEFAULTS.SHOW_DESCRIPTION
showFileTypesshow-file-typesAn optional flag to display the accepted file types.booleanDHL_UPLOAD.DEFAULTS.SHOW_FILE_TYPES
showFilesshow-filesAn optional flag to display the file list.booleanDHL_UPLOAD.DEFAULTS.SHOW_FILES
showIconshow-iconAn optional flag to display the upload icon in the drop zone.booleanDHL_UPLOAD.DEFAULTS.SHOW_ICON

Events

EventDescriptionType
dhlUploadCancelEvent emitted when the cancel button is clicked.CustomEvent<void>
dhlUploadContinueEvent emitted when the continue button is clicked.CustomEvent<{ files: DhlUploadFile[]; }>
dhlUploadFileRemovedEvent emitted when a file is removed from the list.CustomEvent<{ fileId: string; fileName: string; }>
dhlUploadFilesAddedEvent emitted when files are added to the upload (after validation).CustomEvent<{ files: DhlUploadFile[]; }>

Dependencies

Depends on

Graph


Built by DHL User Interface Library Team!