---
title: "Recipe: formatted text in a drag"
description: "html= beside text= gives a drag formatted text, which Notes, Mail, TextEdit, Pages and a browser's editor take where a plain field takes text (LLP 1094.000 D19)."
modificationDate: "2026-12-01"
---

> ## 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: formatted text in a drag

<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-formatted-text: <what was wrong or missing>"`

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

</AgentInstructions>

`html=` beside `text=` gives a drag formatted text, which Notes, Mail,
TextEdit, Pages and a browser's editor take where a plain field takes
`text` (LLP 1094.000 D19).

```prompt Use this recipe in my app
Make the Exact app in this folder do what this recipe describes. Use https://github.com/expo/exact/blob/main/docs/recipes/drag-formatted-text.md as the source for each step. The Exact checkout has the same page at docs/recipes/drag-formatted-text.md.

1. If this folder is not an Exact app (it has no exact.mjs and app.contract), stop and tell me.
2. Read the recipe. If it leaves a choice that I did not make (which screen, which data, which platforms), propose one and ask me before you write code.
3. Do what the recipe says, in its order, with its tags, properties, functions and grants. Its component, state and URL names are examples. Change nothing else in the app.
4. Add a test in app.test.contract for each thing a person does that you changed. Copy the recipe's `contract-test` block where it has one. A drive operation the recipe shows (`call`, a ticket answer such as `tap @N accepted`) is not a test step: run it with `bun exact.mjs agent`.
5. 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. If a finding stays after three rounds of fixes, or the app had it before you changed anything, record it (step 6) and report it; do not keep trying.
6. 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.
7. Tell me what you changed, what the tests and checks reported, and what I must still do by hand.
```

```text
fn place(p: Place): string = `<p style="color: ${cssValue(p.ink)};"><b>${escapeHtml(p.name)}</b></p><div><img src="${escapeHtml(p.photo)}"></div>`

row draggable=true dataTransfer=DataTransfer(text=c.name, html=`<h2>${escapeHtml(c.name)}</h2>${c.places.map(p => place(p)).join("")}`, files=c.places.map(p => p.photo))
```

- **It is HTML with CSS**: headings, paragraphs, quotes, lists, tables,
  bold, links, pictures, and `style` with fonts, sizes, weights, colours,
  lines, alignment, indents, spacing and cell borders. The full list is
  under `draggable` in `docs/contract-grammar.md`; anything else is refused
  by name when compiled.
- **Data goes in two ways only**: `escapeHtml(x)` in text and in a quoted
  attribute, and `cssValue(x)` in a `style` declaration's value, after its
  `:`. A number or a boolean may stand in either. Anything else, a bare
  `${p.name}` among them, is refused when compiled.
- **Say less.** A run with no font or colour takes the destination's own.
  What you write goes with the drag, as a copy from another app does, and
  the destination keeps what it keeps. A role (`-exact-label`) is the
  colour the app shows as the drag begins.
- **Pictures**: each picture's `src` is one of `files` or of `pictures`.
  With `files`, each picture is also a file that Photos, Files and a
  page's upload take, and Notes takes the pictures without the text.
  With `pictures`, the drag is one item, the text with its pictures
  inside: Notes takes both, Ask Siri shows it as a document, and Photos
  and Files take nothing.

## On Android, `text=` is not used

On Android, when `html=` is set, a destination that takes plain text (a
search box, a chat field, a plain `EditText`) gets the words of `html`,
not `text`. For the drag above that is the collection's name, then each
place's name, not `c.name` alone. Android's own apps work this way: a drag
item's plain text is read from its formatted text. Every other platform
gives such a destination `text`. So write `html` whose words read well as
plain text, and do not rely on `text` reaching Android.

## Testing it

`tree` shows a node's formatted text as `text/html "…"`, in the canonical
form every host gets: each `style` its longhands in one order, aliases
written as `b`, `i`, `s` and `u`, runs beside a block in a `div` of their
own. A test compares it:

```contract-test
test "a collection carries its places as formatted text"
  clock settle
  expect drag "collection" has "text/html" == "<h2>Peaks</h2><p style=\"color: #336699;\"><b>Fuji</b></p><div><img src=\"assets/fuji.jpg\"></div>"
```

A picture, link, attribute or declaration the runner refuses is left out
and journaled (`drag: refused: html: …`); markup it cannot read refuses
the formatted text, and the drag carries the rest.
