FileInput

FileInput is a component used for users to select files.

Upload file

Usage

import { FileInput } from "@yamada-ui/react"
<FileInput />

Change Variant

Outline
Filled
Flushed

Change Size

Xs
Sm
Md
Lg
Xl

Change Color Scheme

Success
Warning

Allow Multiple Selection

To allow multiple selection, set multiple to true.

Upload files

Specify File Extensions

To specify file extensions, set accept to a string(type).

Upload a PNG or JPEG file

Customize Separator

To customize the separator, set separator to a string.

Upload files

Use Custom Component

To use a custom component, set component to a ReactNode. component provides value(File) and index.

Upload files

Format File Names

To format file names, use format. format provides File.

Upload files

Customize Children

To customize children, use children. children provides File as an array.

Add Addon

To add an addon, wrap FileInput with InputGroup.Root and use InputGroup.Addon.

Upload file

Add Element

To add an element, wrap FileInput with InputGroup.Root and use InputGroup.Element.

Upload file

Disable

To disable, set disabled to true.

Upload file
Upload file
Upload file

Read-Only

To make it read-only, set readOnly to true.

Upload file
Upload file
Upload file

Invalid

To make the input invalid, set invalid to true.

Upload file
Upload file
Upload file
File is required.

Change Border Color

To change the border color, set a color to focusBorderColor or errorBorderColor.

Custom focus border color
Custom focus border color
Custom error border color
Custom error border color

Reset

To reset the value, set resetRef to ref. A callback function will be attached to the set ref, execute it.

Files: 0

Upload files

Props

Accessibility

If you are not using Field.Root, set aria-label or aria-labelledby to FileInput.

<FileInput aria-label="Upload file" placeholder="Upload file" />
<VStack gap="sm">
  <Text as="h3" id="label">
    Upload file
  </Text>

  <FileInput aria-labelledby="label" placeholder="Upload file" />
</VStack>

Keyboard Navigation

KeyDescriptionState
TabFocuses the element.-
Space, EnterActivates the focused element.-

ARIA Roles and Attributes

ElementRoles and AttributesUsage
div.ui-file-input__rootrole="button"Indicates that this is a button.
aria-disabledSets to "true" if disabled or readOnly is set.
aria-labelledbyIf FileInput is within a Field.Root with a label and no placeholder, value, or explicit accessible name is provided, sets the label's id.
aria-describedbyIf FileInput is within a Field.Root and Field.Root has an errorMessage, helperMessage, Field.ErrorMessage, or Field.HelperMessage, sets its id.
aria-invalidSets to "true" if invalid is set.
aria-requiredSets to "true" if required is set.
inputaria-disabledSets to "true" if disabled or readOnly is set.
aria-describedbyIf FileInput is within a Field.Root and Field.Root has an errorMessage, helperMessage, Field.ErrorMessage, or Field.HelperMessage, sets its id.
aria-hiddenExcludes the element from the accessibility tree.
aria-invalidSets to "true" if invalid is set.
aria-requiredSets to "true" if required is set.

Similar Components

Dropzone

Dropzone is a component used for uploading files via drag and drop.

Editable

Editable is a component used to obtain inline editable text input.

Input

Input is a component used to obtain text input from the user.

NumberInput

NumberInput is a component used to obtain numeric input from the user.

PasswordInput

PasswordInput is a component that allows users to input passwords with a visibility toggle.

PinInput

PinInput is a component used to capture pin codes or OTP (One-Time Password) inputs.

Textarea

Textarea is a component used to obtain multi-line text input.

FileButton

FileButton is a button component used for users to select files.

Uses Components & Hooks

Used By Components & Hooks