Media upload grid
ProThe photos someone is adding: upload progress and errors, remove and retry, drag to reorder (mouse, touch or keyboard), an add tile and file drop. Not an M3 component (@windmorph/react-pro).
import { MediaUploadGrid } from '@windmorph/react-pro';Part of Windmorph Pro, paid components on the free core, not on sale yet. See the Pro guide for what it includes and to register interest.
Keyboard
| Key | Action | Where |
|---|---|---|
| Tab | Moves focus into the grid, onto the last focused tile. From a tile, Tab moves through that tile's buttons, then out of the grid. | |
| Arrow Up or Arrow Down or Arrow Left or Arrow Right | Move between tiles: Left and Right along the order, Up and Down between rows in the grid layout. At the grid's edge they stop, without scrolling the page.Between tiles | Between tiles |
| Enter | Opens the file picker.On the add tile | On the add tile |
| Enter | Picks the photo up to move it (with onReorder). The arrow keys then move between the places it can go, Enter drops it there and Escape cancels.On a photo | On a photo |
- In right-to-left layouts Arrow Left and Arrow Right follow the reading direction.
- The corner buttons and the action menu keep their own keys, as any
IconButtonandMenudo.
Screen reader
- Role
- A
gridof rows, one per tile, with the add tile last. Each photo's buttons are inside its row. - Accessible name
- The grid is named by your
aria-labeloraria-labelledby. Each photo is named by itsalt, the add tile bylabels.add("Add photos"). The buttons are namedlabels.remove("Remove Lake at dusk"),labels.actions("Options for Lake at dusk") andlabels.retry("Retry"), and show that name as the icon button's own tooltip on hover and keyboard focus, without reading it twice. - States announced
- Each photo is described by its state: "Uploading, 40%" (
labels.uploading), or "Couldn't upload. Too large" (labels.failedand the item'serror). The progress indicator is named by the same words. Whiledisabled, every button and the add tile are disabled.
- Moving a photo is React Aria's drag and drop: each step is announced, and the places it can go are read as "Insert between … and …".
- The thumbnails are decorative (
alt=""): the tile carries the name. The error strip on a photo is hidden, since the description already says it, and so is the "Drop photos to add them" overlay. - Every word comes from
labels.
Focus
- The grid is one Tab stop: focus returns to the last focused tile. A focused tile shows M3's focus indicator inside its edge (a 3px
secondaryoutline drawn inset), so a scrolling row never clips it. - Removing a photo moves focus to the tile after it (which may be the add tile), or else the one before it, without scrolling the page. Retry keeps focus on the photo.
- When a photo's Options menu closes (Escape, a choice, a press outside), focus returns to its Options button.
Touch target
- Tiles are square: a third to a fifth of the grid's width (2 columns below 280px, 3 below 600px, 4 up to 839px, 5 from 840px), so they stay 88px or more, or 112px in the
rowlayout. - The remove, action menu and retry buttons are extra-small icon buttons (32px tall) with an invisible 48 × 48px touch target. They stay at density 0 in a dense theme, and a failed photo's Retry takes the start corner (the action menu steps aside), so no two targets overlap.
- A mouse drags a photo to move it; on touch a long press picks it up, so the page still scrolls. The keyboard can do the same, and dropping files from the computer has the add tile as its alternative.
Motion
- When the order changes, tiles slide to their new places, and new tiles grow and fade in. Under reduced motion nothing moves, but a new photo still fades in (it only stops growing).
- Colours and opacity (a dragged photo, the drop bars, the drop overlay) fade on the effects spring; under reduced motion they change at once. The press ripple on the add tile and on a photo being picked up appears at full size without growing.
What you need to do
- Name the grid with
aria-labeloraria-labelledby, and give every photo analt: it names the tile and its buttons, so it can't be empty. - Pass
labelsfrom your translations;uploading,removeandactionsare functions, so the words can go in any order. - Pass
onReorderonly when the order matters, and setdisabledwhile the post is being sent. - Give a failed photo an
errorthat says why ("Too large (max 10 MB)") and passonRetrywhen trying again can help. - The grid announces nothing when it refuses files (off
accept, or pastmaxItems): handleonFilePick(oronFileReject) and say why in words a screen reader hears too, such as a snackbar or a status line, once for the whole pick or drop. - In forced-colours mode tiles, the drop bars and the drop outline use system colours; keep
classNamesoverrides from removing them. - Give custom icons (
removeIcon,retryIcon,actionsIcon,addIcon) no name of their own: the buttons are named bylabels.