# Inline Rewrite

AI rewrite for selected text, done in place: a soft wave runs across the words while it loads, then the text morphs word by word, with kept words gliding to their new spots, removed words blurring out and new words wiping in, and Undo morphing the old wording back.

- Page and source: https://uibrik.com/components/inline-rewrite
- Install (Pro, needs a license key, see https://uibrik.com/docs/pro): `npx shadcn@latest add @uibrik-pro/inline-rewrite`
- Packages: none beyond React
- Import: `import { InlineRewrite } from "@/components/uibrik/inline-rewrite/inline-rewrite"`

Where to use the Inline Rewrite React component:

- **Writing and email tools**: Selecting a sentence and picking Improve, Shorter or Formal morphs the wording in place, so the change is easy to follow. Pairs with [Email Composer](https://uibrik.com/components/email-composer) and [Prompt Input](https://uibrik.com/components/prompt-input).
- **AI editors and docs**: New words keep a fading wash after the morph, so readers see exactly what the model touched. Pairs with [Streaming Chat](https://uibrik.com/components/streaming-chat) and [Cited Answer](https://uibrik.com/components/cited-answer).
- **Product copy review**: Undo and Cmd+Z morph the original wording back, which makes trying several rewrites feel safe.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| accent | `string` | `"#8b5cf6"` | Loading wave, incoming words and their wash. |
| duration | `number` | `420` | Length of the morph. |
| stagger | `number` | `35` | Delay between new words wiping in. |
| highlightChanges | `boolean` | `true` | Leave a fading wash on the new words. |
| onRewrite | `(text: string, action: string) => Promise<string> \| string` |  | Returns the rewritten selection, e.g. from an AI call. |
| value | `string` |  | The text. Pass with onChange to control it. |
| defaultValue | `string` |  | Starting text when uncontrolled. |
| onChange | `(value: string) => void` |  | Called with the full text after each rewrite or undo. |
| actions | `{ id: string; label: string }[]` | `Improve, Shorter, Formal` | Toolbar buttons. The first runs on Cmd+Enter. |
| ref | `Ref<{ select(start, end): void; rewrite(start, end, action?): void; undo(): void }>` |  | Drive it from code, e.g. a first-visit hint. |
| aria-label | `string` | `"Text"` | Accessible name for the text block. |
| className | `string` |  | Classes for the wrapper. |
| textClassName | `string` |  | Classes for the text, such as font size and line height. |
