Rewrite

Shorten, expand, friendlier, formal or fix grammar, streamed on device, with replace / diff / side-by-side results and accept/reject.

Mock· scripted answersNo model runs in a browser, so every answer here is scripted. On a phone it comes from the model.
  • Apple Foundation Models: supported
  • Gemini Nano: supported
  • Llama (not yet supported): not supported
  • A cloud model: supported

Install

npx ondai add rewrite

Usage

import { Rewrite } from '@/components/ondai/rewrite'

<Rewrite value={draft} onAccept={setDraft} presentation="toolbar" resultView="diff" />
  • Modes: shorten, expand, friendlier, formal, fix grammar, or custom with your own instruction.
  • Result views: replace, word-level diff, or side by side.

Customize

Every AI component takes the same look and customization props, so it fits your app rather than ours.

<Rewrite
  variant="pop"
  tint="#FF5A5F"
  size="lg"
  radius={12}
  icons={{ shorten: Search, expand: null }}
  labels={{ shorten: '…', expand: '…' }}
/>
PropWhat it does
variantThe look of the whole component: clean, minimal, glass, pop, candy, metal, shine
sizesm, md, lg; type, rows, icons and keys scale together
tintAny colour; the variant paints its keys, tiles and glow in it
radiusCorner radius of the container
iconsReplace any icon (a lucide component, an element, or null to hide it): shorten, expand, friendlier, formal, fix, custom, menu, accept, reject, retry
labelsEvery visible and spoken string; defaults are exported as rewriteLabels: shorten, expand, friendlier, formal, fix, custom, workingShorten, workingExpand, workingFriendlier, workingFormal, workingFix, workingCustom, menu, accept, reject, retry, before, after, words, word, sameLength, empty, modes
SlotsDraw a part yourself: renderMode, renderResult, renderActions, renderEmpty
stylesStyle any named part

Variants

PropOptions
variantclean, minimal, glass, pop, candy, metal, shine
presentationtoolbar, menu, chips
resultViewreplace, diff, sideBySide
sizesm, md, lg

Token budget

Input budget: 1800 tokens. Input is truncated to half the window so the rewrite fits in the rest.

Fallback

When no provider is ready the component renders the unavailable state (AvailabilityGate copy) and, where a deterministic path exists, keeps working without the model.

Eval score

Fixtures: evals/rewrite/fixtures.json.

Files

Registry dependencies: button, chip, on-device-badge, sheet, shimmer-text, skeleton, streaming-text, surface

npm dependencies: @ondai/core, @ondai/tokens, expo-haptics, lucide-react-native, react-native-reanimated, react-native-svg

On this page