Component

File upload

A drag-and-drop uploader. Choose or drop files, preview them, enforce type, size, and count limits, and optionally upload to an endpoint — in a full dropzone or a compact button.

Advanced (dropzone)

Drop autumn photos here

Selected: —

import { ChangeDetectionStrategy, Component, signal } from '@angular/core';

import { HbFileUploadImports, type HbUploadFile } from '@herbst/ui';

@Component({
  selector: 'hb-demo-file-upload-advanced',
  imports: [HbFileUploadImports],
  template: `
    <div class="flex w-full max-w-md flex-col gap-2">
      <hb-file-upload
        hbMultiple
        hbAccept="image/*,.pdf"
        hbChooseLabel="Choose files"
        hbUploadLabel="Upload"
        hbClearLabel="Clear"
        hbDropLabel="Drop autumn photos here"
        (hbSelect)="onSelect($event)"
        (hbClear)="names.set('')"
      />

      <p class="font-mono text-[12px] text-muted-foreground">Selected: {{ names() || '—' }}</p>
    </div>
  `,
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class HbDemoFileUploadAdvancedComponent {
  protected readonly names = signal('');

  protected onSelect(files: HbUploadFile[]): void {
    this.names.set(files.map((file) => file.name).join(', '));
  }
}

Basic (compact)

Type, size & count limits

Images only · up to 1 MB · max 2 files

No errors yet.

API reference

hb-file-upload — selection

PropertyDescriptionTypeDefault
[hbMode] Full dropzone, or a compact button. 'advanced' | 'basic' 'advanced'
[hbMultiple] Allow selecting more than one file. boolean false
[hbAccept] Accepted types (an accept string, e.g. "image/*,.pdf"). string ''
[hbMaxFileSize] / [hbFileLimit] Max size per file in bytes, and max number of files (0 = no limit). number 0
[hbShowPreview] / [hbDisabled] Show file previews, and disable the control. boolean true / false
labels hbChooseLabel, hbUploadLabel, hbClearLabel, hbDropLabel. string 'Choose' / 'Upload' / 'Clear' / …

hb-file-upload — uploading

PropertyDescriptionTypeDefault
[hbAuto] Upload files immediately on selection. boolean false
[hbUrl] / [hbName] / [hbWithCredentials] Endpoint, form field name, and whether to send credentials. string / boolean '' / 'files' / false

Outputs & templates

PropertyDescriptionTypeDefault
(hbSelect) / (hbRemove) / (hbClear) Files chosen, a file removed, and the list cleared. HbUploadFile[] / HbUploadFile / void
(hbUpload) / (hbProgress) / (hbComplete) / (hbUploadError) Upload lifecycle events, including validation and network errors. event objects
hbUploadHeader / hbUploadFile / hbUploadEmpty ng-template directives to customise the header, each file row, and the empty state. template