Photo Drop
A squircle drop tile for one photo or file, with marching ants, an upload ring, Try Again, locked and read-only.
Default
An empty squircle with a dashed edge and a +. Hover it, tab to it or drag a file over it and the edge wakes into marching ants. The real file input covers the tile, so a click, a drop and the keyboard all open the browser's own picker. A picked photo fills the same shape, and a camera badge shows when the tile wakes.
Choose a photoor drop it here
Uploading and Failed
onPick hands you a preview URL and the File, so you upload it yourself. Pass progress (0 to 1) while it goes: a ring in the key colour fills along the edge from the top, the photo dims, and the tile takes no new file. If the upload stops, set failed: the edge turns the error colour and Try Again calls onRetry. A tap still picks a different file. Pick a photo here to watch it upload; the first one fails.

Change photoTap it, or drop a new one on it
States
Uploading with a known amount and with progress="indeterminate" (a sweeping arc), failed, locked and read-only. Locked shows a lock badge where the camera sits, "Locked" and your lockedReason. Read-only shows the photo only, with a quiet rim and no hint; give it a readOnlyReason and it shows "Read-Only" and that line. Neither has an input, so nothing inside takes focus.

Uploading your photoUploading, 40%. Keep this page open.

Uploading your photoUploading. Keep this page open.

Your photo didn't uploadCheck your connection, then try again.

LockedCheck-in has started.

Read-OnlyIt can't be changed here.
File
With file, the tile holds an icon instead of a photo, src is the file's name, and Remove calls onClear. It is 128px unless you set size.
Choose a fileor drop it here
Sizes
size sets the tile's side in px. The clip and the edge are drawn from the same squircle path at any size. The default is 220, or 128 in file mode.



In Five Looks
Empty, uploading, failed, locked and read-only in each look on the theme picked in the docs. The Photo looks turn glass on over a photo: the tiles sit on a glass form panel and take the glass layer's control fill, and the badges blur the photo. Elsewhere nothing blurs.
Honcho Backstage
The tile in the Honcho kit's ink and field fill, from the theme alone. Today is the honcho theme; the other four looks are honcho-backstage. Over a photo the tiles sit on a glass form panel.
Installation
npx visor add photo-dropThis copies two files into your project:
components/ui/photo-drop/photo-drop.tsx— the componentcomponents/ui/photo-drop/photo-drop.module.css— the styles
Usage
import { PhotoDrop } from '@/components/ui/photo-drop/photo-drop';
<label htmlFor="photo">Your Photo</label>
<PhotoDrop id="photo" src={photo} onPick={(url, file) => { setPhoto(url); upload(file); }} />Theming
| Variable | Default | Sets |
|---|---|---|
--photo-drop-ink | --text-primary | The edge, the awake icon, the lead and the badge glyph |
--photo-drop-bg | --glass-on-control-fill, else --input-bg, else --surface-interactive-default | The tile's fill, and Remove and Try Again |
--photo-drop-bg-hover | --glass-on-control-hover-fill, else the fill 4% nearer the ink | The awake tile's fill |
--photo-drop-ring | --interactive-primary-bg | The upload ring |
--photo-drop-error | --border-error | The edge when invalid or failed |
--photo-drop-badge-bg | --surface-page, at 72% under glass | The camera and lock badges and the progress pill |
--photo-drop-dim | brightness(0.7) saturate(0.8) | The photo while uploading or failed |
--photo-drop-duration | --motion-duration-500 | Fill, colour and badge transitions |
--photo-drop-ease | --motion-easing-enter | Every transition's curve |
--photo-drop-hint-font-size | 15px | The hint beside the tile |
--photo-drop-lead-font-size | --font-size-lg | The hint's first line |
The squircle exponent is 5, the kit's soft corner. The edge is --stroke-width-regular and dashes 7px on, 6px off.
API Reference
PhotoDropProps
| Prop | Type | Default | Description |
|---|---|---|---|
id | string | — | The file input's id, for a <label htmlFor>. Required. |
src | string | — | The picked photo's URL (in file mode, the file's name), or empty. Required. |
onPick | (url: string, file: File) => void | — | Called with a preview object URL and the picked File, so you can upload it. |
size | number | 220 (128 in file mode) | Side of the tile, in px. |
file | { icon: ReactNode; accept?: string; onFile: (file: File) => void; onClear: () => void } | — | File mode: the tile shows the icon, the file's name sits beside it, and Remove calls onClear. |
progress | number | "indeterminate" | — | Uploading: 0 to 1, drawn as a ring along the edge in the key colour, or "indeterminate" for a sweeping arc. The tile takes no new file while it uploads. |
failed | boolean | — | The upload stopped: an error edge, "didn't upload" and Try Again. A tap still picks a new file. |
onRetry | () => void | — | Called by Try Again. |
locked | boolean | — | Locked: the photo or file shows with a lock badge, "Locked" and no input. |
lockedReason | ReactNode | — | Why it is locked, shown under "Locked". |
readOnly | boolean | — | Read-only: the photo (or file name) only, with a quiet rim, no hint and no input. |
readOnlyReason | ReactNode | — | Read-only with a note, shown under "Read-Only" (e.g. why it can't be changed). Without it, read-only shows no caption. |
alt | string | "" | The photo's alt text. Give one when the photo means something, as in read-only and locked. |
invalid | boolean | — | Sets aria-invalid on the input and draws the edge in the error colour. |
required | boolean | — | Sets aria-required on the input. |
describedBy | string | — | More ids for the input's aria-describedby (a field's hint or error), after the tile's own hint. |
...props | React.HTMLAttributes<HTMLDivElement> | — | Standard div attributes are forwarded to the row (tile and hint). |
Accessibility
- The file input covers the tile and takes the focus; label it with a
<label htmlFor={id}>(4.1.2) - The input is described by the tile's own hint and any ids you pass in
describedBy;invalidandrequiredsetaria-invalidandaria-required(3.3.1) - Focus wakes the edge and draws a ring around the tile and its hint at the focus-ring tokens, outside the clip (2.4.7)
- Uploading is a
progressbarnamed "Uploading" with its value, and the hint says how far it is in a status region (4.1.3) - A failed upload is announced in a status region, and Try Again is a native button after the input in the tab order
- Locked, read-only and uploading render no input, so the tab order skips the tile. Give the photo an
altwhen it means something - With
prefers-reduced-motion: reduce, the marching ants and the sweeping arc stop; focus still changes the edge and draws the ring (2.3.3)