Eidetic

AI Attachments Input

AI
Authoring
Block

File upload component for providing context and reference materials to AI conversations. Supports drag & drop, multiple files, progress tracking, and token counting.

Preview

Drag & drop file upload with attachment list

Drag & drop files or click to browse

Max 10.0 MB per file3/5 files

quarterly-report.pdf

2.3 MB15,420 tokens

data-analysis.xlsx

825.2 KB8,230 tokens
screenshot.png

screenshot.png

152.3 KB

Upload States

Files being uploaded and processed

large-dataset.csv

42.9 MB67%

analysis.py

12.1 KBProcessing...

Error State

Failed uploads with retry option

document.pdf

2.3 MB

corrupted-file.zip

14.9 MBFile could not be processed

Inline Variant

Compact list with add button

quarterly-report.pdf

2.3 MB15,420 tokens

data-analysis.xlsx

825.2 KB8,230 tokens

Compact Variant

Minimal inline file chips

quarterly-report.pdf
data-analysis.xlsx
screenshot.png

Button Variant

Simple button trigger

quarterly-report.pdf
data-analysis.xlsx

Interactive Demo

Try adding and removing files

Drop files here or click to browse (max 5MB)

Max 5.0 MB per file0/3 files

Props

AIAttachmentsInput component API reference

PropTypeDefaultDescription
attachmentsAttachment[]Current attachments
onAdd(files: File[]) => voidCallback when files are added
onRemove(attachmentId: string) => voidCallback when an attachment is removed
onPreview(attachment: Attachment) => voidCallback when an attachment is previewed
onDownload(attachment: Attachment) => voidCallback when an attachment is downloaded
onRetry(attachmentId: string) => voidCallback when retrying failed upload
acceptstringAccepted file types (MIME types or extensions)
maxFileSizenumberMaximum file size in bytes
maxFilesnumberMaximum number of attachments
multiplebooleantrueWhether multiple files can be selected
showTokenCountbooleantrueShow token counts for text files
variant'dropzone' | 'inline' | 'compact' | 'button''inline'Display variant
placeholderstring'Drag & drop files or click to browse'Placeholder text for dropzone
disabledbooleanfalseDisabled state

Attachment Type

Structure for file attachments

interface Attachment {
id: string // Unique identifier
name: string // File name
size: number // File size in bytes
mimeType: string // MIME type
type: FileType // 'image' | 'document' | 'code' | 'spreadsheet' | 'video' | 'audio' | 'archive' | 'other'
status: AttachmentStatus // 'uploading' | 'processing' | 'ready' | 'error'
progress?: number // Upload progress (0-100)
error?: string // Error message if status is error
previewUrl?: string // Preview URL for images
thumbnailUrl?: string // Thumbnail URL
tokenCount?: number // Token count for text files
}

Usage

Import and implementation example

import { AIAttachmentsInput, type Attachment } from '@/blocks/ai-conversation/ai-attachments-input'
export default function Example() {
const [attachments, setAttachments] = useState<Attachment[]>([])
const handleAdd = async (files: File[]) => {
// Create placeholder attachments with uploading status
const newAttachments: Attachment[] = files.map((file, i) => ({
id: `${Date.now()}-${i}`,
name: file.name,
size: file.size,
mimeType: file.type,
type: getFileType(file.type, file.name),
status: 'uploading',
progress: 0,
}))
setAttachments(prev => [...prev, ...newAttachments])
// Upload files and update status...
}
const handleRemove = (id: string) => {
setAttachments(prev => prev.filter(a => a.id !== id))
}
return (
<AIAttachmentsInput
variant="dropzone"
attachments={attachments}
onAdd={handleAdd}
onRemove={handleRemove}
onPreview={(a) => openPreviewModal(a)}
maxFiles={5}
maxFileSize={10 * 1024 * 1024}
accept="image/*,.pdf,.doc,.docx"
showTokenCount
/>
)
}

Built With

2 components

This block uses the following UI components from the design system:

Features

Built-in functionality

  • Four variants: Dropzone, inline, compact, and button display modes
  • Drag & drop: Native drag and drop file upload
  • Multiple files: Upload multiple files at once
  • Progress tracking: Show upload progress with visual indicators
  • File type icons: Automatic icons based on file type
  • Token counting: Display token counts for text files
  • Image thumbnails: Preview thumbnails for image files
  • Error handling: Display errors and retry failed uploads
  • File limits: Enforce max file size and count
  • Type filtering: Accept specific file types

Accessibility

Accessibility considerations

ARIA Attributes

Hidden file input is properly labeledStatus changes announced to screen readersError messages associated with file items

Keyboard Navigation

KeyAction
TabNavigate between interactive elements
Enter / SpaceTrigger file picker or remove file

Notes

  • Dropzone is keyboard accessible
  • File type conveyed through icons and text
  • Consider adding live region for upload status