Writing Assistant
Rewrite a selection in place; the suggestion never lands on text you changed.
Select text, or none for all of it, then pick Shorter, Friendlier, Fix grammar or say what you want. The rewrite streams in beside the original as a diff; Accept puts it in place and Reject leaves your text alone.
PROGet Writing Assistant and 176 other Pro components with pro lifetime — Get Pro
- Category
- AI Chat
- Access
- ProPro · unlocked
- Source
- 402 lines · one file
- States
- 5 drawn
- Added
- 13 Nov 2026
The decision inside it
A suggestion belongs to the text it was asked for
If you edit the selected text while the rewrite streams, the suggestion is marked out of date and can't be applied over your edit; one click asks again. Edits elsewhere in the text are fine: the selection follows them.
When to use it
Use Writing Assistant for AI rewrites of a selection inside a text the person is writing: shorter, friendlier, fixed grammar or their own instruction, shown as a diff. For drafting a whole email use Email Draft; for chat use Prompt Composer.
Installation
How you get it
Paste this into Claude Code, Cursor, Codex or any coding agent. It installs the file and uses it as it is, instead of writing a new one.
Use Liro's Writing Assistant for this.
Install it: npx shadcn@latest add @liro/writing-assistant
(the @liro registry is set up in components.json, with LIRO_KEY in .env.local)
Import it from @/components/ui/writing-assistant.
Do not rewrite or restyle it. Pass my data through its props
and keep its built-in states.For the full brief with every prop and the mistakes assistants usually make, use Copy prompt above. Pro components install through the @liro registry with your CLI token: see the Namespaced tab.
Usage
import * as React from "react";
import { WritingAssistant, type RewriteRequest } from "@/components/ui/writing-assistant";
async function* rewrite({ text, instruction, signal }: RewriteRequest) {
const res = await fetch("/api/rewrite", { method: "POST", body: JSON.stringify({ text, instruction }), signal });
const reader = res.body!.pipeThrough(new TextDecoderStream()).getReader();
for (;;) {
const { value, done } = await reader.read();
if (done) return;
yield value;
}
}
export function ReplyEditor() {
const [body, setBody] = React.useState("");
return <WritingAssistant title="Reply" value={body} onChange={setBody} onRewrite={rewrite} />;
}API reference
“Copy prompt” above puts a full brief on your clipboard, install command, dependencies, props, and the mistakes an assistant usually makes with this component.
Props
Read from the component’s own TypeScript interface when the site is built, so this table cannot drift from the file you install.
| Type | Notes | ||
|---|---|---|---|
value | string | No | – |
defaultValue | string | No | – |
onChange | (value: string) => void | No | – |
onRewrite | (req: RewriteRequest) => string | Promise<string> | AsyncIterable<string> | Yes | – |
presets | RewritePreset[] | No | – |
title | string | No | Above the editor: "Reply to Olivia". |
placeholder | string | No | – |
defaultSelection | [number, number] | No | A range to select on mount, [start, end]. |
Dependencies
npm packages
clsxframer-motionlucide-reacttailwind-mergeLiro foundations, installed alongside it
liro-themebuttonStates
All of them are drawn by the component. None is left for you to design.
- Selected text
- Streaming
- Suggestion
- Out of date
- Rewrite fails
Accessibility
- Keyboard reachable throughout, in visual order
- Focus trapped in overlays, Escape closes them
- Focus returns to whatever opened it
- Live regions announce what changed, not that something did
- Honours prefers-reduced-motion
Responsive behavior
- Sizes to its container, not the viewport
- Usable from 320px up
- Pointer-based interaction, so trackpad and touch both work
- No hover-only affordances