Skip to content

No.50 · Buttons· New

Upload Button

Click or drop a file and the control becomes its own progress: the file's name, a live percentage and a cancel cross, then a green tick, or a plain reason it failed with Retry. As a compact button, a wide drop target, or a round photo picker.

The prompt

Copy this text

Automatic copying is unavailable. Copy the selected text using your device’s copy command.

Written for the variant you picked above: Button

Build a file upload control, in the one form selected below, that turns itself into the upload's progress. Inter at 500, 15px. Palette (light / dark): ink #111111 / #ededed, muted #6b6b6b / #a0a0a0, card #ffffff / #141414, hairline #e2e2e2 / #2b2b2b, dashes #c9c9c9 / #3d3d3d, solid button #111111 with white text / #ededed with #0a0a0a text, accent #2563eb / #6ea8fe with a wash of #eff4ff / #101b2e, track #ececec / #262626, done #15803d / #3fb950, error #c81e1e / #ff6369. Behaviour: a hidden <input type=file> opened by a real button; dropping a file anywhere on the control works too (the drag state is shown). Check the file against accept and a size limit first and say why in plain words if it's refused ('That file is 31 MB; the limit is 20 MB.'). Uploading takes an upload(file, progress, signal) function; the default simulates a believable transfer (uneven but always forward, 1.1–4.2s by size) and fails when the browser is offline. Cancel aborts it. A failure shows the reason and 'Retry', which sends the same file again. Long names are shortened in the middle, keeping the extension. Progress is announced in quarters in a polite live region, with the start, the end, cancelling and errors. Show it on a #f6f6f5 panel and a #0a0a0a panel side by side. Selected variant — Button (button): Button: a 44px solid button with 12px corners, an up-arrow-into-tray icon (it lifts 2px on hover) and 'Upload file'. Once a file is chosen it becomes a 20rem card-coloured bar with a hairline: a document icon, the name (ellipsis), the percentage in tabular figures and a 28px round cross; a pale accent wash fills it from the left as the progress. Done: a green tick, the name and a 'Replace' text button. This selection takes precedence over references to other themes or options in the general brief. Implement this selected appearance; do not add a variant picker or alternative appearances unless requested. Implementation requirements: Use React and TypeScript. Keep the component self-contained, with uniquely scoped CSS and no animation libraries. Include required imports, styles and font setup in the result. Interaction: Click (or Enter/Space) to choose a file, or drop one on it. While uploading, the cross cancels. When done, the follow-up action picks again or resets; when it fails, Retry resends. Motion: Progress follows the transfer frame by frame; the bar widens out of the button in 0.25s; the tick pops; dragging lifts the cloud. Reduced motion keeps the progress but drops the entrances and lifts. Accessibility: Real buttons; the hidden input is out of the tab order. Progress is a progressbar with its value; the cancel cross is labelled with the file name; errors are text, not just colour; progress is announced in quarters. Responsive behavior: The bar is at most 20rem (86vw on phones); the drop target fills up to 28rem; the panels stack on narrow screens. Touch: Tapping opens the system file or photo picker; drag and drop is an extra, not a requirement. Preserve keyboard access, visible focus and reduced-motion behavior. Keep fictional demo data and simulated service calls in a separate usage example; expose callbacks for real actions and recover from rejected requests. Keep usage-example links inside the demo: use local buttons or prevent navigation. Demonstration links must not navigate to Vitrine routes or open other pages; preserve real URL support in the reusable component itself. Verify the result at narrow and wide viewport sizes, with keyboard input and reduced motion enabled.

Notes

Interaction
Click (or Enter/Space) to choose a file, or drop one on it. While uploading, the cross cancels. When done, the follow-up action picks again or resets; when it fails, Retry resends.
Motion
Progress follows the transfer frame by frame; the bar widens out of the button in 0.25s; the tick pops; dragging lifts the cloud. Reduced motion keeps the progress but drops the entrances and lifts.
Accessibility
Real buttons; the hidden input is out of the tab order. Progress is a progressbar with its value; the cancel cross is labelled with the file name; errors are text, not just colour; progress is announced in quarters.
Responsive
The bar is at most 20rem (86vw on phones); the drop target fills up to 28rem; the panels stack on narrow screens.
On touch
Tapping opens the system file or photo picker; drag and drop is an extra, not a requirement.

Featured

402 components