You are viewing a PR preview for PR #1506

Agriculture Design System
Beta
Design System for the Export Service

File upload

The File upload component allows users to attach multiple files to a form via drag-and-drop or by browsing the device.

View in FigmaView in StorybookView in Github
import { ... } from '@ag.ds-next/react/file-upload';

Usage

File upload components can be imported via the file-upload entrypoint in the @ag.ds-next/react package.

For example:

import { ... } from '@ag.ds-next/react/file-upload';

Props

FileUpload Props
PropTypeDescription
labelstringDescribes the purpose of the field.
onChange(value: FileWithStatus[]) => voidCallback for when an accepted file is added or removed
accept?("application/msword" | "application/vnd.openxmlformats-officedocument.wordprocessingml.document" | "application/pdf" | "application/rtf" | "application/vnd.ms-excel" | ... 24 more ... | CustomFileMimeType)[]List of acceptable file MIME types, e.g. `image/jpeg`, `application/pdf`.
disabled?boolean
existingFiles?ExistingFile[]Used to display a list of files that have already been uploaded.
hideOptionalLabel?booleanIf true, "(optional)" will never be appended to the label.
hideThumbnails?booleanDefault: "false"If true, the thumbnails will be hidden.
hint?stringProvides extra information about the field.
id?string
invalid?booleanIf true, the invalid state will be rendered.
maxFiles?numberThe maximum number of files allowed to be selected. By default there is no limit (if `multiple` is true).
maxSize?numberThe maximum allowed size for each file, measured in KB
message?stringMessage to show when the field is invalid.
multiple?booleanWhether multiple files are allowed to be selected.
name?string
onBlur?FocusEventHandler<HTMLInputElement>
onFocus?FocusEventHandler<HTMLInputElement>
onRemoveExistingFile?((file: ExistingFile) => void)Callback function called when an existing file is removed.
ref?Ref<HTMLInputElement>
required?booleanIf false, "(optional)" will be appended to the label.
value?FileWithStatus[]Default: "[]"The value of the input

Source

You can view the full source code for this package on Github.