Inline Rewrite
Inline Rewrite
Drag a dial to rewrite a paragraph in place, with shared words gliding into position.
Dependencies
React
Installation
Add this component with your preferred package manager.
pnpm dlx shadcn@4.21.5 add @cavemio/inline-rewriteFirst install? Configure @cavemio once
Run npx shadcn@4.21.5 init if shadcn is not set up, then merge this entry into the registries field in your existing components.json. Keep your other settings and registries.
components.json
{
"registries": {
"@cavemio": "https://registry.cavemio.dev/r/cavemio-{name}.json"
}
}Usage
Uses local demo data; no AI service or network requests.
import { InlineRewrite } from "@/components/inline-rewrite";
<InlineRewrite label="Length" description="Adjust how much detail the paragraph includes." defaultValue={1} versions={[{ label: "Shorter", text: "Fresh beans, delivered." }, { label: "Original", text: "Fresh beans from small roasters, delivered every two weeks." }]} />Props
| Prop | Type | Description |
|---|---|---|
| versions | RewriteVersion[] | Required. Available rewrite versions, including their labels and text. |
| value | number | Optional. The chosen version's index. |
| defaultValue | number | Optional. Initial selection when uncontrolled. |
| onValueChange | (index: number) => void | Optional. Called when the selection changes. |
| originalIndex | number | Optional. The version the counts compare against. Defaults to the one chosen first. |
| onRewrite | (request: RewriteRequest) => Promise<string> | Optional. Asynchronous rewrite handler. Resolve with the replacement text. |
| label | string | Optional. Visible heading and accessible name for the slider, e.g. "Tone". |
| description | string | Optional. Help text, shown beside the heading in an info tooltip. |
| highlight | boolean | Optional. Let new words glow for a moment after each rewrite. |
Accessibility & motion
The visible label names the keyboard-accessible slider; arrow keys, Home and End select versions. Optional description text appears in an info tooltip on hover or focus and describes the slider for assistive technology. Status updates are announced politely. Reduced motion changes text in place and disables slider movement.
pnpm dlx shadcn@4.21.5 add @cavemio/inline-rewrite