UploadTile

UploadTile is an animated upload tile component for React Native and React, from the dissolve library. Attachment that assembles from grains, fills a progress ring, rejected files leave as dust.

An attachment tile for chat composers. The upload progress is the tile itself: from 0 to 1, its grains land one by one, a front running left to right, and at 1 the tile is whole. Only then the remove cross fades in. No ring, no badge. A file over maxSize, or an upload that rejects, completes, shakes three times, turns red and leaves as dust while the row closes up. Tap the tile during the upload to abort: the grains that have landed snap away from your finger. No picker dependency, you pass the files.

Install

React Native

Install the engine once per app and wrap the root layout in <DissolveProvider> (see Installation), then copy the component into components/dissolve:

npx expo install dissolve-ui @shopify/react-native-skia react-native-reanimated react-native-worklets react-native-gesture-handler expo-haptics
npx dissolve-ui add upload-tile --native
npx shadcn@latest add https://dissolve.rselmi.com/r/native/upload-tile.json

React

Needs React 19 and react-dom, nothing else: no engine, no provider, no Tailwind. Works in the Next.js App Router.

npx dissolve-ui add upload-tile --web
npx shadcn@latest add https://dissolve.rselmi.com/r/upload-tile.json

Usage

UploadTile.tsx (React Native)
import { UploadTray } from '@/components/dissolve/upload-tile';

<UploadTray
  files={files}
  upload={(file, onProgress, signal) => api.upload(file, { onProgress, signal })}
  maxSize={25 * 1024 * 1024}
  onAdd={pickFiles}
  onRemove={(file) => setFiles((all) => all.filter((f) => f.id !== file.id))}
/>
UploadTile.tsx (React)
import { UploadTray } from '@/components/dissolve/upload-tile';

<UploadTray
  files={files}
  upload={(file, onProgress, signal) => api.upload(file, { onProgress, signal })}
  maxSize={25 * 1024 * 1024}
  onAdd={pickFiles}
  onRemove={(file) => setFiles((all) => all.filter((f) => f.id !== file.id))}
/>

Props

PropTypeDefaultDescription
file{ id?, name, size, uri?, source? }requiredThe file. An image uri or source shows as a thumbnail, anything else as a file icon, name and size.
upload(file, onProgress, signal) => Promise<void>requiredYour upload. Report progress 0 to 1: it drives how many grains have landed. Stop when the signal aborts (a tap on the tile aborts it), reject to show the error state.
maxSizenumberBytes. A bigger file is rejected without starting the upload.
sizenumber72Tile side. 6 pt of room are kept around it for the cross and the grains.
spacingnumber0Space after the tile in a row. It closes up with the tile.
onDone(file) => voidCalled once the upload resolved and the tile is whole, as the cross appears.
onRemove(file, reason: 'rejected' | 'cancelled' | 'removed') => voidCalled once the tile has gone and its space has closed: drop the file here.
hapticsbooleantrueSuccess when whole, error on reject, light impact on cancel and remove.
classNamestringOuter wrapper classes (margins).
tileClassNamestringTile classes (background, radius).

Source

Previous: SweepTransition · Next: TaskCheck · All components

dissolve is MIT licensed. Source on GitHub, package on npm. This page as markdown. For AI agents: llms.txt.