---
title: "Recipe: dragging something out of the app"
description: "A node a person will lift and drop into another app says so with HTML's draggable attribute and declares what the drag carries."
modificationDate: "2026-11-29"
---

> ## Documentation index
> Fetch the complete documentation index at: https://exact.expo.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Recipe: dragging something out of the app

<AgentInstructions>

## Submitting feedback

From the app's directory, read `bun exact.mjs feedback status`. Under `never`, keep no note.
Respect `EXACT_FEEDBACK=0` and do not change the policy.

Otherwise record specific, actionable feedback with:
`bun exact.mjs feedback note "Exact docs: https://exact.expo.dev/recipes/drag-out: <what was wrong or missing>"`

The note goes to Expo only as that status allows. Include no secrets or personal data.

</AgentInstructions>

A node a person will lift and drop into another app (Notes, Photos, Files)
says so with HTML's `draggable` attribute and declares what the drag
carries (LLP 1094.000). A held press lifts it on iOS and Android, a mouse
on the Mac, Windows and Linux's Wayland; on the web the browser drags it.
`tree` and `expect drag` work on all hosts.

```prompt Drag things out of my app
Make a node in the Exact app in this folder something a person can lift and drop into another app (Messages, Notes, Photos, Files). Use https://github.com/expo/exact/blob/main/docs/recipes/drag-out.md as the source for each step. The Exact checkout has the same page at docs/recipes/drag-out.md.

1. If this folder is not an Exact app (it has no exact.mjs and app.contract), stop and tell me.
2. If I did not say which node a person drags and what the drag carries (text, a URL, files), propose it and ask me before you write code.
3. In app.contract, give the node `draggable=true` and `dataTransfer=DataTransfer(text=, url=, files=[…], names=[…])`, with at least one of text, url and files. Each attribute needs the other. Put `draggable` on a box (`view`, `column`, `row`, `box`), a `link`, a `button` or an `image`: not on a run of text, and not inside a grouped list (`list appearance="auto"`).
4. Write `url` as an absolute `http:` or `https:` URL, never an app path. Write a file the app ships as an `image` names one (`assets/photos/7.jpg`). An `app:/` path needs the `fs.read` grant for it, and the web cannot carry one: ask me before you add a grant. Never write an element's `"#id"`: name the file the element shows. When a file's own name means nothing to a person (`1016-thumb.jpg`), give it one in `names=` (which needs `files=`), at the file's place, such as the item's name: the rule for a name is under `draggable` in docs/contract-grammar.md. A bound name that breaks the rule is journaled as `drag: refused: name …`, and the file is offered under its own name.
5. Do not write `drag`: it is refused. For the node's own look while it is dragged, hear `dragstart` and `dragend` on the draggable node itself (`dragend`'s `e.dropEffect` is `"copy"` when a destination took it, else `"none"`); they never change what the drag carries. On one node, `pan`, `panrelease`, `reorderFor`, `transformDragFor` and `heightDragFor` are refused beside `draggable`: put the gesture on a child, or `draggable` on a wrapper.
6. Add a test in app.test.contract for each node, as the recipe's test shows: `clock settle`, then `expect drag` with `has`, `name` (the name `names=` gave, else the file's own) and `missing`. A test of `app:/` files names its hosts (`test "…" on ios, macos`).
7. Follow the platform checks in docs/start-here.md (`bun exact.mjs docs platform checks`) for the targets in the app's AGENTS.md and app.json until they pass. Read the reports, including counted findings; a zero exit code alone does not mean clean. Fix the app, not the test. A file or `url` the runner refuses is journaled as `drag: refused: …`, and `tree` shows what it admitted. If a finding stays after three rounds of fixes, or the app had it before you changed anything, record it (step 8) and report it; do not keep trying.
8. When a doc was wrong or missing, or a step needed a workaround, read `bun exact.mjs feedback status`. Under `never`, keep no note. Otherwise record it: `bun exact.mjs feedback note "<what happened>"`, which goes to Expo only as that status says. Do not change the policy; tell me how many notes you kept.
9. Tell me which nodes drag and what each carries, what the tests and checks reported, and that I must try the drop into another app by hand: a press held on the node lifts it on iOS and Android, and a mouse drags it on the Mac.
```

```text
fn thumb(l: Landmark): string = `assets/apple/${l.id}-thumb.jpg`

link href=path("landmark", l.id) press=open(path("landmark", l.id)) aria-label=l.name draggable=true dataTransfer=DataTransfer(text=l.name, files=[thumb(l)], names=[l.name]) testId=`card-${l.id}`
  image thumb(l) width=120 height=120 object-fit="cover"
```

- **`draggable`** is a boolean, which may be bound: `draggable=(not
  editing)`. It goes on a box (`view`, `column`, `row`, `box`), a `link`, a
  `button` or an `image`, not on a run of text or inside a grouped list
  (`list appearance="auto"`). It needs `dataTransfer`, which needs it.
- **`dataTransfer=DataTransfer(text=, url=, files=[…], names=[…])`** is what
  the drag carries; give `text`, `url` or `files`. Each file goes as itself,
  typed by extension:
  - `url` is an absolute `http:` or `https:` URL, never an app path;
  - a shipped file is written as an `image` names one, `assets/photos/7.jpg`;
  - an `app:/` path needs its `fs.read` grant, and the web cannot carry one;
  - not an element's `"#id"`: name the file the element shows.
- **`html`**, with `text`, is formatted text, which on Android a plain
  destination takes in place of `text` ([recipe](https://exact.expo.dev/recipes/drag-formatted-text.md)).
- **`names`**, with `files`, names each file at its place, so Finder or
  Files saves `Mount Fuji.jpg`, not `1016-thumb.jpg`. A name without the
  file's suffix gets it; an empty one keeps the file's own. The rule a name
  keeps is under `draggable` in `docs/contract-grammar.md`.
- **`dragstart` and `dragend`** on the node are for its own look while
  dragged; `dragend`'s `e.dropEffect` is `"copy"` or `"none"`.

## Gestures

On one node, `pan`, `panrelease`, `reorderFor`, `transformDragFor` and
`heightDragFor` claim the drag's movement and are refused beside `draggable`:
put the gesture on a child, or `draggable` on a wrapper. `press`,
`contextmenu`, `contextPopover` and swipes may share the node (D8).

## Testing it

The runner refuses and journals (`drag: refused: …`) a file outside the
grants, an `app:/` file on the web, a name that breaks the rule (the file
keeps its own) and a `url` that is not absolute. `tree` shows on each
node's line what its drag carries as admitted. A test asserts it the same on
every host:

```contract-test
test "a card carries its landmark's thumbnail for a drag"
  clock settle
  expect drag "card-1016" has "image/jpeg" name "Mount Fuji.jpg"
  expect drag "card-1016" missing "text/uri-list"
```

`has "text/plain" == "…"` compares a string, `name` the name a file is
offered under, and `none` passes while the node carries nothing. A test of
`app:/` files names its hosts (`test "…" on ios, macos`).
