Skip to main content

Attachment

A file or image attachment card with upload states, a spring collapse on removal, and a scrolling group.

motion-tokens.tsTypeScript, 4.2 KB
hero-frame.pngPNG, 128 KB

Customize

SizeDefault
Stagger (ms)36
Reveal blur (px)3
Speed1

Installation

npx shadcn@latest add @kinetic/attachment

Usage

Compose AttachmentMedia, AttachmentContent and AttachmentActions inside Attachment.

import { DocumentTextIcon, XMarkIcon } from "@heroicons/react/24/outline";
import {
  Attachment,
  AttachmentAction,
  AttachmentActions,
  AttachmentContent,
  AttachmentDescription,
  AttachmentMedia,
  AttachmentTitle,
} from "@/components/kinetic/ui/attachment";

export function FileChip() {
  return (
    <Attachment>
      <AttachmentMedia>
        <DocumentTextIcon />
      </AttachmentMedia>
      <AttachmentContent>
        <AttachmentTitle>report.pdf</AttachmentTitle>
        <AttachmentDescription>PDF, 240 KB</AttachmentDescription>
      </AttachmentContent>
      <AttachmentActions>
        <AttachmentAction aria-label="Remove file">
          <XMarkIcon />
        </AttachmentAction>
      </AttachmentActions>
    </Attachment>
  );
}

States

state picks the indicator in the media slot: idle, uploading, processing, error or done. Set showStatus={false} to hide it.

<Attachment state="uploading">...</Attachment>

Removal

Set open={false} to collapse the card with a spring. onDismissComplete fires when it is gone, so you can drop it from your list.

<Attachment open={open} onDismissComplete={() => removeFile(file.id)}>
  ...
</Attachment>

Size and layout

size is default, sm or xs; orientation="vertical" stacks a thumbnail above the text. AttachmentMedia variant="image" shows a cover image.

<Attachment orientation="vertical">
  <AttachmentMedia variant="image">
    <img src="/uploads/hero.png" alt="" />
  </AttachmentMedia>
  ...
</Attachment>

Group

AttachmentGroup lays cards out in a horizontal scroll strip with a staggered entrance. Use AttachmentTrigger with asChild to make a whole card open a link.

<AttachmentGroup>
  <Attachment>...</Attachment>
  <Attachment>...</Attachment>
</AttachmentGroup>

Motion preferences

animated, speed, staggerMs and blurPx tune the lifecycle and group animations. Reduced motion shows and removes cards without animation.

API Reference

Attachment

Attachment card with media status indicators and spring dismissal.

PropTypeDefaultDescription
state"idle" | "uploading" | "processing" | "error" | "done""done"Selects the upload, processing, success, or error indicator in the media slot.
size / orientation"default" | "sm" | "xs" / "horizontal" | "vertical""default" / "horizontal"Controls card padding density and inline row vs. vertical thumbnail layout.
open / onDismissCompleteboolean / () => voidtrueDrives Euler spring collapse when set to false and notifies after unmount cleanup.
animated / showStatus / speedboolean / boolean / numbertrue / true / 1Toggles lifecycle animations, status icon slot, and animation speed multiplier (clamped 0.25-4).

AttachmentGroup

Horizontal scroll strip playing a capped staggered reveal across Attachment items.

PropTypeDefaultDescription
animated / staggerMs / blurPx / speedboolean / number / number / numbertrue / 36 / 3 / 1Configures group entrance stagger (0-120ms, max 180ms), initial blur, and speed multiplier.

AttachmentMedia / AttachmentAction / AttachmentTrigger / AttachmentContent / AttachmentTitle / AttachmentDescription / AttachmentActions

Media frame, Kinetic Button-backed action control, asChild trigger overlay, and text slots.

PropTypeDefaultDescription
variant (AttachmentMedia)"icon" | "image""icon"Renders a padded icon frame or full-bleed cover image thumbnail.
size (AttachmentAction)KineticButtonSize | "icon-xs""icon-sm"Button size passed to Kinetic Button (maps icon-xs cleanly to icon-sm).
asChild (AttachmentTrigger)booleanfalseMerges full-card trigger behavior onto a single child link or element.

Notes

Always use Attachment (not Item) for file or image attachments in chat UIs, wrap multiple items in AttachmentGroup, and pass aria-label on icon-only AttachmentAction buttons.