Componente

Attachment

Um chip para um arquivo enviado ou anexado — miniatura ou ícone, nome e linha de detalhe, barra de progresso opcional e ações de remover ou personalizadas. Agrupe vários com hb-attachment-group.

Básico

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);
}

Estados e progresso

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

Tamanhos

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

Miniaturas (vertical)

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

Clicável, ação e desabilitado

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

Opened 0×

Referência de API

hb-attachment — inputs

PropriedadeDescriçãoTipoPadrão
[hbName] Nome do arquivo exibido como título. string ''
[hbDescription] Linha de detalhe secundária (tamanho, tipo, status). string ''
[hbSrc] URL da imagem de miniatura; cai no ícone em caso de erro. string ''
[hbIcon] Nome do ícone usado quando não há miniatura. string ''
[hbState] Ciclo do upload; error tinge o chip e troca o ícone. 'idle' | 'uploading' | 'processing' | 'error' | 'done' 'done'
[hbProgress] Percentual 0–100; a barra aparece só em uploading ou processing. number | null null
[hbSize] Escala geral do chip. 'xs' | 'sm' | 'md' | 'lg' | 'xl' 'md'
[hbOrientation] Layout em linha, ou card vertical com a mídia no topo. 'horizontal' | 'vertical' 'horizontal'
[hbRemovable] Mostra o botão de remover. boolean false
[hbClickable] Torna o corpo clicável e emite hbClick. boolean false
[hbDisabled] Esmaece o chip e bloqueia a interação. boolean false

hb-attachment — outputs & slots

PropriedadeDescriçãoTipoPadrão
(hbRemove) Emitido quando o botão de remover é pressionado. void
(hbClick) Emitido quando um corpo clicável é ativado. void
[hbAttachmentAction] Elemento de ação projetado, colocado antes do botão de remover. slot

hb-attachment-group

PropriedadeDescriçãoTipoPadrão
[hbOrientation] Dispõe os anexos em linha ou em coluna. 'horizontal' | 'vertical' 'horizontal'
[class] Classes CSS extras mescladas no grupo. string ''