DitherCharts

File upload

Updated

FileUpload is a drop area in a pixel-dashed ink frame, dithered while files are dragged over it. It's a native file input stretched invisibly across the frame, so clicking, dropping and the keyboard all work, and the files submit with a form. Like the charts, it takes your theme's ink and paper, light or dark, and needs no Tailwind.

Example

Up to 5 MB each.

import "@/components/dithercharts/controls.css"
import { FileUpload } from "@/components/dithercharts/file-upload"

<FileUpload
  label="Data"
  name="data"
  accept=".csv,text/csv"
  multiple
  prompt="Drop CSV files or click to browse"
  hint="Up to 5 MB each."
  onFilesChange={(files) => setFiles(files)}
/>

Install

Controls install with DitherCharts Pro. See Installation to log in, then import controls.css once, e.g. in your root layout.

npx dithercharts add file-upload

Props

It renders a native element, so every other attribute that element takes passes through.

FileUpload props
PropTypeDefaultDescription
labelrequiredType ReactNodeDefault –The caption above the drop area, and the input's accessible name.
promptType ReactNodeDefault "Drop files or click to browse"The drop area's text until files are chosen.
onFilesChangeType (files: File[]) => voidDefault –Called with the chosen or dropped files.
hintType ReactNodeDefault –Help text under the field, read after its label.
errorType ReactNodeDefault –An error under the field; it also marks the field invalid.