API reference: @salmonui/inputs/file-upload
FileUploadcomponent
import { FileUpload } from '@salmonui/inputs/file-upload';function FileUpload(props: FileUploadProps): ReactNode;
File picker with a drop zone, validation, a file list and an optional
upload queue. ref is a FileUploadApi; unknown props go
to the native file input, className / style to the root.
Props: FileUploadProps
| Name | Signature | Description |
|---|---|---|
labeloptionalinherited | label?: ReactNode; | |
descriptionoptionalinherited | description?: ReactNode; | |
errorMessageoptionalinherited | errorMessage?: ((ctx: { readonly errors: readonly string[]; }) => ReactNode) | ReactNode; | Error text (or a function of the errors) shown while the field is invalid. |
invalidoptionalinherited | invalid?: boolean; | Forces the error state. |
validationoptionalinherited | validation?: FieldValidation; | Rules in the Data Grid vocabulary. |
validateOnoptionalinherited | validateOn?: ValidateOn; | When errors appear; default the |
sizeoptionalinherited | size?: FieldSize; | Metric set. Default |
filesoptional | readonly files?: readonly (FileEntry | FilePreload)[] | undefined; | Controlled list; preloaded entries default to status |
defaultFilesoptional | readonly defaultFiles?: readonly (FileEntry | FilePreload)[] | undefined; | |
onFilesChangeoptional | readonly onFilesChange?: ((files: readonly FileEntry[], details: FilesChangeDetails) => void) | undefined; | |
acceptoptional | readonly accept?: string | undefined; | Extensions and MIME types ( |
multipleoptional | readonly multiple?: boolean | undefined; | |
directoryoptional | readonly directory?: boolean | undefined; | Picks and drops folders ( |
minSizeoptional | readonly minSize?: number | undefined; | Bytes; smaller files get error |
maxSizeoptional | readonly maxSize?: number | undefined; | Bytes; larger files get error |
maxFilesoptional | readonly maxFiles?: number | undefined; | Files beyond the limit get error |
uploadoptional | readonly upload?: UploadTransport | undefined; | Transport; without it the files only submit with the form. |
removeoptional | readonly remove?: RemoveTransport | undefined; | Server removal of uploaded files. |
autoUploadoptional | readonly autoUpload?: boolean | undefined; | Uploads as soon as files are added. Default |
concurrencyoptional | readonly concurrency?: number | undefined; | Parallel uploads; |
dropTargetoptional | readonly dropTarget?: RefObject<Element | null> | undefined; | Another element that accepts drops. |
dropEffectoptional | readonly dropEffect?: 'copy' | 'move' | 'link' | 'none' | undefined; |
|
showFileListoptional | readonly showFileList?: boolean | undefined; | Default |
renderFileoptional | readonly renderFile?: ((ctx: FileRenderContext) => ReactNode) | undefined; | Content of one list item. |
renderTriggeroptional | readonly renderTrigger?: ((ctx: {
readonly open: () => void;
readonly text: string;
}) => ReactNode) | undefined; | Content of the drop zone button. |
localeTextoptional | readonly localeText?: FileUploadLocaleText | undefined; | |
localeoptional | readonly locale?: string | undefined; | Locale of file sizes. Default |
onBeforeFilesAddoptional | readonly onBeforeFilesAdd?: ((event: BeforeFilesAddEvent) => void) | undefined; | |
onBeforeUploadoptional | readonly onBeforeUpload?: ((event: BeforeFileEvent) => void) | undefined; | |
onUploadProgressoptional | readonly onUploadProgress?: ((file: FileEntry) => void) | undefined; | |
onUploadSuccessoptional | readonly onUploadSuccess?: ((file: FileEntry, result: unknown) => void) | undefined; | |
onUploadErroroptional | readonly onUploadError?: ((file: FileEntry, reason: unknown) => void) | undefined; | |
onUploadCompleteoptional | readonly onUploadComplete?: ((files: readonly FileEntry[]) => void) | undefined; | |
onBeforeRemoveoptional | readonly onBeforeRemove?: ((event: BeforeFileEvent) => void) | undefined; | |
onBeforeClearoptional | readonly onBeforeClear?: ((event: BeforeClearEvent) => void) | undefined; | |
classNameoptional | readonly className?: string | undefined; | |
styleoptional | readonly style?: CSSProperties | undefined; | |
classNamesoptional | readonly classNames?: {
readonly trigger?: string;
readonly list?: string;
readonly item?: string;
readonly label?: string;
readonly description?: string;
readonly error?: string;
} | undefined; | Part classes: |
refoptional | readonly ref?: Ref<FileUploadApi> | undefined; |