Some properties provide flexibility for specific integrations. Follow the component's usage guidance. Customizations beyond the documented patterns need a use case approved by DNB UX. Read about intended use and customization.
Properties#
| Type | Description | |
|---|---|---|
id | string function object React.Context | (optional) Unique id used together with the useUpload hook to manage the files. Needed when wanting to connect with the useUpload hook. |
children | React.ReactNode | (optional) Content to display below the title and text. Can be used to add custom content. |
variant | "default" "compact" | (optional) Defines the appearance. Use one of these: default or compact. Defaults to default. |
acceptedFileTypes | Array<string> Array<AcceptedFileType> | (required) List of accepted file types. Either as a string or an AcceptedFileType. When providing a list of AcceptedFileType, the accepted file types will be presented in a table (see example). |
filesAmountLimit | number | (optional) Defines the amount of files the user can select and upload. Defaults to 100. |
fileMaxSize | number false | (optional) Defines the max file size of each file in MB. Use either 0 or false to disable. Defaults to 5 MB. |
title | string | (optional) Custom text property. Replaces the default title. Can be disabled using false. |
text | string | (optional) Custom text property. Replaces the default text. Can be disabled using false. |
download | boolean | (optional) Causes the browser to treat all listed files as downloadable instead of opening them in a new browser tab or window. Defaults to false. |
allowDuplicates | boolean | (optional) Allows uploading of duplicate files. Defaults to false. |
disableDragAndDrop | boolean | (optional) Disables file drag and drop, by removing the drop zone. Defaults to false. |
buttonProps | ButtonProps | (optional) Define any valid Eufemia Button properties or HTML attribute inside an object, to customize the upload button behavior and appearance. |
skeleton | boolean | (optional) If set to true, an overlaying skeleton with animation will be shown. |
buttonText | React.ReactNode | (optional) Custom text for the upload button. Overrides the default translation. |
fileLimitsButtonText | React.ReactNode | (optional) Custom text for the button that shows the accepted file types and sizes in the compact variant. Overrides the default translation. Use false to remove the button and the file limits. |
fileTypeTableCaption | React.ReactNode | (optional) Custom caption for the file type table used by screen readers. Overrides the default translation. |
fileTypeDescription | React.ReactNode | (optional) Custom label for the file type description column. Overrides the default translation. |
fileSizeDescription | React.ReactNode | (optional) Custom label for the file size description column. Overrides the default translation. |
fileAmountDescription | React.ReactNode | (optional) Custom text for the file amount description. Overrides the default translation. |
fileSizeContent | React.ReactNode | (optional) Custom text for the file size content. Overrides the default translation. |
errorLargeFile | React.ReactNode | (optional) Custom error message for files exceeding the size limit. Overrides the default translation. |
errorUnsupportedFile | React.ReactNode | (optional) Custom error message for unsupported file types. Overrides the default translation. |
errorAmountLimit | React.ReactNode | (optional) Custom error message when the file amount limit is reached. Overrides the default translation. |
errorDeleteFailed | React.ReactNode | (optional) Custom error message for a file when an async onFileDelete throws or rejects without a message. Overrides the default translation. |
loadingText | React.ReactNode | (optional) Custom text displayed during file loading. Overrides the default translation. |
deleteButton | React.ReactNode | (optional) Custom text for the delete button. Overrides the default translation. |
listAriaLabel | string | (optional) Custom aria-label for the file list. Overrides the default translation. |
Space | string object | (optional) Spacing properties like top or bottom are supported. |
FileItem#
The file item object is representing the files of the Upload component.
| Type | Description | |
|---|---|---|
file | File | (required) The file object. This is the same object as the one returned by the File API. |
id | string | (required) Unique ID for the file item. This ID is generated by the component and is not user-defined. |
exists | boolean | (optional) Indicates if the file item already exists in the list of files. This is useful for distinguishing between new and existing files. |
isLoading | boolean | (optional) Indicates if the file item is currently being loaded. This is useful for showing a loading state while the file is being processed. |
errorMessage | React.ReactNode | (optional) Provide an error message to be displayed. This is useful for indicating issues with the file upload process. |
description | React.ReactNode | (optional) Provide a description to be displayed. This is useful for providing additional information about the file. |
removeDeleteButton | boolean | (optional) Set to true to remove the delete button from the file item. This is useful for preventing users from deleting files. |
deleteButtonProps | ButtonProps | (optional) Define any valid Eufemia Button properties or HTML attribute inside an object. |
removeLink | boolean | (optional) Set to true to remove the link for the file item. This is useful for preventing users from opening the file. |
AcceptedFileType#
The accepted file type object is used to define file max size for specific file types.
When providing a list of AcceptedFileType to Uploads acceptedFileTypes, the accepted file types will be presented in a table. Here is an example.
The table is sorted by maxFileSize, with the smallest first. File types without a max size come last. File types with the same maxFileSize are listed in the given order.
| Type | Description | |
|---|---|---|
fileType | string | (required) The name of the accepted file type. |
fileMaxSize | number false | (optional) Defines the max file size of the given file type in MB. Use either 0 or false to disable. If not provided, it defaults to the value of Uploads fileMaxSize which defaults to 5 MB. |
Translations#
All translation keys listed in the translations table below, can be used as a component property (like title or text).
More info about translations can be found in the general localization and Eufemia Forms localization docs.
| Key | nb-NO | en-GB | sv-SE | da-DK |
|---|---|---|---|---|
Upload.title | Last opp dokumenter | Upload documents | Ladda upp dokument | Upload dokumenter |
Upload.text | Dra og slipp eller velg hvilke filer du vil laste opp. | Drag & drop your files or choose files to upload. | Dra och släpp eller välj vilka filer du vill ladda upp. | Træk og slip eller vælg hvilke filer du vil uploade. |
Upload.textSingular | Dra og slipp eller velg hvilken fil du vil laste opp. | Drag & drop your file or choose which file to upload. | Dra och släpp eller välj vilken fil du vill ladda upp. | Træk og slip eller vælg hvilken fil du vil uploade. |
Upload.fileTypeTableCaption | Tillatte filer og maks filstørrelse | Allowed files and max. file size | Tillåtna filer och max filstorlek | Tilladte filer og maks filstørrelse |
Upload.fileTypeDescription | Tillatte filer: | Allowed files: | Tillåtna filer: | Tilladte filer: |
Upload.fileSizeDescription | Maks filstørrelse: | Max. file size: | Max filstorlek: | Maks filstørrelse: |
Upload.fileAmountDescription | Maks antall filer: | Max. number of files: | Max antal filer: | Maks antal filer: |
Upload.fileSizeContent | %size MB | %size MB | %size MB | %size MB |
Upload.buttonText | Velg filer | Choose files | Välj filer | Vælg filer |
Upload.buttonTextSingular | Velg fil | Choose file | Välj fil | Vælg fil |
Upload.fileLimitsButtonText | Tillatte filer og størrelser | Allowed files and sizes | Tillåtna filer och storlekar | Tilladte filer og størrelser |
Upload.loadingText | Laster | Loading | Laddar | Indlæser |
Upload.errorLargeFile | Filen du prøver å laste opp er for stor, den maksimale støttede størrelsen er %size MB. | The file you are trying to upload is too big, the maximum size supported is %size MB. | Filen du försöker ladda upp är för stor, den maximalt tillåtna storleken är %size MB. | Filen du prøver at uploade er for stor, den maksimale understøttede størrelse er %size MB. |
Upload.errorAmountLimit | Det er begrenset hvor mange filer du kan laste opp (%amount). | There is a limit to how many files you can upload (%amount). | Det är begränsat hur många filer du kan ladda upp (%amount). | Der er en grænse for, hvor mange filer du kan uploade (%amount). |
Upload.errorUnsupportedFile | Filen du prøver å laste opp er ikke støttet. | The file you are trying to upload is not supported. | Filen du försöker ladda upp stöds inte. | Filen du prøver at uploade er ikke understøttet. |
Upload.errorDeleteFailed | Filen kunne ikke slettes. | The file could not be deleted. | Filen kunde inte raderas. | Filen kunne ikke slettes. |
Upload.deleteButton | Slett | Delete | Radera | Slet |
Upload.listAriaLabel | opplastede filer | uploaded files | uppladdade filer | uploadede filer |
Upload.errorRequired | Du må laste opp minst en fil. | You must upload a file. | Du måste ladda upp minst en fil. | Du skal uploade mindst én fil. |
Upload.errorInvalidFiles | Fjern alle filer som har feil. | Remove all files with errors. | Ta bort alla filer som innehåller fel. | Fjern alle filer, der indeholder fejl. |
Upload.errorUploadFailed | Filen kunne ikke lastes opp. | The file could not be uploaded. | Filen kunde inte laddas upp. | Filen kunne ikke uploades. |