---
title: FileInput
description: "`FileInput` is a component used for users to select files."
links:
- style: https://github.com/yamada-ui/yamada-ui/tree/main/packages/react/src/components/file-input/file-input.style.ts
- source: https://github.com/yamada-ui/yamada-ui/tree/main/packages/react/src/components/file-input
- storybook: https://yamada-ui.github.io/yamada-ui?path=/story/components-fileinput--basic
---
```tsx
```
## Usage
```tsx
import { FileInput } from "@yamada-ui/react"
```
```tsx
import { FileInput } from "@/components/ui"
```
```tsx
import { FileInput } from "@workspaces/ui"
```
```tsx
```
### Change Variant
```tsx
{(variant, index) => (
)}
```
### Change Size
```tsx
{(size, index) => (
)}
```
### Change Color Scheme
```tsx
{(colorScheme, index) => (
)}
```
### Allow Multiple Selection
To allow multiple selection, set `multiple` to `true`.
```tsx
```
### Specify File Extensions
To specify file extensions, set `accept` to a string(type).
```tsx
```
### Customize Separator
To customize the separator, set `separator` to a string.
```tsx
```
### Use Custom Component
To use a custom component, set `component` to a `ReactNode`. `component` provides `value`(`File`) and `index`.
```tsx
{name}}
gapY="xs"
multiple
placeholder="Please upload file"
/>
```
### Format File Names
To format file names, use `format`. `format` provides `File`.
```tsx
name.substring(0, name.indexOf("."))}
multiple
placeholder="Please upload file"
/>
```
### Customize Children
To customize children, use `children`. `children` provides `File` as an array.
```tsx
{(files) => Selected: {files?.length ?? 0}}
```
### Add Addon
To add an addon, wrap `FileInput` with `InputGroup.Root` and use `InputGroup.Addon`.
```tsx
```
### Add Element
To add an element, wrap `FileInput` with `InputGroup.Root` and use `InputGroup.Element`.
```tsx
```
### Disable
To disable, set `disabled` to `true`.
```tsx
```
### Read-Only
To make it read-only, set `readOnly` to `true`.
```tsx
```
### Invalid
To make the input invalid, set `invalid` to `true`.
```tsx
```
### Change Border Color
To change the border color, set a color to `focusBorderColor` or `errorBorderColor`.
```tsx
```
### Reset
To reset the value, set `resetRef` to `ref`. A callback function will be attached to the set `ref`, execute it.
```tsx
const [value, onChange] = useState(undefined)
const resetRef = useRef<() => void>(null)
const onReset = () => {
onChange(undefined)
resetRef.current?.()
}
return (
files: {value?.length ?? 0}
{value?.length ? (
) : null}
)
```
## Props
| Prop | Default | Type | Description |
| ------------------ | ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------ |
| `as` | - | `As` | The HTML element to render. |
| `asChild` | - | `boolean` | Merges its props onto its immediate child. |
| `css` | - | `CSSObject \| CSSObject[]` | The CSS object. |
| `colorScheme` | - | `"amber" \| "black" \| "blackAlpha" \| "blue" \| "cyan" \| "danger" \| "emerald" \| "error" \| "flashy" \| "fuchsia" ...` | Set color scheme variables. |
| `size` | `"md"` | `"2xl" \| "lg" \| "md" \| "sm" \| "xl" \| "xs"` | The size of the component. |
| `variant` | `"outline"` | `"filled" \| "flushed" \| "outline" \| "plain"` | The variant of the component. |
| `children` | - | `(files: File[] \| undefined) => ReactNode` | A callback that returns a React node. |
| `component` | - | `(props: { index: number; value: File }) => ReactNode` | The component that displays uploaded files. |
| `defaultValue` | - | `File[]` | The initial value of the file input. |
| `errorBorderColor` | - | `"-moz-initial" \| "ActiveBorder" \| "ActiveCaption" \| "aliceblue" \| "amber.100" \| "amber.200" \| "amber.300" \| "amber.400" \| "amber.50" \| "amber.500" ...` | The border color when the input is invalid. |
| `focusBorderColor` | - | `"-moz-initial" \| "ActiveBorder" \| "ActiveCaption" \| "aliceblue" \| "amber.100" \| "amber.200" \| "amber.300" \| "amber.400" \| "amber.50" \| "amber.500" ...` | The border color when the input is focused. |
| `format` | - | `(value: File, index: number) => string` | A callback that formats the name of the uploaded file. |
| `invalid` | `false` | `boolean` | If `true`, the field will be invalid. |
| `onChange` | - | `(files: File[] \| undefined) => void` | Function to be called when a file change event occurs. |
| `resetRef` | - | `RefObject<(() => void) \| null>` | Ref to a reset function. |
| `separator` | `","` | `string` | The string to separate uploaded files. |
| `value` | - | `File[]` | The value of the file input. |
## Accessibility
Currently, this section is being updated due to the migration of v2.