About this set
Attachment controls for places where uploading is secondary to writing. Email composer attachments is a message draft with To and Subject fields, a body and a toolbar: the paperclip opens the file picker, attached files sit above the toolbar as chips with a document icon, name, size and remove button, and a running total reads 2 files, 2.2 MB of 25 MB so people see how close they are to the limit before sending. Chat message bar with previews is a rounded input bar with a plus button, a message field and a round send button; images appear above it as 64 pixel thumbnails and PDFs as labelled tiles, each with its own remove button, up to four per message. In both, files can also be dropped anywhere on the composer, which shows a Drop files to attach overlay while a file is dragged over it. A single script handles both: it checks type, size per file, the number of files and the total size, explains any rejection by name, previews images with object URLs and keeps input.files in step with the chips. Use the email pattern for forms and support tickets and the chat bar for messaging.
What’s included
- Paperclip or plus button backed by a real file input
- Drop anywhere on the composer with a visible overlay
- Chips with name, size and remove button
- Running total against a size limit
- Image thumbnails and file tiles in the chat bar
Accessibility
The icon-only attach buttons are labels with visually hidden text, so the input is named Attach files or Add photos or PDFs, and the send buttons are named too. Chips have remove buttons named after their file, focus moves to the next chip after a removal, and attached, removed and rejected files are announced in a polite live region. Every field and button has a visible focus style, and transitions switch off under prefers-reduced-motion.
Customise it
Change --att-accent, --att-line and --att-danger on .att, and set data-max-total, data-max-size, data-max-files and accept on the input. Bootstrap uses a .card, borderless .form-control fields and .btn-close; Tailwind reads the att colours from @theme.





