Skip to content
Eskais UI

Data

Attachments

AttachmentStrip: a horizontally scrolling strip of image thumbnails and file chips (icon, name, type and size). Images open a Lightbox, files open their link, max adds a +N button. AttachmentThumb renders one. Agents get openAttachment(id).

Example

Open an image or a file.

Installation

npx shadcn@latest add @eskais/attachments
npm packageslucide-react

Usage

Import
import { attachments } from "@/components/ui/attachments-primitive"import { AttachmentThumb, formatFileSize } from "@/components/ui/attachment-thumb"import { AttachmentStrip, attachmentLabels, AttachmentThumb, formatFileSize } from "@/components/ui/attachments"

API reference

AttachmentThumb

PropTypeDefault
attachmentrequiredAttachment–
size"sm" | "md""md"
onOpenRuns on a press; `event.preventDefault()` stops a file's link from opening. Without it, an image is static.(attachment: Attachment, event: MouseEvent<HTMLElement>) => void–
openLabelThe accessible name of an image's button.(name: string) => stringdefaultOpenLabel
localestring–
classNamestring–

AttachmentStrip

PropTypeDefault
attachmentsrequiredreadonly Attachment[]–
onOpenRuns before an attachment opens, for a person or an agent; `details.cancel()` keeps it closed.(attachment: Attachment, details: ChangeDetails<AttachmentOpenReason>) => void–
maxShows this many, then a "+N" button for the rest.number–
sizeAttachmentSize"md"
labelsPartial<AttachmentLabels>–
localestring–
aria-labelrequiredstring–

Also takes <div> attributes and render except children, onSelect.

Other exports

attachmentsformatFileSizeattachmentLabelstype Attachmenttype AttachmentOpenReasontype AttachmentsOptionstype AttachmentSizetype AttachmentThumbPropstype AttachmentLabelstype AttachmentStripProps

Accessibility

  • The strip needs an aria-label; images open the lightbox and focus returns to the thumbnail.

Agent actions

Agents call openAttachment; onOpen runs first and can cancel.

Runs agent.snapshot() from @ui-sdk/react/agent on the live preview above.