• CMSnpm version

    • Overview
    • ContentBuilder
    • InviteUserForm
    • LoginForm
    • RenewPasswordForm
    • WysiwygInput
  • UInpm version

    • Overview
    • Accordion
    • AlertBubble
    • AnnouncementBar
    • Avatar
    • AvatarFileInput
    • Badge
    • Button
    • ButtonGroup
    • ButtonList
    • Calendar
    • Checkbox
    • CheckboxButton
    • CheckboxInput
    • CheckboxList
    • Chip
    • ColorRadio
    • ColorRadioGroup
    • Combobox
    • DatePicker
    • DatePickerInput
    • DateRangePicker
    • DateRangePickerInput
    • DatetimePicker
    • DatetimePickerInput
    • Dialog
    • Dropdown
    • Dropzone
    • ErrorMessage
    • FileInput
    • FlashMessages
    • FormComponent
    • Icon
    • IconButton
    • ImageGallery
    • InfoBox
    • Input
    • Label
    • Layout
    • Lightbox
    • ListItem
    • Loader
    • Lozenge
    • Menu
    • Message
    • Modal
    • ✅ ModalDialog
    • ✅ ModalHeader
    • MultiCombobox
    • MultiSelect
    • Pagination
    • Paper
    • Popover
    • Radio
    • RadioGroup
    • RasterImage
    • Select
    • Switch
    • ✅ Tabs
    • TextInput
    • TextLink
    • Textarea
    • TimePicker
    • TimePickerInput
    • Toggle
    • Tooltip
    • Typography
  • Formnpm version

    • Overview
    • AvatarFileInput
    • CheckboxButton
    • CheckboxInput
    • CheckboxList
    • ColorRadioGroup
    • Combobox
    • DatePickerInput
    • DateRangePickerInput
    • DatetimePickerInput
    • Dropzone
    • FileInput
    • Form
    • FormRenderer
    • GpsInput
    • MoneyInput
    • MultiCombobox
    • MultiSelect
    • NumberInput
    • PasswordInput
    • RadioGroup
    • Select
    • TextInput
    • Textarea
    • TimePickerInput
    • Toggle
  • DataGridnpm version

    • Overview
    • DataGrid
    • DataGridCustomExample
    • ExportButton
    • FilterList
    • Filters
    • FiltersButton
    • FulltextInput
    • HiddenColumns
    • HiddenColumnsButton
    • Pagination
    • RowCounts
    • RowsPerPageSelect
    • SelectedRowsToolbar
    • TableV2
    • ToolbarControl
    • ToolbarCustoms
    • ToolbarTabs
  • Wysiwygnpm version

    • Overview
  • Resizernpm version

    • Overview
  • Routernpm version

    • Overview
  • Corenpm version

    • Overview
  • Core-Reactnpm version

    • Overview
  • DnDnpm version

    • Overview
  • Stylesnpm version

    • Overview
  • Localizenpm version

    • Overview
  • Analyticsnpm version

    • Overview
  • Datepickernpm version

    • Overview
  • Icons-generatornpm version

    • Overview
  • Smart-addressnpm version

    • Overview
  • E2Enpm version

    • Overview
  • E2E-Playwrightnpm version

    • Overview
View source on GitLab

Dropzone

Multi-file drag-and-drop upload area built on react-dropzone. Files are uploaded immediately on drop/selection; Dropzone.List renders the uploaded files with progress and remove controls.

When to use

Use Dropzone for uploading one or more files via drag-and-drop or a click-to-browse area. Pair the drop area (Dropzone) with Dropzone.List — both share the same value (a DropzoneFile[]) and onChange so the list stays in sync with what was dropped.

  • Inside a @uxf/form form: use @uxf/form/dropzone instead — it wires react-hook-form (useController), reads the form context, and adds count validation (minFilesCount / maxFilesCount). @uxf/ui/dropzone is the controlled primitive you drive with value / onChange.
  • Single-file field with a file name: use FileInput.
  • Avatar / image upload with a preview: use AvatarFileInput.

Usage

import { FileResponse } from "@uxf/core/types";
import { Dropzone } from "@uxf/ui/dropzone";
import { DropzoneFile } from "@uxf/ui/dropzone/types";
import { getDropzoneState } from "@uxf/ui/utils/get-dropzone-state";
import { useState } from "react";

// your uploader: send the file to storage, resolve with the stored file
declare function uploadFile(file: File): Promise<FileResponse>;

function Example() {
    const [files, setFiles] = useState<DropzoneFile[]>([]);
    const { status } = getDropzoneState(files);

    return (
        <>
            <Dropzone
                isDisabled={status === "UPLOADING"}
                label="Use drag and drop or click to upload"
                name="attachments"
                onChange={setFiles}
                onUploadFile={uploadFile}
                value={files}
            />
            <Dropzone.List name="attachments" onChange={setFiles} value={files} />
        </>
    );
}

API

Import from @uxf/ui/dropzone:

ExportKindDescription
DropzonecomponentThe drop area (DropzoneInput).
Dropzone.ListcomponentList of uploaded files (DropzoneList).
DropzoneInputPropstypeProps of Dropzone.
DropzoneListPropstypeProps of Dropzone.List.

Related helpers and types (separate deep imports, not on the component):

  • getDropzoneState — @uxf/ui/utils/get-dropzone-state
  • DropzoneFile type — @uxf/ui/dropzone/types

Dropzone props (DropzoneInputProps)

PropTypeDefaultDescription
valueDropzoneFile[] | undefined—Required. Current files (controlled).
onChange(value: DropzoneFile[] | undefined, event?) => void—Required. Receives the updated file list.
onUploadFile(file: File, options?: UploadOptions) => Promise<FileResponse>—Required. Uploads a dropped file; called per file with an AbortController and progress callback.
namestring—Required. Field name (also emitted as data-name).
acceptAccept ({ [mime: string]: string[] })—Accepted MIME types in react-dropzone format, e.g. { "image/*": [] }.
maxFileSizenumber—Max size per file in bytes.
minFileSizenumber—Min size per file in bytes.
maxFilesCountnumber—Max number of files. When 1, the input is single-file (multiple is off). Files past the limit are rejected individually — the ones within it still upload.
iconIconName"cloud"Icon shown in the drop area.
labelReactNode—Drop area label.
helperTextReactNode—Helper / error text under the drop area.
isNotClickablebooleanfalseDisable click-to-browse (drag only).
isNotDraggablebooleanfalseDisable dragging (click only).
onDropRejected(fileRejections: FileRejection[]) => void—Called for files rejected by accept/size/count (react-dropzone FileRejection[]).
onUploadComplete(files: FileResponse[]) => Promise<void>—Called once all uploads settle, with the successfully uploaded files.
onUploadError(err: unknown) => void—Called when an individual upload fails.
isDisabledbooleanfalseDisable the drop area.
isReadOnly / isInvalid / isRequired / isFocusedbooleanfalseState flags (styling / data-*).
idstring—Input id.
className / stylestring / CSSProperties—Root styling.

Dropzone.List props (DropzoneListProps)

PropTypeDefaultDescription
valueDropzoneFile[] | undefined—Required. Files to render (share with Dropzone).
onChange(value: DropzoneFile[] | undefined, event?) => void—Required. Receives the list after a removal.
namestring—Required. Field name.
errorTextstring"File upload error"Text shown under a file that failed to upload.
isDownloadableOnClickbooleanfalseRender the file link with download instead of opening in a new tab.
onRemoveConfirm(file: DropzoneFile) => Promise<boolean>—Confirm before removing; remove only if it resolves true.
renderItem(file, onRemove, isUploading) => ReactNode—Custom renderer for each list item (replaces the default row).
isDisabledbooleanfalseHide the per-item remove buttons.
className / stylestring / CSSProperties—List styling.

getDropzoneState

import { getDropzoneState } from "@uxf/ui/utils/get-dropzone-state";

const { status, errorMessage } = getDropzoneState(files);
// status: "OK" | "UPLOADING" | "ERROR"

Derives the overall upload state from the file list. Use status === "UPLOADING" to disable the drop area while files are in flight.

DropzoneFile

Extends FileResponse (@uxf/core/types) with upload bookkeeping:

FieldTypeDescription
originalFileFileThe picked file (present until the server response replaces it).
progressnumber | nullUpload progress 0–100, or null when not computable.
errorunknownSet when the file's upload failed.
abortControllerAbortControllerAborts the in-flight upload when the file is removed.

Variants & states

  • Files upload immediately on drop/select. Each pending file gets a temporary negative id and a progress value until its onUploadFile promise resolves and the server FileResponse replaces it.
  • Removing a file that is still uploading calls its abortController.abort().
  • onDropRejected fires when react-dropzone rejects files (wrong type, too large/small, too many). Rejection is per file, not per batch: dropping more files than maxFilesCount uploads the ones within the limit and reports only the surplus as too-many-files. A ready-made handler exists at @uxf/ui/dropzone/handle-rejected-files (handleRejectedFiles), but it shows hardcoded Czech alert() messages — prefer your own handler in production.
  • Inside a UiContext that provides domain, already-uploaded file names in Dropzone.List render as links to the stored file.

Requirements

Client component ("use client").

Import the required stylesheets once in your global CSS:

@import url("@uxf/ui/css/icon.css");
@import url("@uxf/ui/css/dropzone.css");

Also requires the global @uxf/ui token layer, set up once per app — see @uxf/ui setup.

Default
Open in new tab
States
Open in new tab