Component

Attachment

A chip for an uploaded or attached file — a thumbnail or icon, a name and detail line, an optional progress bar, and remove or custom actions. Group several with hb-attachment-group.

Basic

autumn-walk.pdf 248 KB · PDF
import { ChangeDetectionStrategy, Component, signal } from '@angular/core';

import { provideIcons } from '@ng-icons/core';
import { phosphorFilePdf } from '@ng-icons/phosphor-icons/regular';

import { HbAttachmentImports, HbButtonComponent } from '@herbst/ui';

@Component({
  selector: 'hb-demo-attachment-basic',
  imports: [HbAttachmentImports, HbButtonComponent],
  providers: [provideIcons({ phosphorFilePdf })],
  template: `
    @if (!removed()) {
      <hb-attachment
        class="max-w-sm"
        hbIcon="phosphorFilePdf"
        hbName="autumn-walk.pdf"
        hbDescription="248 KB · PDF"
        hbRemovable
        (hbRemove)="removed.set(true)"
      />
    } @else {
      <button hb-button hbType="outline" hbSize="sm" (click)="removed.set(false)">Restore</button>
    }
  `,
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class HbDemoAttachmentBasicComponent {
  protected readonly removed = signal(false);
}

States & progress

oak-leaves.tiff Uploading… 40%
forest-path.png Processing… 80%
foggy-morning.raw Upload failed
chestnuts.jpg 1.2 MB · JPEG

Sizes

xs.pdf extra small
sm.pdf small
md.pdf medium
lg.pdf large
xl.pdf extra large

Thumbnails (vertical)

oak-leaves.jpg
oak-leaves.jpg image
misty-forest.png
misty-forest.png image
chestnuts.webp
chestnuts.webp image

Clickable, action & disabled

falling-leaves.jpg Click to preview
archived.zip Disabled — no interaction

Opened 0×

API reference

hb-attachment — inputs

PropertyDescriptionTypeDefault
[hbName] File name shown as the title. string ''
[hbDescription] Secondary detail line (size, type, status). string ''
[hbSrc] Thumbnail image URL; falls back to the icon on error. string ''
[hbIcon] Icon name used when there is no thumbnail. string ''
[hbState] Upload lifecycle; error tints the chip and swaps the icon. 'idle' | 'uploading' | 'processing' | 'error' | 'done' 'done'
[hbProgress] Percent 0–100; the bar shows only while uploading or processing. number | null null
[hbSize] Overall scale of the chip. 'xs' | 'sm' | 'md' | 'lg' | 'xl' 'md'
[hbOrientation] Row layout, or a vertical card with the media on top. 'horizontal' | 'vertical' 'horizontal'
[hbRemovable] Show the remove button. boolean false
[hbClickable] Make the body clickable and emit hbClick. boolean false
[hbDisabled] Dim the chip and block interaction. boolean false

hb-attachment — outputs & slots

PropertyDescriptionTypeDefault
(hbRemove) Emitted when the remove button is pressed. void
(hbClick) Emitted when a clickable body is activated. void
[hbAttachmentAction] Projected action element placed before the remove button. slot

hb-attachment-group

PropertyDescriptionTypeDefault
[hbOrientation] Lay the attachments in a row or a column. 'horizontal' | 'vertical' 'horizontal'
[class] Extra CSS classes merged onto the group. string ''