Skip to content

BbDropzone

Supports drag-and-drop file input flows.

import { BbDropzone } from 'bitboss-ui';

On this page

Props

NameDescription
accept Type: string[]

File filter: MIME types ('image/png'), wildcards ('image/*'), extensions ('.png') or bare tokens ('png', upgraded to the extension and its MIME type from the lazily imported mime database; files that arrive earlier wait for it).

Validated on picker and drop paths. Takes MIME types, wildcards, .ext extensions or bare tokens (pdf); a bare token covers both the extension and the MIME type. Pair explicit MIME entries with their extension, because a dropped file can arrive with an empty file.type.

See example
autofocus Type: Booleanish

Focuses the field when it mounts (a dialog already open included), unless the user is typing in another field.

disabled Type: booleanDefaultfalse

Disables the field: no pick, no drop, and a named field posts nothing.

Use while an application-owned upload is active so the selection cannot change mid-request. There is no loading state. A disabled field posts nothing: to keep the files shown and submitted, use readonly.

See example
errors Type: string | string[]

Error messages under the field, a string or array, in an aria-live="polite" region and first in the control's aria-describedby, so they are re-read when it regains focus.

Does not fill itself from @error. Map the typed rejections to your own messages and pass them back: clear them on update:modelValue, set them on error.

See example
formless Type: booleanDefaultfalse

Keep this control out of the enclosing BbForm entirely: not submitted, not dirty, not reset, not validated. For a control that is not form data (a filter, a "show advanced" switch).

hasErrors Type: booleanDefaultfalse

The error state (aria-invalid, the errors pt state) without a message.

hasWarnings Type: booleanDefaultfalse

The warning state without a message; errors take priority.

hideLabel Type: booleanDefaultfalse

Hides the label visually; it still names the control.

Use it when the slot already carries a visible headline: the label still names the file input.

See example
hint Type: string

Helper line under the field, shown while the field has focus (always, with persistent-hint).

id Type: string

The id of the native file input; the label's for, the useBbDropzone(id) handle and the message ids derive from it. Generated when omitted.

Set it to open the mounted field from another button with useBbDropzone(id).

See example
label requiredType: string

The field's label: its <label> and the control's accessible name.

maxFiles Type: number

Most files held. Unset: no limit. 1 makes a one-file field (the picker then takes one file). A file past the limit is rejected; nothing held is ever replaced.

Caps the existing and incoming selection together. Past the cap a new file is rejected, never swapped in; one file is :max-files="1".

See example
maxSize Type: number

Largest file, in bytes.

A per-file limit in bytes. Rejected files never enter the model.

See example
modelValue Type: File[]

The files held: only files that passed the rules. A pick or drop appends to it.

name Type: string

The name the files post under in a native form submit (a hidden input mirrors the value), and the field's key in a BbForm.

Outside a form it renders the hidden input a native multipart post needs (v2 rendered that input unconditionally). Inside a BbForm it keys the value, like on every field.

See example
persistentHint Type: booleanDefaultfalse

Keeps the hint displayed.

pt Type: (PtCompoundOf<"", { readonly parts: readonly ["root", "label", "content", "message", "hint"]; readonly states: readonly ["hasValue", "readonly", "disabled", "warnings", "errors", "active"]; readonly wide: readonly ["hasValue", "readonly", "disabled", "warnings", "errors", "active"]; }> & PtMap<BbDropzonePtPart, BbDropzonePtState>)

Passthrough, object form: the same keys as the pt:* attributes without the prefix. See the pt:<part> row.

pt:<part> Type: PtValue

Passthrough, attribute form: one attribute per part, pt:<part>, and per part and state, pt:<part>:<state>. Parts: content, hint, label, message, root. States: active, disabled, errors, hasValue, readonly, warnings.

See example
readonly Type: booleanDefaultfalse

Shows the files; the user cannot change them: drop, the file picker and open() do nothing, yet the input stays focusable and a named field still submits its files (unlike disabled). Your slot renders the list: hide your remove buttons with the slot's readonly.

Your slot renders the file list: hide its remove and Browse buttons with the slot's readonly.

See example
rules Type: RuleExpression<File[]>

vee-validate rules for this field. Only inside a BbForm.

Checks the accepted files only: type, size and count rejections never reach the model, so they arrive through @error, not through a rule.

See example
validationLabel Type: string

The field's name in validation messages ({field}): "Email is not valid". Defaults to the label (or legend), then "This field"; never the name. Set it when the label is hidden or reads badly in a sentence (icon-only, a question). BbForm only.

Rule messages already use the label. Set it only when the label reads badly in a sentence.

See example
validationMode Type: ValidationMode

When the field validates: aggressive (each change), balanced (on leave, then live while in error), lazy (on leave), submit-only, submit-live. Unset: the BbForm's validation-mode, then all.validationMode ('balanced'). BbForm only.

warnings Type: string | string[]

Warning messages under the field, a string or string array: amber, in their own aria-live region, and in the control's aria-describedby after the errors. A non-empty list implies the warning state; errors win when both are set.

v-model

Values kept in sync through v-model.

NameDescription
modelValue Type: File[]

Contains validated files only. Upload progress, cancellation, retry, and server errors remain application-owned state.

See example

Events

NameDescription
blur Type: (event: FocusEvent): void

Emitted when the file input loses focus. Forwards the original DOM FocusEvent.

error Type: (rejections: BbFileRejection[]): void

Emitted once per drop or pick that rejected any file, AFTER that gesture's update:modelValue (if any): all its rejections, in file order. A clean drop emits none.

Emits once per drop or pick that rejected anything, after its update:modelValue (if it accepted anything), with every rejection as a BbFileRejection[]; a clean drop emits none. It never mutates the model or writes a message for the user.

See example
focus Type: (event: FocusEvent): void

Emitted when the file input receives focus. Forwards the original DOM FocusEvent.

update:modelValue Type: (value: File[]): void

Emitted when a pick or drop accepted files: the held files with the new ones appended. A gesture that accepted nothing emits none.

Slots

The listed properties are the ones exposed to the slot scope.

NameDescription
default Type: BbDropzoneDefaultSlotProps

The area: free content, no design of its own. A click anywhere in it opens the picker, except on a real button or link; a file dropped on it is taken. The only visible surface: no fallback content.

The area: a click anywhere opens the picker except on a real button or link, so a Browse <button> calls open(). Put labelId on one headline only; a wrapper would pull hints, buttons and filenames into the accessible name. Paint focus with :class="{ 'bb-ring': focused }".

See example
hint Type: CommonFieldLabelSlotProps

Replaces the hint text; alone it still renders the row.

label Type: CommonFieldLabelSlotProps

Replaces the label text.

Renamed and removed

Names from v2 and from earlier 3.0 betas that no longer work, and what to write instead.

  • hasWarninghasWarningsfails silently
  • maxmaxFilesfails silently

    The count limit is max-files (beside max-size); a file past it is rejected, never swapped in.

  • multipleremovedfails silently

    The value is always a File[] and takes many files by default; a one-file field is :max-files="1" (read files[0])

  • tagremovedfails silently

    The field's root is always a <div> (the field frame: label, area, hint, messages)

  • validateOnvalidationModefails silently

    An array of events became one mode (aggressive | balanced | lazy | submit-only | submit-live). The old defaults (['blur'], ['inactive'], a toggle's ['update:modelValue', 'change', 'blur']) are balanced, the new default: delete the prop. A text field on ['update:modelValue'] is validation-mode="aggressive". Set it once on <BbForm validation-mode> instead of per field.

  • vidremovedfails silently

    A display name (v2: vid="Email address") is now validation-label; a field path (3.0 betas: vid="address.city") is now name (brackets for a native post: address[city]). check --fix picks by the value.