Forms
Dropzone
Takes files or a whole folder by drop or by the system's chooser: a game folder, a math release.
Drop a game folder
Its art, sound, texts and math, as one folder.
No folder yet.
Installation
pnpm add @elsikora/keystone-ui-kitUsage
import { Dropzone } from "@elsikora/keystone-ui-kit";import { useState } from "react";import { Dropzone } from "@elsikora/keystone-ui-kit";
export default function DropzoneDefaultExample() { const [count, setCount] = useState<number | null>(null);
return ( <div className="flex flex-col gap-3"> <Dropzone directory label="Drop a game folder" description="Its art, sound, texts and math, as one folder." onFiles={(files): void => { setCount(files.length); }} /> <p className="text-sm text-fg-2">{count === null ? "No folder yet." : `${String(count)} files.`}</p> </div> );}Examples
A folder
Drop a game folder
Its art, sound, texts and math, as one folder.
No folder yet.
Files
Drop math files
Disabled
Uploads are closed
API reference
Dropzone
| Prop | Type | Default | Description |
|---|---|---|---|
label | ReactNode | - | What to give. |
description | ReactNode | - | What to give and what happens next. |
directory | boolean | false | A folder, every level, instead of single files. |
accept | string | - | File types the chooser offers. |
buttonLabel | string | "Choose files" or "Choose a folder" | The chooser button's words. |
disabled | boolean | false | Unavailable. |
onError | (error: unknown) => void | - | Called when a dropped folder or file cannot be read; the drop then gives no files. |
onFiles | (files: ReadonlyArray<{ file: File; path: string }>) => void | - | Every file of one choice or drop, with its path in the folder. |
Notes
- The button is the keyboard's way in; the drop area is an addition, never the only way.