Components
- Accordion
- Alert
- Alert Dialog
- Aspect Ratio
- Attachment
- Autocomplete
- Avatar
- Badge
- Breadcrumb
- Bubble
- Button
- Calendar
- Card
- Carousel
- Chart
- Checkbox
- Checkbox Group
- Collapsible
- Combobox
- Command
- Context Menu
- Date Picker
- Dialog
- Drawer
- Dropdown Menu
- Empty
- Field
- Fieldset
- Form
- Frame
- Group
- Input
- Input Group
- Kbd
- Label
- Menu
- Menubar
- Message
- Meter
- Number Field
- OTP Field
- Pagination
- Popover
- Preview Card
- Progress
- Questionnaire
- Radio Group
- Scroll Area
- Select
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Spinner
- Switch
- Table
- Tabs
- Textarea
- Toggle
- Toggle Group
- Toolbar
- Tooltip
Shared
- Artifact
- Audio Player
- Canvas
- Chain of Thought
- Checkpoint
- Code Block
- Commit
- Connection
- Context
- Controls
- Edge
- Environment Variables
- Mic Selector
- Model Selector
- Node
- Node Toolbar
- Open in Chat
- Panel
- Plan
- Prompt Input
- Queue
- Reasoning
- Sandbox
- Schema Display
- Shimmer
- Snippet
- Sources
- Speech Input
- Stack Trace
- Suggestion
- Tool
- Transcription
- Web Preview
Hooks
Resources
Attachment
Displays an uploaded file with its upload state.
release-notes.pdf248 KB
import { FileTextIcon } from "lucide-react";
import {
Attachment,
AttachmentContent,
AttachmentDescription,
AttachmentMedia,
AttachmentTitle,
} from "@/components/ui/attachment";
export default function Particle() {
return (
<Attachment>
<AttachmentMedia>
<FileTextIcon aria-hidden="true" />
</AttachmentMedia>
<AttachmentContent>
<AttachmentTitle>release-notes.pdf</AttachmentTitle>
<AttachmentDescription>248 KB</AttachmentDescription>
</AttachmentContent>
</Attachment>
);
}
Installation
pnpm dlx shadcn@latest add @frontal-labs/attachment
Usage
import {
Attachment,
AttachmentContent,
AttachmentDescription,
AttachmentMedia,
AttachmentTitle,
} from "@/components/ui/attachment";<Attachment>
<AttachmentMedia>
<FileTextIcon />
</AttachmentMedia>
<AttachmentContent>
<AttachmentTitle>release-notes.pdf</AttachmentTitle>
<AttachmentDescription>248 KB</AttachmentDescription>
</AttachmentContent>
</Attachment>API Reference
Attachment
Root container.
| Prop | Type | Default |
|---|---|---|
state | "idle" | "uploading" | "processing" | "error" | "done" | "done" |
size | "default" | "sm" | "xs" | "default" |
orientation | "horizontal" | "vertical" | "horizontal" |
AttachmentMedia
Thumbnail slot. Accepts variant of "icon" (default) or "image".
AttachmentContent
Wraps the title and description.
AttachmentTitle
The file name.
AttachmentDescription
Secondary text such as the file size or status.
AttachmentActions
Container for trailing actions.
AttachmentAction
An icon button rendered inside AttachmentActions. Accepts every Button prop.
AttachmentTrigger
Renders the attachment as an interactive element, for example to open a preview.
AttachmentGroup
Lays out several attachments together.
Examples
Upload States
release-notes.pdfidle
release-notes.pdfuploading
release-notes.pdfprocessing
release-notes.pdferror
release-notes.pdfdone
import { FileTextIcon } from "lucide-react";
import {
Attachment,
AttachmentContent,
AttachmentDescription,
AttachmentGroup,
AttachmentMedia,
AttachmentTitle,
} from "@/components/ui/attachment";
const states = ["idle", "uploading", "processing", "error", "done"] as const;
export default function Particle() {
return (
<AttachmentGroup className="flex flex-wrap gap-2">
{states.map((state) => (
<Attachment key={state} state={state}>
<AttachmentMedia>
<FileTextIcon aria-hidden="true" />
</AttachmentMedia>
<AttachmentContent>
<AttachmentTitle>release-notes.pdf</AttachmentTitle>
<AttachmentDescription>{state}</AttachmentDescription>
</AttachmentContent>
</Attachment>
))}
</AttachmentGroup>
);
}
Vertical
diagram.png1.2 MB
import { ImageIcon } from "lucide-react";
import {
Attachment,
AttachmentContent,
AttachmentDescription,
AttachmentMedia,
AttachmentTitle,
} from "@/components/ui/attachment";
export default function Particle() {
return (
<Attachment orientation="vertical">
<AttachmentMedia>
<ImageIcon aria-hidden="true" />
</AttachmentMedia>
<AttachmentContent>
<AttachmentTitle>diagram.png</AttachmentTitle>
<AttachmentDescription>1.2 MB</AttachmentDescription>
</AttachmentContent>
</Attachment>
);
}
With an Action
proposal.docx84 KB
import { FileTextIcon, XIcon } from "lucide-react";
import {
Attachment,
AttachmentAction,
AttachmentActions,
AttachmentContent,
AttachmentDescription,
AttachmentMedia,
AttachmentTitle,
} from "@/components/ui/attachment";
export default function Particle() {
return (
<Attachment>
<AttachmentMedia>
<FileTextIcon aria-hidden="true" />
</AttachmentMedia>
<AttachmentContent>
<AttachmentTitle>proposal.docx</AttachmentTitle>
<AttachmentDescription>84 KB</AttachmentDescription>
</AttachmentContent>
<AttachmentActions>
<AttachmentAction aria-label="Remove attachment">
<XIcon aria-hidden="true" />
</AttachmentAction>
</AttachmentActions>
</Attachment>
);
}