Command Palette

Search for a command to run...

Attachment

shadcn/ui

Displays uploaded files, media previews, and actions in horizontal or vertical layouts.

Attachment
Quarterly Report.pdf2.4 MB
design-system.figUploading · 64%
Add attachmentUp to 10 MB

import { Attachment, AttachmentAction, AttachmentActions, AttachmentContent, AttachmentDescription, AttachmentGroup, AttachmentMedia, AttachmentTitle, AttachmentTrigger } from "@/components/optics/attachment";import { Download, FileText, Loader2, Upload, X } from "lucide-react";<AttachmentGroup className="w-full max-w-2xl">  <Attachment orientation="horizontal">    <AttachmentMedia variant="icon">      <FileText />    </AttachmentMedia>    <AttachmentContent>      <AttachmentTitle>        Quarterly Report.pdf      </AttachmentTitle>      <AttachmentDescription>        2.4 MB      </AttachmentDescription>    </AttachmentContent>    <AttachmentActions>      <AttachmentAction aria-label="Download attachment">        <Download />      </AttachmentAction>      <AttachmentAction aria-label="Remove attachment">        <X />      </AttachmentAction>    </AttachmentActions>  </Attachment>  <Attachment    orientation="horizontal"    state="uploading"  >    <AttachmentMedia variant="icon">      <LoaderCircle className="animate-spin" />    </AttachmentMedia>    <AttachmentContent>      <AttachmentTitle>        design-system.fig      </AttachmentTitle>      <AttachmentDescription>        Uploading · 64%      </AttachmentDescription>    </AttachmentContent>    <AttachmentActions>      <AttachmentAction aria-label="Cancel upload">        <X />      </AttachmentAction>    </AttachmentActions>  </Attachment>  <Attachment    orientation="horizontal"    state="idle"  >    <AttachmentTrigger aria-label="Add attachment" />    <AttachmentMedia variant="icon">      <Upload />    </AttachmentMedia>    <AttachmentContent>      <AttachmentTitle>        Add attachment      </AttachmentTitle>      <AttachmentDescription>        Up to 10 MB      </AttachmentDescription>    </AttachmentContent>  </Attachment></AttachmentGroup>

Installation

pnpm dlx shadcn@latest add @optics/attachment

Props

<Attachment />
Name
Type
state
"done" | "error" | "idle" | "uploading" | "processing"(default: done)
orientation
"horizontal" | "vertical"(default: horizontal)

<AttachmentMedia />
Name
Type
variant
"image" | "icon"(default: icon)
<AttachmentAction />
Name
Type
variant
"link" | "outline" | "default"(default: ghost)
render
React.ReactElement
nativeButton
boolean
focusableWhenDisabled
boolean
animation
"none" | "all" | "colors" | "only-scale"
<AttachmentTrigger />
Name
Type
render
string(default: undefined)