File upload
File[] ; uploading the files is up to your code.
vig-file-upload
import { FileUpload } from '@vigdx/ui/file-upload';Basic
[(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.
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.
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 .
- contract-signed.pdf 242.2 kB
- appendix-a.pdf 1.8 MB
Uploads are closed.
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.
- kimlik.pdf 93.8 kB
Reactive Forms
VigValueAccessor next to the component to use formControlName , [formControl] or ngModel . Type the control as File[] ; Validators.required treats [] as missing.
Signal Forms
vig-file-upload implements FormValueControl<File[]> . Signal Forms' required() treats [] as filled, so check the length with validate() for a mandatory upload.
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"]
| Part | Element | data-state |
|---|---|---|
label | — | |
dropzone | — | |
icon | — | |
prompt | — | |
input | — | |
files | — | |
file | — | |
file-name | — | |
file-size | — | |
remove | — | |
hint | vig-hint (a display: contents host; style its text part). | — |
disabled-reason | vig-hint with the disabled reason ( display: contents ). | — |
error | 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 aftermultiple), so keyboard users open the file dialog with Enter or Space; dragging is never required. A button cannot carryaria-required, sorequiredadds 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 setaria-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-uploadFile 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 [].
| Name | Type | Default | Description |
|---|---|---|---|
accept | string | '' | Same syntax as the native attribute: |
dirty | boolean | false | — |
disabled | boolean | false | — |
disabledReasons | readonly WithOptionalFieldTree<DisabledReason>[] | [] | — |
dropLabel | string | undefined | undefined | Drop-zone prompt; defaults to a singular or plural label after |
errorMessages | Record<string, string> | — | — |
errors | readonly ValidationError.WithOptionalFieldTree[] | [] | — |
hidden | boolean | false | — |
hint | string | undefined | undefined | — |
invalid | boolean | false | — |
label | string | — | — |
maxFiles | number | undefined | undefined | Most files the field holds in total. |
maxFileSize | number | undefined | undefined | Largest accepted file, in bytes. |
multiple | boolean | false | — |
name | string | '' | — |
pending | boolean | false | — |
readonly | boolean | false | — |
removeAriaLabel | string | undefined | undefined | — |
required | boolean | false | — |
requiredLabel | string | undefined | undefined | Screen-reader text conveying |
touched | boolean | false | — |
value | File[] | [] | — |
| Name | Payload | Description |
|---|---|---|
rejected | FileRejection[] | Files left out by the |
touch | void | — |
valueChange | File[] | — |
| Signature | Description |
|---|---|
addFiles(files: Iterable<File>): FileRejection[] | Adds files after checking them; returns the rejected ones. |
browse(): void | Opens the native file dialog. |
focus(options?: FocusOptions): void | Moves focus to the control's interactive element (the input, or the
trigger of a popup control). Signal Forms calls it through
|
remove(index: number): void | Removes the file at |
reset(): void | Returns the control to its pristine look: drops in-progress text, closes
an open popup, clears errors the component raised itself and the
submitted state of |
VigValueAccessor
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.
| Signature | Description |
|---|---|
registerOnChange(fn: (value: unknown) => void): void | — |
registerOnTouched(fn: () => void): void | — |
setDisabledState(disabled: boolean): void | — |
writeValue(value: unknown): void | — |