FileInput
The FileInput component allows users to upload files, supporting both a traditional input style and a dropzone style.
사용 시기
- 하나 이상의 파일을 업로드해야 할 때.
- 끌어서 놓기로 파일을 업로드해야 할 때.
끌어서 놓기
파일을 특정 영역으로 끌어서 업로드할 수 있습니다. 또는 선택하여 업로드할 수도 있습니다.
astro
---
import FileInput from '@/components/data-entry/FileInput.astro';
---
<FileInput variant="dropzone" label="Upload Avatar" /> 클릭하여 업로드
클래식 모드. 업로드 버튼을 클릭하면 파일 선택 대화 상자가 나타납니다.
astro
---
import FileInput from '@/components/data-entry/FileInput.astro';
---
<FileInput variant="input" label="Resume" description="PDF or DOCX up to 5MB" /> 미리보기 파일 사용자 지정
슬롯을 사용하여 로컬 미리보기를 사용자 지정합니다.
astro
---
import FileInput from '@/components/data-entry/FileInput.astro';
---
<FileInput variant="dropzone">
<span class="text-blue-500 underline">Click here</span> to select a file
<span slot="description" class="text-xs text-zinc-400">Supported formats: .jpg, .png</span>
</FileInput> 유효성 검사 및 매개 변수
최대 파일 및 최대 크기와 같은 매개 변수를 구성하여 파일 목록을 완전히 제어할 수 있습니다.
astro
---
import FileInput from '@/components/data-entry/FileInput.astro';
---
<FileInput
variant="dropzone"
label="Upload Documents"
description="Max 2 files, up to 1MB each."
multiple
maxFiles={2}
maxSize={1}
/> PNG 파일만 업로드
허용할 수 있는 파일 형식을 제한합니다.
astro
---
import FileInput from '@/components/data-entry/FileInput.astro';
---
<FileInput
variant="input"
label="Upload Image"
acceptType="images"
placeholder="Select image..."
/> API
| 속성 | 설명 | 타입 | 기본값 |
|---|---|---|---|
| variant | 입력의 시각적 변형 | 'input' | 'dropzone' | 'input' |
| label | 파일 입력의 레이블 | string | '' |
| description | 설명 또는 도움말 텍스트 | string | '' |
| multiple | 여러 파일 선택 허용 | boolean | false |
| maxFiles | 허용되는 최대 파일 수 | number | |
| maxSize | 최대 파일 크기 (MB) | number | |
| acceptType | 사전 정의된 허용 파일 유형 | 'images' | 'spreadsheets' | 'documents' | 'pdfs' | 'videos' | 'audios' | 'all' | 'all' |
| placeholder | 입력 변형의 자리 표시자 텍스트 | string | 'Choose a file...' |
| error | Indicates an error state or displays an error message | string | boolean | |
| success | Indicates a success state or displays a success message | string | boolean | |
| disabled | Disables the component | boolean | false |