Components

Attachment

A file handed over in a conversation: a slip clipped to the message, or a print taped up. Five states (idle, uploading, processing, error, done), a pencil progress bar and a remove button. The pencil traces the slip, dashes it while it is only a promise and goes red when it fails.

Install

terminal
npx shadcn@latest add @wobko/attachment

First time here? Add the registry to components.json first. How to install

Examples

The five states

Done (a clipped slip), uploading (a pencil bar), processing (the same bar, pulsing), error (red pencil and a retry) and idle (a dashed slot waiting for a file).

A live upload

Progress is a CSS variable: the hatched fill is drawn once and clipped to the value, so a fast upload never redraws anything. The finished slip gets its clip and becomes pressable.

Prints on the wall

orientation="vertical" is a photo with a white border, taped up. Put an `<img>` in the media; here a doodle stands in. A group scrolls sideways and snaps when its prints are wider than the box.

API reference

Attachment

The root and the drawing: a `Paper` slip (horizontal) or a taped photo (vertical) behind the content, with a hand-traced outline on top. A finished slip carries a paper clip, a finished print a strip of tape.

PropTypeDefaultDescription
state"idle" | "uploading" | "processing" | "error" | "done""done"Idle is a dashed empty slot with no paper, error is red pencil on a red wash, uploading and processing are the same slip with a second, looser pass and a pulsing title.
size"default" | "sm" | "xs""default"Padding and type size.
orientation"horizontal" | "vertical""horizontal"A file chip, or a print with a caption in its white border.
seedstring | number-Pins the hand.

AttachmentMedia

The tile a file's icon or thumbnail sits in: a paper-shade blob and a pencil loop, red in the error state. A bare glyph is held to 16 px (24 px in a print); a `Doodle` or `Sticker` keeps the size you give it.

PropTypeDefaultDescription
variant"icon" | "image""icon"`image` frames a picture (`<img>`) that covers the tile; it is dimmed while the file is uploading or processing.

AttachmentProgress

The pencil bar: a ruled box with a hatched fill. The fill is drawn once at full length and clipped by CSS to the value, so progress never redraws it.

PropTypeDefaultDescription
valuenumber-0 to `max`. Undefined makes an indeterminate bar (the hatching pulses).
maxnumber100The value that means done.

Accessibility

  • AttachmentProgress is a `role="progressbar"` with `aria-valuenow`/`min`/`max` (none while indeterminate). Inside an attachment it is named by the AttachmentTitle unless you give it an `aria-label` or `aria-labelledby`; on its own it needs one.
  • An AttachmentTrigger covers the attachment and is the tab stop; the Action buttons above it (z-20) stay separately focusable. Label both: the file name is not enough for 'Remove'.
  • The state is never only color: error is red pencil plus a red message plus (for you) a retry action; idle is dashed; done carries a clip.
  • Sheets, outlines, clips and tape are aria-hidden and take no pointer events. Calm density hides the clip and the tape and traces a plain hairline.
  • Error text is red on slip (4.8:1); titles are ink on slip (14:1).
  • A finished chip carries a paper clip over its end. With no action beside it the content keeps clear of the clip (extra end padding), so a long title truncates before it, not under it.

Source

The files the CLI copies into your project.

Loading the source