Docs
Attachments

Attachments

Display the collection of attachment information.

Installation

pnpm dlx shadcn@latest add https://ui.aoian.chat/r/attachments

Usage

import {
  Attachments,
} from "@/components/aoian-ui/attachments/attachments"
  <Attachments  />

Examples

Drag anywhere on screen

Enable the full-screen drag-and-drop upload function, using the fullScreenDrop property.

Full screen drop:

File Card

A single file card, used in some display scenarios.

Created with Pixso.
excel-file.xlsx

109 KB

Created with Pixso.
word-file.docx

106 MB

Created with Pixso.
image-file.png

1 KB

Created with Pixso.
pdf-file.pdf

Upload failed

Created with Pixso.
ppt-file.pptx
Created with Pixso.
video-file.mp4
Created with Pixso.
audio-file.mp3
Created with Pixso.
zip-file.zip
Created with Pixso.
markdown-file.md
Created with Pixso.
python-file.py

Image mode

Add a Mode property to the FileCard component to control the display mode.

You need to set the url property.

File card with sender

The file cards can be used in conjunction with the sending box.

Created with Pixso.
excel-file.xlsx

109 KB

Created with Pixso.
word-file.docx

106 MB

Created with Pixso.
image-file.png

1 KB

Created with Pixso.
pdf-file.pdf

Upload failed

Created with Pixso.
ppt-file.pptx
Created with Pixso.
video-file.mp4
Created with Pixso.
audio-file.mp3
Created with Pixso.
zip-file.zip
Created with Pixso.
markdown-file.md
Created with Pixso.
python-file.py
image-file.png
image-file.png
image-file.png

UploadThing

Use it together with UploadThing.

Props

Attachments

PropTypeDefaultDescription
acceptDropzoneProps["accept"]image/*File types that can be accepted. See input accept Attribute
maxSizeDropzoneProps["maxSize"]1024 * 1024 * 2The maximum size of each file
maxFileCountDropzoneProps["maxFiles"]1Limit the number of uploaded files. Will replace current one when maxFileCount is 1
multiplebooleanfalseWhether to support selected multiple files
disabledbooleanfalseDisable upload button
fullScreenDropbooleanfalseenable full - screen drag
onFileChange(acceptedFiles: File[], rejectedFiles: FileRejection[]) => void-A callback function, can be executed when uploading state is changing.

FileListBox

PropTypeDefaultDescription
itemsFileCardItem[]-File list. Check the FileCardItem for details.
mode"image" | "file"fileWhich display mode should be adopted
onDelete(uid?: string) => void-Deletion callback function

FileCard

PropTypeDefaultDescription
itemFileCardItem-File list. Check the FileCardItem for details.
mode"image" | "file"fileWhich display mode should be adopted
onDelete(uid?: string) => void-Deletion callback function

FileCardItem

  type FileCardItem = {
    uid?: string
    name: string
    size: number
    percent: number
    url?: string
    message?: string
    contentType?: string
    status: "error" | "done" | "uploading" | "removed"
  }