Skip to content

FileInput

A file input supporting both inline and drag-and-drop dropzone modes.

Choose file
function SingleFileStory(): React.JSX.Element {
const [value, setValue] = useState<File | null>(null);
return <FileInput label="Upload" onChange={setValue} value={value} />;
}
<SingleFileStory />
Choose files
function DropzoneStory(): React.JSX.Element {
const [value, setValue] = useState<File[]>([]);
return (
<FileInput
isMultiple
label="Upload"
mode="dropzone"
onChange={setValue}
value={value}
/>
);
}
<DropzoneStory />
PDF, PNG, or JPG up to 10 MB
Choose file
function WithDescriptionStory(): React.JSX.Element {
const [value, setValue] = useState<File | null>(null);
return (
<FileInput
description="PDF, PNG, or JPG up to 10 MB"
label="Upload"
onChange={setValue}
value={value}
/>
);
}
<WithDescriptionStory />
PNG or JPG only
Choose file
function AcceptImagesStory(): React.JSX.Element {
const [value, setValue] = useState<File | null>(null);
return (
<FileInput
accept="image/png, image/jpeg"
description="PNG or JPG only"
label="Upload"
onChange={setValue}
value={value}
/>
);
}
<AcceptImagesStory />
Choose file
<FileInput isDisabled label="Upload" onChange={() => {}} value={null} />
Choose file
<FileInput isLoading label="Upload" onChange={() => {}} value={null} />
Choose file
function RequiredStory(): React.JSX.Element {
const [value, setValue] = useState<File | null>(null);
return (
<FileInput isRequired label="Upload" onChange={setValue} value={value} />
);
}
<RequiredStory />
Choose file
<FileInput
label="Upload"
onChange={() => {}}
status={{message: 'A file is required.', type: 'error'}}
value={null}
/>
Choose file
<FileInput label="Upload" onChange={() => {}} size="sm" value={null} />
Choose file
<FileInput label="Upload" onChange={() => {}} size="lg" value={null} />
Choose files
<FileInput
isDisabled
isMultiple
label="Upload"
mode="dropzone"
onChange={() => {}}
value={[]}
/>
report.pdf
<FileInput
isReadOnly
label="Upload"
onChange={() => {}}
value={new File(['report'], 'report.pdf', {type: 'application/pdf'})}
/>

A file input supporting both inline and drag-and-drop dropzone modes.

When isMultiple: true, isOptional: false, isRequired: false

PropTypeDefaultDescription
isMultiple*trueWhether multiple files can be selected.
maxFilesnumberMaximum number of files allowed.
onChange*(files: File[]) => voidCalled when the selected files change.
value*File[]Currently selected files.
acceptstringComma-separated MIME types or file extensions the input accepts.
classNamestringAdditional CSS class names applied to the root element.
data-testidstringTest ID applied to the hidden file input.
descriptionReactNodeSupporting text rendered below the label.
isDisabledbooleanfalseWhether the input is disabled.
isLabelHiddenbooleanfalseWhether to visually hide the label.
isLoadingbooleanfalseWhether the input is in a loading state.
isReadOnlybooleanfalseWhether the selected files are displayed without allowing interaction.
label*stringField label text.
labelIconIconComponentIcon shown before the label.
labelTooltipReactNodeTooltip content shown next to the label.
maxSizenumberMaximum file size in bytes.
mode"input" | "dropzone"'input'Display mode: inline input or drag-and-drop dropzone.
placeholderstringPlaceholder text shown when no file is selected.
refRef<HTMLInputElement>Ref forwarded to the hidden file input element.
size"sm" | "md" | "lg"'md'Visual size of the input.
statusInputStatusValidation status displayed below the input.
styleCSSPropertiesInline styles applied to the root element.
isOptionalfalse
isRequiredfalse

When isMultiple: true, isOptional: true, isRequired: false

PropTypeDefaultDescription
isMultiple*trueWhether multiple files can be selected.
maxFilesnumberMaximum number of files allowed.
onChange*(files: File[]) => voidCalled when the selected files change.
value*File[]Currently selected files.
acceptstringComma-separated MIME types or file extensions the input accepts.
classNamestringAdditional CSS class names applied to the root element.
data-testidstringTest ID applied to the hidden file input.
descriptionReactNodeSupporting text rendered below the label.
isDisabledbooleanfalseWhether the input is disabled.
isLabelHiddenbooleanfalseWhether to visually hide the label.
isLoadingbooleanfalseWhether the input is in a loading state.
isReadOnlybooleanfalseWhether the selected files are displayed without allowing interaction.
label*stringField label text.
labelIconIconComponentIcon shown before the label.
labelTooltipReactNodeTooltip content shown next to the label.
maxSizenumberMaximum file size in bytes.
mode"input" | "dropzone"'input'Display mode: inline input or drag-and-drop dropzone.
placeholderstringPlaceholder text shown when no file is selected.
refRef<HTMLInputElement>Ref forwarded to the hidden file input element.
size"sm" | "md" | "lg"'md'Visual size of the input.
statusInputStatusValidation status displayed below the input.
styleCSSPropertiesInline styles applied to the root element.
isOptional*true
isRequiredfalse

When isMultiple: true, isOptional: false, isRequired: true

PropTypeDefaultDescription
isMultiple*trueWhether multiple files can be selected.
maxFilesnumberMaximum number of files allowed.
onChange*(files: File[]) => voidCalled when the selected files change.
value*File[]Currently selected files.
acceptstringComma-separated MIME types or file extensions the input accepts.
classNamestringAdditional CSS class names applied to the root element.
data-testidstringTest ID applied to the hidden file input.
descriptionReactNodeSupporting text rendered below the label.
isDisabledbooleanfalseWhether the input is disabled.
isLabelHiddenbooleanfalseWhether to visually hide the label.
isLoadingbooleanfalseWhether the input is in a loading state.
isReadOnlybooleanfalseWhether the selected files are displayed without allowing interaction.
label*stringField label text.
labelIconIconComponentIcon shown before the label.
labelTooltipReactNodeTooltip content shown next to the label.
maxSizenumberMaximum file size in bytes.
mode"input" | "dropzone"'input'Display mode: inline input or drag-and-drop dropzone.
placeholderstringPlaceholder text shown when no file is selected.
refRef<HTMLInputElement>Ref forwarded to the hidden file input element.
size"sm" | "md" | "lg"'md'Visual size of the input.
statusInputStatusValidation status displayed below the input.
styleCSSPropertiesInline styles applied to the root element.
isOptionalfalse
isRequired*true

When isMultiple: false, isOptional: false, isRequired: false

PropTypeDefaultDescription
isMultiplefalseWhether multiple files can be selected.
maxFilesundefinedMaximum number of files allowed. Only applicable when isMultiple is true.
onChange*(file: File | null) => voidCalled when the selected file changes.
value*File | nullCurrently selected file.
acceptstringComma-separated MIME types or file extensions the input accepts.
classNamestringAdditional CSS class names applied to the root element.
data-testidstringTest ID applied to the hidden file input.
descriptionReactNodeSupporting text rendered below the label.
isDisabledbooleanfalseWhether the input is disabled.
isLabelHiddenbooleanfalseWhether to visually hide the label.
isLoadingbooleanfalseWhether the input is in a loading state.
isReadOnlybooleanfalseWhether the selected files are displayed without allowing interaction.
label*stringField label text.
labelIconIconComponentIcon shown before the label.
labelTooltipReactNodeTooltip content shown next to the label.
maxSizenumberMaximum file size in bytes.
mode"input" | "dropzone"'input'Display mode: inline input or drag-and-drop dropzone.
placeholderstringPlaceholder text shown when no file is selected.
refRef<HTMLInputElement>Ref forwarded to the hidden file input element.
size"sm" | "md" | "lg"'md'Visual size of the input.
statusInputStatusValidation status displayed below the input.
styleCSSPropertiesInline styles applied to the root element.
isOptionalfalse
isRequiredfalse

When isMultiple: false, isOptional: true, isRequired: false

PropTypeDefaultDescription
isMultiplefalseWhether multiple files can be selected.
maxFilesundefinedMaximum number of files allowed. Only applicable when isMultiple is true.
onChange*(file: File | null) => voidCalled when the selected file changes.
value*File | nullCurrently selected file.
acceptstringComma-separated MIME types or file extensions the input accepts.
classNamestringAdditional CSS class names applied to the root element.
data-testidstringTest ID applied to the hidden file input.
descriptionReactNodeSupporting text rendered below the label.
isDisabledbooleanfalseWhether the input is disabled.
isLabelHiddenbooleanfalseWhether to visually hide the label.
isLoadingbooleanfalseWhether the input is in a loading state.
isReadOnlybooleanfalseWhether the selected files are displayed without allowing interaction.
label*stringField label text.
labelIconIconComponentIcon shown before the label.
labelTooltipReactNodeTooltip content shown next to the label.
maxSizenumberMaximum file size in bytes.
mode"input" | "dropzone"'input'Display mode: inline input or drag-and-drop dropzone.
placeholderstringPlaceholder text shown when no file is selected.
refRef<HTMLInputElement>Ref forwarded to the hidden file input element.
size"sm" | "md" | "lg"'md'Visual size of the input.
statusInputStatusValidation status displayed below the input.
styleCSSPropertiesInline styles applied to the root element.
isOptional*true
isRequiredfalse

When isMultiple: false, isOptional: false, isRequired: true

PropTypeDefaultDescription
isMultiplefalseWhether multiple files can be selected.
maxFilesundefinedMaximum number of files allowed. Only applicable when isMultiple is true.
onChange*(file: File | null) => voidCalled when the selected file changes.
value*File | nullCurrently selected file.
acceptstringComma-separated MIME types or file extensions the input accepts.
classNamestringAdditional CSS class names applied to the root element.
data-testidstringTest ID applied to the hidden file input.
descriptionReactNodeSupporting text rendered below the label.
isDisabledbooleanfalseWhether the input is disabled.
isLabelHiddenbooleanfalseWhether to visually hide the label.
isLoadingbooleanfalseWhether the input is in a loading state.
isReadOnlybooleanfalseWhether the selected files are displayed without allowing interaction.
label*stringField label text.
labelIconIconComponentIcon shown before the label.
labelTooltipReactNodeTooltip content shown next to the label.
maxSizenumberMaximum file size in bytes.
mode"input" | "dropzone"'input'Display mode: inline input or drag-and-drop dropzone.
placeholderstringPlaceholder text shown when no file is selected.
refRef<HTMLInputElement>Ref forwarded to the hidden file input element.
size"sm" | "md" | "lg"'md'Visual size of the input.
statusInputStatusValidation status displayed below the input.
styleCSSPropertiesInline styles applied to the root element.
isOptionalfalse
isRequired*true