Skip to content
kitn AI/UI

Attachments

kai-attachments

Every item keeps its own preview, size label and remove control, whatever layout you pick.

  • Shadow DOM
  • 3 variants
  • Hover-card preview
  • Optional lightbox

Set items in JavaScript (arrays can’t be HTML attributes); choose the presentation with the variant, hover-card, and removable attributes; listen for kai-remove.

variant="grid" — square image tiles for a gallery.

variant="inline" — a compact icon + label chip per file, for a composer or message body.

variant="list" — full-width rows with a preview thumbnail, filename and media type.

Add removable for a per-item remove button (the ×); it fires the kai-remove event.

Add hover-card to reveal each item’s details on hover — useful on grid, where the tile shows only the image.

For a gallery where the point is looking at the picture, image-preview="lightbox" trades the hover card for a modal: click an image tile and it opens full-size, with Escape, a backdrop click or the close control to dismiss it. It applies to image items only; every other item keeps the hover card, so one container can serve a mixed set.

The modal is the kit’s own Lightbox, which composes the kit’s Dialog: it portals through the host’s mount point, moves focus into the panel and restores it on close, traps Tab, and carries role="dialog" aria-modal. Nothing about it is a second modal implementation, so an attachment lightbox behaves like every other dialog in the kit for keyboard and screen-reader users.

Composing your own tile? The trio is public in the Solid entry:

<Lightbox>
<LightboxTrigger>
<AttachmentPreview />
</LightboxTrigger>
<LightboxContent label="Screenshot">
<img src={url} alt="" class="block" />
</LightboxContent>
</Lightbox>
PropertyTypeDefaultNotes
theme'auto'Color mode (`auto` follows prefers-color-scheme).
items[]The attachments to render (omit or pass `[]` for the empty state). Each `url` must be a `data:` URI or https URL, never `blob:`.
variant'grid'Layout: `grid` = visual tiles, `inline` = icon + label chips, `list` = rows.
hoverCardfalseWrap each item in a hover card that previews its details.
imagePreview'hover'How an image tile reveals its full size: a pointer-only card by default, or a modal on click.
removablefalseShow a remove button per item; clicking it fires a `kai-remove` event.
showMediaTypefalseAlso show the media type beneath the filename (non-grid variants).
emptyText—Text shown when `items` is empty.
EventDetailNotes
A remove button was clicked.

This element wraps these SolidJS components — reach for them directly when you need finer control than the props expose.

AttachmentsAttachmentAttachmentPreviewAttachmentInfoAttachmentRemoveAttachmentHoverCardAttachmentHoverCardTriggerAttachmentHoverCardContentAttachmentEmptyLightboxLightboxTriggerLightboxContent