Skip to content
bitboss-ui3.0.0-beta.64

BbDropzone

Capture and validate files while the application owns errors, upload progress, cancellation, and retry.

import { BbDropzone } from 'bitboss-ui';

On this page

Use it for

Use BbDropzone when users need a visible drop target, picker access, and file validation.

Use something else when

  • <input type="file"> โ€” one picker with no drop surface or rendered selection is enough
  • BbProgress โ€” the task is showing an upload already in progress

Also see: Validated forms.

BbDropzone captures and validates files. It does not upload them.

Passthrough

Hover or tap a part to outline it. The toggles turn on loading, errors and warnings where the component has them; only parts get a row.

Validate receipt attachments

Set accept, max-size and max-files on the zone, and turn every rejected file into a message the user can act on.

team-dinner.heic is not a receipt (PNG, JPG or PDF only).

No receipts attached yet.

Rejected files never enter the model. After a drop updates the model, @error hands you every typed rejection of that drop in one array, and a clean drop emits none. The component never fills errors itself, so clear your messages on update:modelValue and set them on error.

Model and file constraints

multiple changes both behaviour and type: single mode replaces a File | null; multiple mode appends to a seeded File[].

accept takes MIME types (application/pdf), wildcards (image/*), extensions (.pdf) or bare tokens (pdf), and a bare token covers both the extension and the MIME type. If you write explicit entries, pair each MIME type with its extension, because a dropped file can arrive with an empty file.type. max-size is bytes per file, and max-files counts the files already picked plus the new ones.

Own the drop surface

The default slot is the visible surface. Put labelId on its headline only, not on a wrapper that also contains hints, buttons, and filenames.

The real input is visually hidden. Paint a focus ring from the slot's focused flag and a drop highlight from dragging, and wire open() to a visible Browse button. Without labelId the zone takes the localized default name ("Select files" in English), which only fits a zone with no visible headline. Do not nest another label; the slot already renders inside one.

Upload and submit

Inside a BbForm, give the dropzone a name and build FormData from the files @submit hands you.

Sent with the Q2 pack

  • Q2 revenue review.pdf2.4 MB

Send with no new PDF and the form stops at the dropzone and moves focus to it. A dropzone has no label, so without name the form throws, and rule messages say "This field" unless you set validation-label. Outside a form, name renders the hidden input a native multipart post needs. Progress, cancellation, retry and server errors stay in your own state.

Coming from v2hidden input only with name

v2 always rendered the hidden submittable input; now it exists only when name is set.

Lock the zone during an upload

Disable the zone while an upload is active so the selection cannot change mid-request.

To show files nobody can change, such as a request already sent for review, set readonly. Drop, the picker and open() do nothing, the input stays focusable, and a named zone still submits its files, which disabled would not. The file list is yours, so hide its remove buttons and your Browse button with the slot's readonly flag.

There is no loading state: pair an active transfer with BbProgress. On a phone, the zone opens the system file picker.