File Dropzone

A drag-and-drop upload area that also supports click-to-browse. Handles drag counter logic correctly across child elements, filters by file type and max size, and exposes selected files via a callback.

Drag files here or click to browse

Max file size: 5 MB

Accepted: .png,.jpg,.jpeg,.gif,.webp

import { FileDropzone } from "@aetherstack/patterns"

Installation

terminal
npx aether-ui add file-dropzone

Import

import.tsx
import { FileDropzone } from "@aetherstack/patterns"

Usage

file-dropzone.tsx
import * as React from "react"
import { FileDropzone } from "@aetherstack/patterns"

export function MyUploader() {
  const [files, setFiles] = React.useState<File[]>([])

  return (
    <FileDropzone
      onFilesSelected={setFiles}
      accept=".png,.jpg,.jpeg"
      multiple
      maxSize={5 * 1024 * 1024}
    />
  )
}

Props

PropTypeDefaultDescription
onFilesSelected*(files: File[]) => voidCalled with the accepted files after a drop or file picker selection.
acceptstringMIME types or file extensions to accept, e.g. ".png,.jpg" or "image/*".
multiplebooleanfalseAllow selecting multiple files at once.
maxSizenumberMaximum file size in bytes. Files exceeding this are filtered out before onFilesSelected is called.
disabledbooleanfalseDisables all interaction and dims the zone.
childrenReactNodeOptional extra content rendered inside the dropzone.
classNamestringAdditional classes on the wrapper.

* Required

Accessibility

  • The zone has role="button" and tabIndex={0} so it is keyboard focusable.
  • Pressing Enter or Space triggers the file picker dialog.
  • aria-disabled is set when the disabled prop is true.
  • The hidden <input type="file"> is sr-only and aria-hidden — screen readers interact with the button wrapper instead.