---
title: FileButton
description: "`FileButton`は、ユーザーがファイルを選択するために使用されるボタンのコンポーネントです。"
links:
- style: https://github.com/yamada-ui/yamada-ui/tree/main/packages/react/src/components/file-button/file-button.style.ts
- source: https://github.com/yamada-ui/yamada-ui/tree/main/packages/react/src/components/file-button
- storybook: https://yamada-ui.github.io/yamada-ui?path=/story/components-filebutton--basic
---
```tsx
Upload
}
/>
```
## 使い方
```tsx
import { FileButton } from "@yamada-ui/react"
```
```tsx
import { FileButton } from "@/components/ui"
```
```tsx
import { FileButton } from "@workspaces/ui"
```
```tsx
```
### バリアントを変更する
```tsx
{(variant, index) => (
{toTitleCase(variant)}
)}
```
### サイズを変更する
```tsx
{(size, index) => (
{toTitleCase(size)}
)}
```
### カラースキームを変更する
```tsx
{(colorScheme, index) => (
{toTitleCase(colorScheme)}
)}
```
### 複数選択を許容する
複数選択を許容する場合は、`multiple`を`true`に設定します。
```tsx
Upload
```
### 拡張子を指定する
拡張子を指定する場合は、`accept`に文字列(タイプ)を設定します。
```tsx
Upload
```
### 無効にする
無効にする場合は、`disabled`を`true`に設定します。
```tsx
Upload
Upload
```
### 読み取り専用にする
読み取り専用にする場合は、`readOnly`を`true`に設定します。
```tsx
Upload
Upload
```
### 無効な入力にする
無効な入力にする場合は、`invalid`を`true`に設定します。
```tsx
Upload
Upload
```
ボーダーの色を変更する場合は、`errorBorderColor`に値を設定します。
```tsx
Upload
```
### リセットする
値をリセットする場合は、`resetRef`に`ref`を設定します。設定された`ref`にコールバック関数が付与されるので、それを実行します。
```tsx
const [files, onChange] = useState(undefined)
const resetRef = useRef<() => void>(null)
const onReset = () => {
onChange(undefined)
resetRef.current?.()
}
return (
files: {files?.length ?? 0}
Upload
)
```
## 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` | - | `"2xl" \| "lg" \| "md" \| "sm" \| "xl" \| "xs"` | The size of the component. |
| `variant` | `"solid"` | `"ghost" \| "outline" \| "solid" \| "subtle" \| "surface" ...` | The variant of the component. |
| `active` | `false` | `boolean` | If `true`, the button is represented as active. |
| `defaultValue` | - | `File[]` | The initial value of the file input. |
| `disabled` | `false` | `boolean` | If `true`, the button is disabled. |
| `disableRipple` | `false` | `boolean` | If `true`, disable ripple effects when pressing a element. |
| `endIcon` | - | `string \| number \| bigint \| boolean \| ReactElement> \| Iterable \| ReactPortal \| Promise<...>` | The icon to display at the end side of the button. |
| `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. |
| `fullRounded` | `false` | `boolean` | If `true`, the button is full rounded. Else, it'll be slightly round. |
| `iconProps` | - | `ButtonIconProps` | The props of the icon element. |
| `invalid` | `false` | `boolean` | If `true`, the field will be invalid. |
| `loading` | `false` | `boolean` | If `true`, the loading state of the button is represented. |
| `loadingIcon` | `"oval"` | `string \| number \| bigint \| boolean \| ReactElement> \| Iterable \| ReactPortal \| Promise<...>` | The icon to display when the button is loading. |
| `loadingMessage` | - | `string \| number \| bigint \| boolean \| ReactElement> \| Iterable \| ReactPortal \| Promise<...>` | The message to display when the button is loading. |
| `loadingPlacement` | `"start"` | `"end" \| "start"` | The placement of the loading indicator. Accepts `start` or `end`. |
| `loadingProps` | - | `ButtonLoadingProps` | The props of the loading icon element. |
| `onChange` | - | `(files: File[] \| undefined) => void` | Function to be called when a file change event occurs. |
| `readOnly` | `false` | `boolean` | If `true`, the field will be readonly. |
| `required` | `false` | `boolean` | If `true`, the field will be required. |
| `resetRef` | - | `RefObject<(() => void) \| null>` | Ref to a reset function. |
| `startIcon` | - | `string \| number \| bigint \| boolean \| ReactElement> \| Iterable \| ReactPortal \| Promise<...>` | The icon to display at the start side of the button. |
| `type` | `"button"` | `"button" \| "reset" \| "submit"` | The type of button. Accepts `button`, `reset`, or `submit`. |
| `value` | - | `File[]` | The value of the file input. |
## アクセシビリティ
現在、v2の移行に伴い、このセクションは更新中です。