Componenteditors0.72 KB gzipZero dependencies
Diff Editor
Editable side-by-side diff view.
Preview
Live Preview
Installation
Tokens guide →Add to your project via CLI (zero dependencies, code you own):
npx bigbullui add diff-editorOr install the full npm package:
npm install bigbulluiUsage
tsx3 lines
import { DiffEditor } from "@/components/ui/diff-editor"; <DiffEditor />Source code
diff-editor.tsx + 1 helperZero third-party dependencies (2 local files shown in tabs below).
tsxdiff-editor.tsx62 lines
"use client"; import * as React from "react";import { cn } from "./lib/utils"; export interface DiffEditorProps extends React.HTMLAttributes<HTMLDivElement> { before: string; after: string; readOnly?: boolean; onBeforeChange?: (v: string) => void; onAfterChange?: (v: string) => void;} /** Side-by-side editable diff comparison editor. */export function DiffEditor({ before = "", after = "", readOnly, onBeforeChange, onAfterChange, className, ...props }: DiffEditorProps) { const beforeLines = before.split("\n"); const afterLines = after.split("\n"); const maxLines = Math.max(beforeLines.length, afterLines.length);Props
Interactive Prop Playground
Tweak parsed AST props below to generate ready-to-paste JSX.
tsx3 lines
import { DiffEditor } from "@/components/ui/diff-editor"; <DiffEditor />| Prop | Type | Description |
|---|---|---|
| before | string | Configures before. (Default: "") |
| after | string | Configures after. (Default: "") |
| readOnly | boolean | Makes the control non-editable while remaining focusable. |
| onBeforeChange | (v: string) => void | Callback invoked on before change. |
| onAfterChange | (v: string) => void | Callback invoked on after change. |