Skip to main content
Neural UIv2.0.0Documentation
View v1 GitHub

Uploader

Select and validate local files with previews and application-driven upload state.

Category
Forms and selection
Import
@neural-ui/core/uploader
Selector
neu-uploader
import { NeuUploaderComponent } from '@neural-ui/core/uploader';

Usage

value contains File objects; selection and dropping do not upload them. accept, maxFiles and maxFileSize validate selection. Handle filesRejected to explain errors. Your application owns the HTTP request and supplies progress or fileStates; fileRetry is a request to retry, not an automatic network operation. previewTemplate receives NeuUploaderFileItem, including file, status and progress. The sample file is generated only after a user action, not during SSR.

Examples

Try this application-owned interaction. Its event handling and initial data are included in Code.

Examples

Choose files

Drop files here or choose them ยท Allowed types: .txt,.pdf ยท Maximum size: 1.0 MB

0 selected files

Events: 0

Try and configure

Change the public options, try the result and inspect the updated template. Code contains the complete executable implementation.

Try and configure

Choose files

Drop files here or choose them ยท Allowed types: .txt,.pdf ยท Maximum size: 1.0 MB

Use Fail beside a file to simulate a failed upload, then Retry. No files are uploaded.

0 selected files

Events: 0

template.html
<neu-uploader
  [value]="value()"
  (valueChange)="onValueChange($event)"
  [disabled]="false"
  [readonly]="false"
  [invalid]="false"
  [multiple]="true"
  [dropzone]="true"
  [showProgress]="true"
  [size]="'md'"
  [maxFiles]="3"
  [maxFileSize]="1048576"
  [accept]="'.txt,.pdf'"
  [progress]="progress()"
  [fileStates]="fileStates()"
  [previewTemplate]="failurePreview"
  [chooseLabel]="'Choose files'"
  [clearLabel]="'Clear'"
  [listAriaLabel]="'Selected files'"
  [removeAriaLabel]="'Remove file'"
  [retryLabel]="'Retry'"
  [retryAriaLabel]="'Retry upload for'"
  [acceptedTypesLabel]="'Allowed types'"
  [fileCountSingularLabel]="'file'"
  [fileCountPluralLabel]="'files'"
  (filesRejected)="record('filesRejected', $event)"
  (filesSelected)="record('filesSelected', $event.map(fileName))"
  (fileRetry)="retry($event)"
  [dropzoneLabel]="'Drop files to add them'"
  [duplicateFileMessage]="'File already selected.'"
  [emptySelectionMessage]="'No files selected.'"
  [invalidTypeMessage]="'File type is not allowed.'"
  [label]="'Attachments'"
  [maxFileSizeMessage]="'File exceeds the maximum size.'"
  [maxFileSizeTextLabel]="'Maximum size'"
  [maxFilesMessage]="'Too many files selected.'"
  [placeholder]="'Drop files here or choose them'"
  [progressLabel]="'Upload progress'"
/>
<div class="remaining-actions">
  <button
    neu-button
    variant="outline"
    [disabled]="disabled() || readonly()"
    (neuClick)="sample()"
  >
    {{ t("Add sample file", "Aรฑadir archivo de ejemplo") }}</button
  ><button neu-button variant="ghost" [disabled]="disabled() || readonly() || !value().length" (neuClick)="simulate()">
    {{ t("Toggle sample progress", "Alternar progreso de ejemplo") }}
  </button>
</div>
<ng-template #failurePreview let-item>
  <button neu-button variant="outline" tone="danger" size="sm"
    [ariaLabel]="t('Simulate upload failure for', 'Simular fallo de subida de') + ' ' + item.name"
    [disabled]="disabled() || readonly() || item.status === 'error'"
    (neuClick)="simulateFailure(item)"
  >{{ t('Fail', 'Fallar') }}</button>
</ng-template>

State and events

value contains File objects; selection and dropping do not upload them. accept, maxFiles and maxFileSize validate selection. Handle filesRejected to explain errors. Your application owns the HTTP request and supplies progress or fileStates; fileRetry is a request to retry, not an automatic network operation. previewTemplate receives NeuUploaderFileItem, including file, status and progress. The sample file is generated only after a user action, not during SSR.

Accessibility and keyboard

Tab reaches the file chooser and remove/retry controls. Enter opens the native picker; file selection is available without dragging.

Key
Action
Tab Reach the file chooser and available remove/retry buttons.
Enter On the chooser, open the native file picker; on a file action, execute remove or retry.
Space On the chooser, open the native file picker; on a file action, execute remove or retry.

API

Inputs, models and Outputs are extracted from the installed Core package. Named public types link to their definitions. Templates below include executable examples.

Inputs

Configure the component with [property]="value". Your application supplies these values; the component does not replace the state you pass in.

Name
Type
Default
Template binding
Description
acceptstring''[accept]Allowed MIME types or filename extensions, following the native file-picker syntax.
acceptedTypesLabelstring'Allowed types'[acceptedTypesLabel]Visible caption for the allowed-file-types hint.
chooseLabelstring'Choose files'[chooseLabel]Visible label of the native file-picker trigger.
clearLabelstring'Clear'[clearLabel]Label for the clear-selection action.
dirtybooleanfalse[dirty]Form state indicating that the user has changed the value.
disabledbooleanfalse[disabled]Prevents interaction with this control.
dropzonebooleantrue[dropzone]Enable the file drop area. Native file selection remains available.
dropzoneLabelstring'Drop files here to add them'[dropzoneLabel]Accessible name of the file drop region.
duplicateFileMessagestring'File {{fileName}} has already been selected.'[duplicateFileMessage]Localized rejection message; documented {{fileName}} / {{maxFiles}} placeholders may be retained.
emptySelectionMessagestring'No file was selected.'[emptySelectionMessage]Message for an empty file selection.
errorMessagestring''[errorMessage]Visible error message associated with the field.
errorsreadonly ValidationError.WithOptionalFieldTree[][][errors]Validation errors supplied by the form or the application.
fileCountPluralLabelstring'files'[fileCountPluralLabel]Localized singular or plural word for the selected file count.
fileCountSingularLabelstring'file'[fileCountSingularLabel]Localized singular or plural word for the selected file count.
fileStatesRecord<string, { status?: NeuUploaderFileStatus; progress?: number | null; error?: string; }>{}[fileStates]Per-file status/progress/error supplied by your application using uploader item ids.
hiddenbooleanfalse[hidden]Hides the control according to the form state.
hintstring''[hint]Application-supplied descriptive help text.
inputIdstringinject(NeuIdGenerator).getId('neu-uploader-')Derived default[inputId]Stable control id, generated when omitted; use it to associate labels or descriptions.
invalidbooleanfalse[invalid]Displays the invalid state; it does not add a validation rule.
invalidTypeMessagestring'File {{fileName}} does not match the allowed file types.'[invalidTypeMessage]Localized rejection message; documented {{fileName}} / {{maxFiles}} placeholders may be retained.
labelstring''[label]Visible label naming the field or action.
listAriaLabelstring'Selected files'[listAriaLabel]Accessible name of the selected-files list.
maxFilesnumber | nullnull[maxFiles]Maximum number of accepted files; null removes the count limit.
maxFileSizenumber | nullnull[maxFileSize]Maximum accepted size in bytes per file; null removes the size limit.
maxFileSizeMessagestring'File {{fileName}} exceeds the allowed maximum size.'[maxFileSizeMessage]Localized rejection message; documented {{fileName}} / {{maxFiles}} placeholders may be retained.
maxFileSizeTextLabelstring'Max size'[maxFileSizeTextLabel]Visible caption for the maximum file-size hint.
maxFilesMessagestring'You can only select up to {{maxFiles}} files.'[maxFilesMessage]Localized rejection message; documented {{fileName}} / {{maxFiles}} placeholders may be retained.
multiplebooleantrue[multiple]Allows selecting more than one file.
pendingbooleanfalse[pending]Form state indicating that asynchronous validation is pending.
pickerDescriptionstring'Use the button below to choose files from your device.'[pickerDescription]Supplementary text explaining native file selection.
placeholderstring'Drag files here or select them from your device.'[placeholder]Text shown when the field has no selected value.
previewTemplateTemplateRef<{ $implicit: NeuUploaderFileItem; item: NeuUploaderFileItem; }> | nullnull[previewTemplate]TemplateRef receiving $implicit/item: NeuUploaderFileItem for each selected-file preview.
progressnumber | nullnull[progress]Application-supplied overall upload percentage; null represents no applied progress.
progressLabelstring'Upload in progress'[progressLabel]Accessible label for upload progress.
readonlybooleanfalse[readonly]Keeps the applied value visible but prevents user edits.
removeAriaLabelstring'Remove file'[removeAriaLabel]Accessible name for the remove button.
requiredbooleanfalse[required]Marks the field as required; use a form validator to enforce it.
retryAriaLabelstring'Retry upload for'[retryAriaLabel]Visible or accessible label for retrying a failed load/upload.
retryLabelstring'Retry'[retryLabel]Visible or accessible label for retrying a failed load/upload.
showPickerTextbooleanfalse[showPickerText]Show the supplementary native-picker explanation.
showProgressbooleantrue[showProgress]Show application-supplied upload progress. It does not start a network request.
sizeNeuUploaderSize'md'[size]Control size. The accepted scale or numeric unit is specified by its type.
touchedbooleanfalse[touched]Form state indicating that the control has been visited.

Models

A model supports [(property)]="signal" or the [property] and (propertyChange) pair. Choose one form, not both.

Name
Type
Default
Template binding
Description
valuereadonly File[][][(value)]Accepted local File objects; selection does not upload them.

Outputs

Listen to an event with (event)="handler($event)". The table explains the data your handler receives and how to use it.

Name
Payload
Template binding
Description
clearedvoid(cleared)="onCleared($event)"Emitted for the explicit clear action; valueChange carries the resulting value.
fileRemovedFile(fileRemoved)="onFileRemoved($event)"Reports the File removed from selection.
fileRetryNeuUploaderFileItem(fileRetry)="onFileRetry($event)"Requests retrying a selected file. Your application owns the upload operation.
filesRejectedNeuUploaderError[](filesRejected)="onFilesRejected($event)"Reports rejection codes, messages and associated files when available.
filesSelectedreadonly File[](filesSelected)="onFilesSelected($event)"Reports the accepted File objects from the latest selection.
touchvoid(touch)="onTouch($event)"Notifies the form that the control has been touched; not a value change.

Templates

ng-content projects content into the component. TemplateRef inputs receive a template; ng-template directives identify templates with a typed context. A directive shared by an entrypoint is not necessarily a slot of this component.

Name
Mechanism
Contract
previewTemplateView example TemplateRef inputTemplateRef<{ $implicit: NeuUploaderFileItem; item: NeuUploaderFileItem; }> | null

Each example demonstrates a different template. Switch between Demo and Code to inspect its implementation, imports and state.

previewTemplate

previewTemplate

previewTemplate

Choose files

Drop files here or choose them ยท Allowed types: .txt,.pdf ยท Maximum size: 1.0 MB

0 selected files

Events: 0

Public Types

Open a type to inspect its definition and interface fields.

Styles and tokens

Use the supported public tokens listed below. Surrounding layout belongs to your application; validate the result in light and dark modes and narrow containers.

Specific tokens

This component uses shared theme tokens rather than dedicated component hooks.

Shared tokens used

Override these on a local wrapper to affect this example. An override on :root affects other components that use the same token.

Token
Purpose here
Other impact
Default / fallback
--neu-border Normal control and cell borders Shared by other Core consumers; scope the override. rgba(15, 23, 42, 0.08)
--neu-border-hover Control borders on hover Shared by other Core consumers; scope the override. rgba(15, 23, 42, 0.16)
--neu-error Invalid field or danger-action color Shared by other Core consumers; scope the override. #dc2626
--neu-error-bg Background of invalid or danger states Shared by other Core consumers; scope the override. #fee2e2
--neu-error-text Error text and danger outline/ghost Button text in both themes Shared by other Core consumers; scope the override. #991b1b
--neu-focus-ring Normal keyboard-focus ring Shared by other Core consumers; scope the override. 0 0 0 var(--neu-focus-ring-width) rgba(0, 122, 255, 0.15)
--neu-focus-ring-strong Emphasized focus treatment Shared by other Core consumers; scope the override. 0 0 0 var(--neu-focus-ring-width) rgba(0, 122, 255, 0.35)
--neu-primary Brand color for active controls and emphasis Shared by other Core consumers; scope the override. #007aff