FileInput
Capture files from user
Source
LLM docs
Docs
PackageIcon
Usage
FileInput component supports Input and Input.Wrapper component features and all input element props. The FileInput documentation does not include all features supported by the component – see the Input documentation to learn about all available features.
Input description
Loading state
Set loading prop to display a loading indicator. By default, the loader is displayed on the right side of the input.
You can change the position with the loadingPosition prop to 'left' or 'right'. This is useful for async operations like API calls, searches, or validations:
Controlled
When multiple is false:
When multiple is true:
Uncontrolled
FileInput can be used with uncontrolled forms the same way as a native input[type="file"].
Set the name attribute to include file input value in FormData object on form submission.
To control the initial value in uncontrolled forms, use the defaultValue prop.
Example usage of uncontrolled FileInput with FormData:
Multiple
Set multiple to allow the user to pick more than one file:
Accept
Set the accept prop to restrict file selection to specific mime types:
Clearable
Set the clearable prop to display a clear button in the right section of the input
when a file is selected. Note that if you define a custom right section, the clear button
will not be rendered.
Clear section mode
The clearSectionMode prop determines how the clear button and rightSection are rendered:
'both'(default) – render both the clear button andrightSection'rightSection'– render only the user-suppliedrightSection, ignore clear button'clear'– render only the clear button, ignorerightSection
Custom value component
Error state
Invalid name
Disabled state
Left and right sections
FileInput supports leftSection and rightSection props. These sections are rendered with absolute positioning inside the input wrapper. You can use them to display icons, input controls, or any other elements.
You can use the following props to control sections styles and content:
rightSection/leftSection– React node to render on the corresponding side of inputrightSectionWidth/leftSectionWidth– controls the width of the right section and padding on the corresponding side of the input. By default, it is controlled by the componentsizeprop.rightSectionPointerEvents/leftSectionPointerEvents– controls thepointer-eventsproperty of the section. If you want to render a non-interactive element, set it tononeto pass clicks through to the input.
Styles API
FileInput supports the Styles API; you can add styles to any inner element of the component with the classNames prop. Follow the Styles API documentation to learn more.
Description
Error
Component Styles API
Hover over selectors to highlight corresponding elements
Get element ref
Accessibility
If FileInput is used without the label prop, it will not be announced properly by screen readers:
Set aria-label to make the input accessible. In this case the label will not be visible, but screen readers will announce it:
If the label prop is set, the input will be accessible and it is not required to set aria-label:
FileInputProps type
FileInputProps type is a generic interface which accepts a single type argument:
the multiple value.