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. Each chip is a spartan hlm-attachment: image type renders an inline thumbnail; file/audio/video render an icon + filename + size. Click a chip to preview it; its remove action sits in the chip.

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.

storyboard-frame-04.png
q4-financials-final.pdf2.3 MB
voice-memo-2026-05-04.m4a4.7 MB

Image-heavy

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

cover.png
banner.png
icon.png
thumb.png

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.

screenshot-1.png
screenshot-2.png
transcript.txt12 KB
+5

Installation

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

ng generate ngx-prompt-kit:attachment-preview

It is built on spartan/ui, so add these helm components too: attachment.

ng g @spartan-ng/cli:ui attachment

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 | undefined — BCP-47 locale for the byte size formatter. Defaults to runtime locale.
classstring — Extra classes for the host.

PkAttachmentChip

PropTypeDefaultDescription
attachmentAttachment — Single attachment to render (required).
removableboolean true Show the remove button.
localestring | undefined — Forwarded to the byte size formatter.

Outputs

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