File upload

A drop zone and file picker that checks file type, size and count before files reach your form. The value is a File[] ; uploading the files is up to your code.

  • vig-file-upload
Import
import { FileUpload } from '@vigdx/ui/file-upload';

Basic

Bind [(value)] to a File[] signal; empty is [] . Click the zone to open the file dialog or drop a file on it. accept uses the syntax of the native attribute and is also checked for dropped files.

Resume

PDF or Word document.

No file chosen.

Multiple files and limits

multiple allows several files, maxFiles caps the total and maxFileSize the size of each file in bytes. Files that fail a check stay out of the value, show a message at once and are emitted through rejected with their reason.

Photos

Up to 3 images, 2 MB each.

0 accepted · last rejected: none

Read-only, disabled and error

readonly lists the files without remove buttons and keeps the zone from opening; disabled blocks it. Errors show once the field is touched and invalid .

Signed contract
  • contract-signed.pdf 242.2 kB
  • appendix-a.pdf 1.8 MB

Attachments

Uploads are closed.

Invoice Required

Attach the invoice to continue.

Translated labels

dropLabel and removeAriaLabel (the file name is appended) translate the texts per instance. errorMessages can use the {file} , {maxSize} and {maxFiles} placeholders of the rejection errors. File sizes are formatted for the active locale.

Belgeler
  • kimlik.pdf 93.8 kB

Reactive Forms

Import VigValueAccessor next to the component to use formControlName , [formControl] or ngModel . Type the control as File[] ; Validators.required treats [] as missing.

Receipts Required

Files: []

Signal Forms

vig-file-upload implements FormValueControl<File[]> . Signal Forms' required() treats [] as filled, so check the length with validate() for a mandatory upload.

Proof of address

Valid: no · 0 file(s)

Styling hooks

Internal elements carry a stable data-part and the component's data-scope; both are public API, so removing one is a breaking change. Select a part by both, e.g. [data-scope="file-upload"][data-part="label"] { … }: the pair stays within this component when kit components nest, and also reaches parts in overlay panels, which render outside the host. State is exposed through aria-* and, where listed, a data-state; literal values are checked by the API gate, values computed from the component's state follow its documented types. Other data-* attributes listed below (such as data-opening while an overlay animates) are API too. See Customizing.

Scope: [data-scope="file-upload"]

FileUpload styling hooks
Part Element data-state
label The visible label. —
dropzone The drop zone button that opens the file dialog. —
icon The upload icon in the drop zone. —
prompt The drop zone text. —
input The hidden native file input. —
files The list of chosen files. —
file One file row. —
file-name The file name (base truncates, extension stays). —
file-size The formatted file size. —
remove The remove button of a file. —
hint The vig-hint (a display: contents host; style its text part). —
disabled-reason The vig-hint with the disabled reason ( display: contents ). —
error The vig-field-error (a display: contents host; style its message part). —

Accessibility

  • The drop zone is a native <button> named by the label and the drop text (singular or plural after multiple), so keyboard users open the file dialog with Enter or Space; dragging is never required. A button cannot carry aria-required, so required adds a visually hidden "Required" (requiredLabel) to its description.
  • The chosen files are a list labelled by the field label. Long names truncate before the extension, which stays visible; the full name stays in the DOM. Each file has a remove button named "Remove" plus the file name (removeAriaLabel).
  • Hint and error are linked to the zone through aria-describedby; rejected files set aria-invalid="true" and the message names the file and the limit.
  • State the accepted types, size and count in the hint, so users know the limits before choosing files.

API

FileUpload

vig-file-upload component

File picker with a drop zone. The zone is a button that opens the native file dialog, so it works by keyboard; files can also be dragged onto it. Picked files are checked against accept, maxFileSize and maxFiles; rejected ones are left out, reported through the field error and the rejected output. Empty is [].

FileUpload props
Name Type Default Description
acceptstring''

Same syntax as the native attribute: .pdf,image/*. Also enforced on drop.

dirtybooleanfalse
—
disabledbooleanfalse
—
disabledReasonsreadonly WithOptionalFieldTree<DisabledReason>[][]
—
dropLabelstring | undefinedundefined

Drop-zone prompt; defaults to a singular or plural label after multiple.

errorMessagesRecord<string, string>—
—
errorsreadonly ValidationError.WithOptionalFieldTree[][]
—
hiddenbooleanfalse
—
hintstring | undefinedundefined
—
invalidbooleanfalse
—
label required string—
—
maxFilesnumber | undefinedundefined

Most files the field holds in total.

maxFileSizenumber | undefinedundefined

Largest accepted file, in bytes.

multiplebooleanfalse
—
namestring''
—
pendingbooleanfalse
—
readonlybooleanfalse
—
removeAriaLabelstring | undefinedundefined
—
requiredbooleanfalse
—
requiredLabelstring | undefinedundefined

Screen-reader text conveying required: the drop zone is a button, which cannot carry aria-required, so it joins the description.

touchedbooleanfalse
—
value model File[][]
—

VigValueAccessor

directive

Bridges the vigdx form fields to Reactive Forms (formControl, formControlName) and template-driven forms (ngModel). Import it next to the component; Signal Forms ([formField]) need no accessor.

VigValueAccessor methods
Signature Description
registerOnChange(fn: (value: unknown) => void): void
—
registerOnTouched(fn: () => void): void
—
setDisabledState(disabled: boolean): void
—
writeValue(value: unknown): void
—

Are you sure?