Attachment

Shows a file and its upload state.

Sizes

  • refund-policy.pdf4.8 MB

    defaultdefault

  • refund-policy.pdf4.8 MB

    sm

Drop

  • Ask the refund agent

    regiondefault

  • Add to the agent's knowledge

    Images and PDFs, up to 10 MB.

    zone

States

  • refund-policy.pdf4.8 MB

    idle

  • refund-policy.pdf1.2 of 4.8 MB

    uploading

  • refund-policy.pdfReading 42 pages

    processing

  • refund-policy.pdf4.8 MB

    done

  • refund-policy.pdfOver the 20 MB limit

    error

  • Ask the refund agent

    drag accept

  • Ask the refund agent

    drag reject

Usage

When to use it
Use
Files on a prompt or a message: screenshots, policies, exports.
Use
A form or settings screen takes files: AttachmentDrop variant="zone".
Use
A composer or a panel takes files dropped on it: AttachmentDrop around it.
Not for
A person or an agent. Use Avatar.
Not for
A link to a page. Use Item.

Rules

6 rules
Never
Put a bare <input type="file"> on screen; use AttachmentDrop with an AttachmentDropTrigger. Because the native input has no drag judgement, no reasons and a look Glaze cannot reach, while the trigger opens the same picker.
Must
Show a refused or failed file as state="error" with the reason in AttachmentDescription. Because a file that silently vanishes makes the person try again, and rejectionReason already says why in words.
Must
Name every AttachmentAction with the file: "Remove refund-policy.pdf". Because a group of chips each with a "Remove" button gives a screen reader five identical names.
Must
Give AttachmentProgress a label naming the file, and write the bytes in AttachmentDescription. Because the 2px bar is the progressbar's only visible part, and "1.2 of 4.8 MB" says what is left.
Never
Put glass, a tint or a shadow on an Attachment chip. Because the chip is not pressed, and a raised chip reads as a button beside the composer's send.
Should
Say what the zone takes in AttachmentDropDescription: types and the size limit. Because the overlay can refuse a type during a drag, but only the words tell the person before they try.

Accessibility

4 checks
A busy chip is aria-busy; AttachmentProgress is a named progressbar with the percent.
The drag overlay is aria-hidden; the trigger is the way in for keyboard and screen reader users.
The file name is whole in the DOM even when cut in the middle.
The error reason is in the failure word colour, 5.9:1, and in words.

Keyboard

2 keys
Tab
Moves to each chip's actions, and to the zone's trigger.
Enter
Presses the focused action or opens the file picker.

Edge cases

6 edge cases
Wrong type dragged
The overlay turns coral and says what the region takes before the drop.
Extension-only accept
Judged on drop, since a drag shows types and not names.
Regions nested
The inner one takes the drop; the outer one shows nothing.
Same file picked twice
The picker fires again.
Thumbnail fails to load
Falls back to the image glyph.
Long file name
Cut in the middle so the extension stays.

API

9 props
Attachment state
'idle' | 'uploading' | 'processing' | 'done' | 'error' default 'done'
Attachment size
'default' | 'sm' default 'default'
AttachmentProgress value, label
number, string
AttachmentGroup layout
'wrap' | 'scroll' default 'wrap'
AttachmentDrop variant
'region' | 'zone' default 'region'
AttachmentDrop accept, maxSize, multiple
string, number, boolean default , , true
AttachmentDrop onFiles, onReject
(files) => void, (rejections) => void
AttachmentDrop paste
boolean default false
AttachmentDrop dragState
'accept' | 'reject'

Tokens

15 tokens
--paper
#ffffff
--line
rgb(5 5 5 / 0.10)
--line-control
rgb(5 5 5 / 0.15)
--fail
#e35e49
--fail-text
#b23c29
--field
#efefef
--ink
#050505
--radius-overlay
10px
--radius-tag
6px
--row
36px
--type-label
500 13px/1.35 var(--font-sans)
--type-caption
400 12px/1.35 var(--font-sans)
--text-1
rgb(5 5 5 / 0.80)
--text-2
rgb(5 5 5 / 0.60)
--dur-state
160ms

Install

For your coding agent

GitHub

Please star me pookie

141

A new design system every week

Leave your email before you copy the prompt.