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 component

Use while an application-owned upload is active so the selection cannot change mid-request. There is no loading or readonly state.

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

Define if the component should be in an error state. It usually attaches a CSS class for styling purposes.

hasWarnings Type: booleanDefaultfalse

Define if the component should be in a warning state. Same chrome as errors with --bb-warn; errors take priority.

id Type: string

The id of the native control; the label's for and the description and message ids derive from it. Generated when omitted.

maxFiles Type: number

Maximum number of acceptable files.

Caps the existing and incoming selection together, and only applies in multiple mode.

See example
maxSize Type: number

Max size of the files in bytes.

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

See example
modelValue Type: File | File[] | null

Used by v-model.

multiple Type: booleanDefaultfalse

Allows the selection of multiple items.

Changes both behaviour and model shape: single mode replaces File | null; multiple mode appends to a seeded File[].

See example
name Type: string

Defines the name of the input.

Required inside a BbForm: a dropzone has no label to key the value by, so without name the form throws. Outside a form it renders the hidden input a native multipart post needs (v2 rendered that input unconditionally).

See example
pt Type: 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, message, root. States: active, disabled, errors, readonly, warnings.

See example
readonly Type: booleanDefaultfalse

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

rules Type: RuleExpression<File | File[] | null>

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
tag Type: LayoutTagDefault"div"

Element rendered as the component's wrapper.

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.

Set it when you use string rules: with no label, messages otherwise say "This field".

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 formControls.validationMode ('balanced'). BbForm only.

warnings Type: string | string[]

Warning messages under the dropzone, 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 | File[] | null

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: (errors: DropZoneError[]): void

Emitted once per drop or pick that rejected any file, AFTER that gesture's update:modelValue (if any): all its rejections (size, type, uniqueness, max count), in file order. A clean drop emits none: clear your messages on update:modelValue, set them here.

Emits once per drop or pick that rejected anything, after its update:modelValue, with every rejection as a DropZoneError[]; 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 | File[] | null): void

Emitted when the selected files change. Payload is the new file or file array.

Slots

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

NameDescription
default Type: BbDropzoneDefaultSlotProps

The drop zone area content. Renders inside the <label> that captures drag and file input events. It is a region, not a label: its text does not name the input unless you mark one node with the labelId slot prop.

The visible drop surface. Put labelId on its headline only; a wrapper would pull hints, buttons, and filenames into the accessible name.

See example

Renamed and removed

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

  • hasWarninghasWarningsfails silently
  • 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.