File drop

stable 3.2 kB
<hk-file-drop>

A drop zone with a real browse fallback and per-file progress. Dragging is a convenience, never the only way in. The progress bar is an indicator, not a receipt: at 100% it has nothing left to say, so it clears and the row settles into a plain "Uploaded" — a list of finished uploads should read as a list, not as a wall of full bars.

#upload#files
In the package npm i hellskitchen-ui Import hk-file-drop and use it directly.

Live demo

Running in this page — interact with it.

Inputs

NameTypeDefaultDescription
acceptstring[][]MIME types or extensions. Empty accepts anything.
multiplebooleantrueAllows more than one file per drop.
maxSizenumber | nullnullPer-file byte ceiling. Oversize files are rejected with a reason.
disabledbooleanfalseIgnores drops and disables the browse button.
keepProgressbooleanfalseHolds the bar at 100% after an upload finishes. Off by default — a completed bar reports nothing the "Uploaded" row does not.

Outputs

  • filesEventEmitter<File[]>

    Accepted files, after filtering.

  • uploadedEventEmitter<File>

    Fires per file as its row reaches 100%. The row progress is simulated by the component; it does not track a real transfer.

  • rejectedEventEmitter<HkFileDropRejection[]>

    Files that failed, each with a reason: 'type' or 'size'.

Keyboard

  • Enter / Space Opens the file browser from the Browse control

Theming

Component tokens, each falling back to a global one:

PropertyDefaultControls
--hk-drop-border#e2e8f0Dashed border when idle.
--hk-drop-border-active#ef4444Border while a drag is over the zone.
--hk-drop-bg-active#fef2f2Fill while a drag is over the zone.

Accessibility

  • The browse control is a real file input behind a label, so keyboard and screen-reader users are not asked to drag.
  • Each bar is a progressbar with aria-valuenow, and "Uploaded" is a status announced once per file.
  • Rejections say why — type or size — instead of failing silently.

More in Forms