Skip to content
Ballpoint

Attachment

A file or picture attached to something: its media, name, what is known of it, how its upload is going and what can be done to it.

From shadcn/ui
sales-dashboard.pdf
PDF · 2.4 MB

Installation

pnpm dlx shadcn@latest add @ballpoint/attachment

Usage

tsx
import { Attachment, AttachmentContent, AttachmentDescription, AttachmentMedia, AttachmentTitle } from "@/components/ui/attachment"

<Attachment>
  <AttachmentMedia><FileTextIcon /></AttachmentMedia>
  <AttachmentContent>
    <AttachmentTitle>sales-dashboard.pdf</AttachmentTitle>
    <AttachmentDescription>PDF · 2.4 MB</AttachmentDescription>
  </AttachmentContent>
</Attachment>

Examples

States

Uploading and processing pulse the name; an error is in red pen, with the reason in words.

field-sketches.zip
Uploading · 42%
letter-to-ada.docx
Processing…
scan-001.png
Couldn't upload: the file is over 10 MB
notes.md
Markdown · 4 KB

Sizes

Default, small and extra small.

report-default.pdf
PDF · 1.1 MB
report-sm.pdf
PDF · 1.1 MB
report-xs.pdf

Group

A row that scrolls sideways and snaps, with pictures and files together.

portrait.svg
Image · 12 KB
notes.md
File
budget.xlsx
File
scan.pdf
File

With a trigger

Make the whole card open a dialog or a link; the buttons stay above it.

research-summary.pdf
PDF · 860 KB · Open to preview

API reference

state
default "done"
"idle" | "uploading" | "processing" | "error" | "done"

Uploading and processing pulse the title; error is red pen.

size
default "default"
"default" | "sm" | "xs"

Padding and type size.

orientation
default "horizontal"
"horizontal" | "vertical"

Media beside the text, or above it.

AttachmentMedia variant
default "icon"
"icon" | "image"

An icon circled with the pen, or a picture.

AttachmentAction
Button props

A small button; give an icon-only one an aria-label.

AttachmentTrigger render
ReactElement

A full-card overlay: render it as a link, or as a dialog's trigger. Give it an aria-label.

seed
string | number

Pins the drawing.

Pen settings

The drawing also takes draw, roughness, passes, radius, corners, weight and speed, as props or from the nearest InkProvider. What each one does.