ngx-prompt-kit

Attachment Preview

ngx-prompt-kit original — not part of ibelick/prompt-kit

Horizontal chip row for staged attachments above a prompt input. Image type renders an inline thumbnail; file/audio/video render an icon + filename + size. Hover or focus a chip to reveal its remove button.

Examples

Mixed types

Image with thumbnail, plus a PDF and an audio attachment. Filename truncates inside the chip; full size is rendered via Intl.NumberFormat.

Image-heavy

Four images in a row. Each thumbnail is the actual click target — wire (clicked) to your lightbox or preview pane.

Overflow with maxVisible

When [maxVisible] > 0 and the attachments array is longer, surplus chips collapse into a square '+N' pill that matches the chip height. The pill is non-interactive — consumers wire whatever (e.g., open a gallery) at the host level.

+5

Installation

Add the attachment-preview component (and the cn() utility) to your project.

ng generate ngx-prompt-kit:attachment-preview

Component API

PkAttachmentPreview

PropTypeDefaultDescription
attachmentsreadonly Attachment[]The attachments to render (required).
maxVisiblenumber 0 When > 0, only the first N chips render and the surplus collapses into a "+N more" pill. 0 shows all.
removableboolean true When false, chips do not show the remove (X) button.
localestring | undefinedBCP-47 locale for the byte size formatter. Defaults to runtime locale.
classstringExtra classes for the host.

PkAttachmentChip

PropTypeDefaultDescription
attachmentAttachmentSingle attachment to render (required).
removableboolean true Show the remove button.
localestring | undefinedForwarded to the byte size formatter.

Outputs

PropTypeDefaultDescription
clicked(id: string) => voidChip body clicked — wire to your preview/lightbox handler.
removed(id: string) => voidRemove (X) button clicked.